Skip to content

Commit e13a38e

Browse files
committed
add harness to produce tokens output
1 parent ce4b90e commit e13a38e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def getScopeNameAtRowCol(self, row, col):
3232
def getFinestScopeNameAtRowCol(self, row, col):
3333
return self.getScopeNameAtRowCol(row, col).split()[-1]
3434

35+
class SyntaxTokenTest(SyntaxTest):
36+
def getTokens(self):
37+
return self.view.find_all(".")
38+
3539

3640
class PowerShellSyntaxTest(SyntaxTest):
3741
def setUp(self):

tests/syntax_def/test_token_gen.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
import sublime
3+
from PowerShell.tests import SyntaxTokenTest
4+
5+
class Test_TokenGenerator(SyntaxTokenTest):
6+
def testGetTokens(self):
7+
8+
self.append("""$foo = @'
9+
hello
10+
'@
11+
""")
12+
tokens = self.getTokens()
13+
14+
outputdir = os.path.join(sublime.packages_path(), 'User', 'UnitTesting', "tokens")
15+
if not os.path.isdir(outputdir):
16+
os.makedirs(outputdir)
17+
outfile = os.path.join(outputdir, "PowerShell_tokens")
18+
19+
if os.path.exists(outfile):
20+
os.remove(outfile)
21+
with open(outfile, 'w') as f:
22+
for r in tokens:
23+
f.write('hi there\n')
24+

0 commit comments

Comments
 (0)