Skip to content

Commit c81c02c

Browse files
committed
Extract string tests to their own file
1 parent 43f59db commit c81c02c

File tree

2 files changed

+213
-208
lines changed

2 files changed

+213
-208
lines changed

Tests/syntax_test_PowerShell.ps1

Lines changed: 1 addition & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -171,72 +171,6 @@ $variable.Name.Method( )
171171
# ^^^^^^^^^^^^^^^ - variable.other.readwrite
172172
# ^ - meta.function-call
173173

174-
# In double-quoted strings, only the variable should be highlighted, not the property
175-
"This is my $variable.Name!"
176-
# <- punctuation.definition.string.begin
177-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string
178-
#^^^^^^^^^^^ string.quoted.double
179-
# ^^^^^^^^^ meta.interpolation variable.other.readwrite - string
180-
# ^ punctuation.definition.variable
181-
# ^^^^^^ string.quoted.double - meta.interpolation - variable - punctuation
182-
# ^ punctuation.definition.string.end
183-
184-
# When used in a subexpression, both should be highlighted
185-
"This is my $($variable.Name)!"
186-
# <- punctuation.definition.string.begin
187-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string
188-
#^^^^^^^^^^^ string.quoted.double
189-
# ^^^^^^^^^^^^^^^^^ meta.interpolation - string
190-
# ^^ string.quoted.double - meta.interpolation
191-
# ^^ punctuation.section.interpolation.begin
192-
# ^^^^^^^^^ variable.other.readwrite
193-
# ^ punctuation.definition.variable
194-
# ^ punctuation.accessor.dot
195-
# ^^^^ variable.other.member
196-
# ^ punctuation.section.interpolation.end
197-
# ^ punctuation.definition.string.end
198-
199-
# $ENV:ComputerName should be highlighted
200-
"This is the name of my computer: $ENV:ComputerName"
201-
# <- punctuation.definition.string.begin
202-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string
203-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
204-
# ^^^^^^^^^^^^^^^^^ meta.interpolation - string
205-
# ^ punctuation.definition.variable
206-
# ^^^^ support.variable.drive
207-
# ^^^^^^^^^^^^ variable.other.readwrite
208-
# ^ punctuation.definition.string.end
209-
210-
# Here as well
211-
"This is the name of my computer: ${ENV:ComputerName}"
212-
# <- punctuation.definition.string.begin
213-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string
214-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
215-
# ^^^^^^^^^^^^^^^^^^^ meta.interpolation - string
216-
# ^ punctuation.definition.variable
217-
# ^ punctuation.section.braces.begin
218-
# ^^^^ support.variable.drive
219-
# ^^^^^^^^^^^^ variable.other.readwrite
220-
# ^ punctuation.definition.string.end
221-
222-
# The @splat references only work in argument mode, should not highlight in strings
223-
"This is a @double quoted string."
224-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double
225-
# ^ - punctuation.definition.variable
226-
# ^^^^^^^ - variable
227-
228-
# double check scopes for automatic variables in strings
229-
"$_ $$ $Pwd"
230-
#^^ variable.language
231-
# ^^ variable.language
232-
# ^^^^ variable.language
233-
234-
# Single quotes string
235-
'This is a string'
236-
# <- punctuation.definition.string.begin
237-
#^^^^^^^^^^^^^^^^^ meta.string string.quoted.single
238-
# ^ punctuation.definition.string.end
239-
240174
# Hashtable
241175
$properties = @{
242176
# <- punctuation.definition.variable
@@ -426,66 +360,6 @@ $a3[1..2]
426360
# ^ punctuation.section.brackets.end
427361
# ^^^^^^^^^^^^^^^ meta.brackets.indexer
428362

429-
# Single quoted strings
430-
'This is a single quoted string.'
431-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single
432-
'$This is a single ''quoted'' string.'
433-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single
434-
# ^^ constant.character.escape
435-
# ^^ constant.character.escape
436-
'This is a
437-
single quoted string.'
438-
# ^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single
439-
'This #also'
440-
# ^^^^^^^^^^^^ meta.string string.quoted.single
441-
'$(Invoke-Something)'
442-
# ^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single - meta.interpolation - variable - support
443-
'This "string" is nice.'
444-
# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.single
445-
446-
# Double quoted strings
447-
"This is a double quoted string."
448-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double
449-
"$This is a double ""quoted"" string."
450-
# ^ meta.string string.quoted.double
451-
# ^^^^^ meta.string meta.interpolation variable.language - string
452-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double - meta.interpolation
453-
# ^^ constant.character.escape
454-
# ^^ constant.character.escape
455-
"This is a
456-
double quoted string."
457-
# ^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double
458-
"This #also"
459-
# ^^^^^^^^^^^^ meta.string string.quoted.double
460-
"$(Invoke-Something)"
461-
# ^ meta.string string.quoted.double
462-
# ^^^^^^^^^^^^^^^^^^^ meta.string meta.interpolation - string
463-
# ^^ punctuation.section.interpolation.begin
464-
# ^^^^^^^^^^^^^^^^ support.function
465-
# ^ punctuation.section.interpolation.end
466-
# @@@@@@@@@@@@@@@@ reference
467-
"This 'string' is nice."
468-
# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double
469-
470-
# Double quoted here-string
471-
@"
472-
# <- string.quoted.double.heredoc
473-
# <- string.quoted.double.heredoc
474-
$This is a 'double quoted'
475-
# <- punctuation.definition.variable
476-
#^^^^ variable.language
477-
Isn't it "nice"??
478-
There is no @platting here!
479-
# ^^^^^^^^^ - variable - punctuation
480-
"@
481-
# <- string.quoted.double.heredoc
482-
# <- string.quoted.double.heredoc
483-
@'
484-
#<- meta.string string.quoted.single.heredoc punctuation.definition.string.begin
485-
A 'single quoted' "heredoc"
486-
'@
487-
#<- meta.string string.quoted.single.heredoc punctuation.definition.string.end
488-
489363
# Numeric constants
490364

491365
-3 +3 3 3l 3lm 3lmb
@@ -1487,75 +1361,6 @@ $b -cLike $c
14871361
"HEY" -ile "hey"
14881362
# ^^^^ keyword.operator.comparison
14891363

1490-
# format
1491-
"{0:N2}" -f $a
1492-
# ^^^^^^^^ string.quoted.double
1493-
# ^^ keyword.operator.string-format
1494-
"{0:D8}" -f $a
1495-
# ^^^^^^^^ string.quoted.double
1496-
# ^^ keyword.operator.string-format
1497-
"{0:C2}" -f $a
1498-
# ^^^^^^^^ string.quoted.double
1499-
# ^^ keyword.operator.string-format
1500-
"{0:P0}" -f $a
1501-
# ^^^^^^^^ string.quoted.double
1502-
# ^^ keyword.operator.string-format
1503-
"{0:X0}" -f $a
1504-
# ^^^^^^^^ string.quoted.double
1505-
# ^^ keyword.operator.string-format
1506-
(1.11).ToString("#.#")
1507-
# ^ punctuation.section.group.begin
1508-
# ^^^^ meta.number.float.decimal constant.numeric.value
1509-
# ^ punctuation.section.group.begin
1510-
# ^ string.quoted.double
1511-
"{1,10} {0,10} {2,10:x}" -f "First", "Second", 255
1512-
# ^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
1513-
# ^^ keyword.operator.string-format
1514-
# ^^^ meta.number.integer.decimal constant.numeric.value
1515-
("{0,6}" -f 4.99), ("{0,6:##.00}" -f 15.9)
1516-
# ^^ keyword.operator.string-format
1517-
# ^^^^ meta.number.float.decimal constant.numeric.value
1518-
# ^^^^^^^^^^^^^ string.quoted.double
1519-
# ^^ keyword.operator.string-format
1520-
"{0:R}" -f (1mb/2.0)
1521-
# ^ keyword.operator.string-format
1522-
# ^ meta.number.integer.decimal constant.numeric.value
1523-
# ^^ meta.number.integer.decimal constant.numeric.suffix
1524-
"{0:00.0}" -f 4.12341234
1525-
# ^ keyword.operator.string-format
1526-
"{0:##.#}" -f 4.12341234
1527-
# ^ string.quoted.double
1528-
# ^ keyword.operator.string-format
1529-
# ^^^^^^^^^^ meta.number.float.decimal constant.numeric.value
1530-
"{0:#,#.#}" -f 1234.121234
1531-
# ^ string.quoted.double
1532-
# ^ keyword.operator.string-format
1533-
"{0:##,,.000}" -f 1048576
1534-
# ^ string.quoted.double
1535-
# ^ keyword.operator.string-format
1536-
"{this is not a #comment}"
1537-
# ^ - comment
1538-
"{0:##.#E000}" -f 2.71828
1539-
# ^ string.quoted.double
1540-
# ^ keyword.operator.string-format
1541-
"{0:#.00'##'}" -f 2.71828
1542-
# ^ string.quoted.double
1543-
# ^ keyword.operator.string-format
1544-
"{0:POS;NEG;ZERO}" -f -14
1545-
# ^ string.quoted.double
1546-
# ^ keyword.operator.string-format
1547-
"{0:$## Please}" -f 14
1548-
# ^ string.quoted.double
1549-
# ^ keyword.operator.string-format
1550-
"{0,-8:P1}" -f 1.75
1551-
# ^ string.quoted.double
1552-
# ^ keyword.operator.string-format
1553-
"{0,10:N3}{1,10:N3}{2,10:N3}{3,10:N3}" -f 0.2, 0.3, 0.45, 0.91
1554-
# ^ keyword.operator.string-format
1555-
'{0:00000.000}' -f 7.125
1556-
# ^ string.quoted.single
1557-
# ^ keyword.operator.string-format
1558-
15591364
function Test-Function {}
15601365
# @@@@@@@@@@@@@ definition
15611366
function New-Object {}
@@ -1653,19 +1458,7 @@ function Out-WithYou {}
16531458
# ^ constant.language
16541459
# ^ punctuation.definition.comment
16551460
# ^^^^^^^^^ comment.line
1656-
"Escaped chars: `", `n, `$, `b, `t, `e, `u{10ffff}, `""
1657-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
1658-
# ^^ constant.character.escape
1659-
# ^^ constant.character.escape
1660-
# ^^ constant.character.escape
1661-
# ^^ constant.character.escape
1662-
# ^^ constant.character.escape
1663-
# ^^ constant.character.escape
1664-
# ^^^^^^^^^^ constant.character.escape
1665-
# ^^ constant.character.escape
1666-
'But here they''re not escape chars: `", `n, `$, `b, `"'
1667-
# ^^ constant.character.escape
1668-
# ^^^^^^^^^^^^^^^^^^^ - constant
1461+
16691462
function get-number {}
16701463
# @@@@@@@@@@ definition
16711464
"When you call a method: $( get-number | %{ invoke-command $( [string]::format("Like (this{0})","what?") ) $var } )"

0 commit comments

Comments
 (0)