Skip to content

Commit bd89ebc

Browse files
committed
Partialy fix upper lower tests
1 parent 849adcb commit bd89ebc

File tree

4 files changed

+83
-56
lines changed

4 files changed

+83
-56
lines changed

tests/pester/Syntax.Tests.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ Describe "Syntax highlighting" {
7171
}
7272
}
7373
}
74-
# TODO: These are bugs, make it 0
75-
$errorCounter | Should be 1
74+
$errorCounter | Should be 0
7675
}
7776

7877
It "produces same tokens for lower case" {

tests/pester/SyntaxHelper.psm1

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,21 @@ function Test-ScopesEqual
133133
if ($leftScope.startOffset -ne $rightScope.startOffset) {return $false}
134134
if ($leftScope.endOffset -ne $rightScope.endOffset) {return $false}
135135
if ($leftScope.Text -ne $rightScope.Text) {return $false}
136-
#TODO: this is week, need to verify that Kind is the same
137-
#if ($leftScope.Kind.Split('.')[0] -ne $rightScope.Kind.Split('.')[0]) {return $false}
136+
if ($leftScope.Kind -ne $rightScope.Kind)
137+
{
138+
# TODO: what's that??
139+
$bugsExclude = @('entity.name.function*', 'keyword.operator*', 'storage.type*', 'entity.other.attribute-name*', '*constant*')
140+
foreach ($bug in $bugsExclude)
141+
{
142+
if (($leftScope.Kind -like $bug) -and ($rightScope.Kind -like $bug))
143+
{
144+
Write-Warning "[Fix me in SyntaxHelper.psm1] Ignore mistmatch in left scope $leftScope and right scope $rightScope"
145+
return $true
146+
}
147+
}
148+
149+
return $false
150+
}
138151
return $true
139152
}
140153

tests/py/__init__.py

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -55,57 +55,63 @@ def getTestFilePath(self):
5555

5656
def getTokens(self):
5757
selectors = [
58-
"comment.block",
59-
"comment.documentation.embedded",
60-
"comment.line.number-sign",
61-
"constant.character.escape",
62-
"constant.language",
63-
"constant.numeric.hexadecimal",
64-
"constant.numeric.scientific",
65-
"constant.string.documentation",
66-
"entity.name",
67-
"entity.name.function.invocation",
68-
"entity.other",
69-
"entity.other.attribute-name",
70-
"entity.other.attribute.parameter",
71-
"interpolated.complex.source",
72-
"interpolated.simple.source",
73-
"keyword.control",
74-
"keyword.operator.assignment",
75-
"keyword.operator.bitwise",
76-
"keyword.operator.comparison",
77-
"keyword.operator.documentation",
78-
"keyword.operator.logical",
79-
"keyword.operator.math",
80-
"keyword.operator.other",
81-
"keyword.operator.range",
82-
"keyword.operator.redirection",
83-
"keyword.operator.string-format",
84-
"keyword.operator.unary",
85-
"keyword.other",
86-
"keyword.other.statement-separator",
87-
"meta",
88-
"meta.group.array-expression",
89-
"meta.group.complex.subexpression",
90-
"meta.scriptblock",
91-
"punctuation.end.definition.comment.block",
92-
"punctuation.start.definition.comment.block",
93-
#"source", # this scope represents the whole file
94-
"storage",
95-
"storage.modifier.scope",
96-
"string.quoted.double",
97-
"string.quoted.double.heredoc",
98-
"string.quoted.single",
99-
"string.quoted.single.heredoc",
100-
"support.constant",
101-
"support.constant.variable",
102-
"support.function",
103-
"support.variable.automatic",
104-
"support.variable.drive",
105-
"variable.language",
106-
"variable.other",
107-
"variable.other.normal",
108-
"variable.other.readwrite",
58+
"comment.block.powershell",
59+
"comment.documentation.embedded.powershell",
60+
"comment.line.number-sign.powershell",
61+
"constant.character.escape.powershell",
62+
"constant.language.powershell",
63+
"constant.numeric.hexadecimal.powershell",
64+
"constant.numeric.scientific.powershell",
65+
"constant.string.documentation.powershell",
66+
"entity.name.function",
67+
"entity.name.function ",
68+
"entity.name.function.invocation.powershell",
69+
"entity.name.tag",
70+
"entity.other.attribute-name",
71+
"entity.other.attribute-name ",
72+
"entity.other.attribute-name.powershell",
73+
"entity.other.attribute.parameter.powershell",
74+
"interpolated.complex.source.powershell",
75+
"interpolated.simple.source.powershell",
76+
"keyword.control.powershell",
77+
"keyword.operator.assignment.powershell",
78+
"keyword.operator.bitwise.powershell",
79+
"keyword.operator.comparison.powershell",
80+
"keyword.operator.documentation.powershell",
81+
"keyword.operator.logical.powershell",
82+
"keyword.operator.math.powershell",
83+
"keyword.operator.other.powershell",
84+
"keyword.operator.range.powershell",
85+
"keyword.operator.redirection.powershell",
86+
"keyword.operator.string-format.powershell",
87+
"keyword.operator.unary.powershell",
88+
"keyword.other.powershell",
89+
"keyword.other.statement-separator.powershell",
90+
"meta.function",
91+
"meta.group.array-expression.powershell",
92+
"meta.group.complex.subexpression.powershell",
93+
"meta.scriptblock.powershell",
94+
"PowerShell",
95+
"punctuation.end.definition.comment.block.powershell",
96+
"punctuation.start.definition.comment.block.powershell",
97+
"source.powershell",
98+
"storage.modifier.scope.powershell",
99+
"storage.type",
100+
"storage.type.powershell",
101+
"string.quoted.double.heredoc.powershell",
102+
"string.quoted.double.powershell",
103+
"string.quoted.single.heredoc.powershell",
104+
"string.quoted.single.powershell",
105+
"support.constant.automatic.powershell",
106+
"support.constant.powershell",
107+
"support.constant.variable.powershell",
108+
"support.function.powershell",
109+
"support.variable.automatic.powershell",
110+
"support.variable.drive.powershell",
111+
"variable.language.powershell",
112+
"variable.other.normal.powershell",
113+
"variable.other.powershell",
114+
"variable.other.readwrite.powershell",
109115
]
110116
tokens = []
111117
for selector in selectors:

tests/py/syntax_def/test_token_gen.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@ def testGetTokens(self):
1818
self.writeTokensToFile(self.getTokens(), "test-file.ps1.tokens")
1919

2020
def testGetLowerTokens(self):
21+
def escaped_lower(i, line):
22+
should = not (i > 0 and line[i-1] == '`')
23+
if (should):
24+
return line[i].lower()
25+
else:
26+
return line[i]
27+
2128
with open(self.test_path) as f:
2229
content = f.readlines()
2330
for line in content:
24-
self.append(line.lower())
31+
# escaped chars (like `n) are case-sensitive, don't upper them
32+
line_low = ''.join([escaped_lower(i, line) for i in range(len(line))])
33+
self.append(line_low)
2534
self.writeTokensToFile(self.getTokens(), "test-file.ps1.lower.tokens")
2635

2736
def testGetUpperTokens(self):

0 commit comments

Comments
 (0)