File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+ import unittest
2+
3+ import sublime
4+
5+
6+ class ViewTest (unittest .TestCase ):
7+ def setUp (self ):
8+ self .view = sublime .active_window ().new_file ()
9+
10+ def append (self , text ):
11+ self .view .run_command ('append' , {'characters' : text })
12+
13+ def tearDown (self ):
14+ self .view .set_scratch (True )
15+ self .view .close ()
16+
17+
18+ class SyntaxTest (ViewTest ):
19+ def _setSyntax (self , rel_path ):
20+ self .view .set_syntax_file (rel_path )
21+
22+ def getScopeNameAt (self , pt ):
23+ return self .view .scope_name (pt )
24+
25+ def getFinestScopeNameAt (self , pt ):
26+ return self .getScopeNameAt (pt ).split ()[- 1 ]
27+
28+ def getScopeNameAtRowCol (self , row , col ):
29+ text_pt = self .view .text_point (row , col )
30+ return self .getScopeNameAt (text_pt )
31+
32+ def getFinestScopeNameAtRowCol (self , row , col ):
33+ return self .getScopeNameAtRowCol (row , col ).split ()[- 1 ]
34+
35+
36+ class PowerShellSyntaxTest (SyntaxTest ):
37+ def setUp (self ):
38+ super ().setUp ()
39+ self ._setSyntax ('Packages/PowerShell/Support/PowershellSyntax.tmLanguage' )
Original file line number Diff line number Diff line change 1+ from PowerShell .tests import PowerShellSyntaxTest
2+
3+
4+ class Test_DoubleQuoted_HereDocStrings (PowerShellSyntaxTest ):
5+ def testIsScopeCorrectIfDelimiterAtBOL (self ):
6+ self .append ("""@"
7+ hello
8+ "@
9+ """ )
10+ sname = self .getFinestScopeNameAtRowCol (1 , 1 )
11+ self .assertEqual (sname , 'string.quoted.double.heredoc.powershell' )
12+
13+ def testIsScopeCorrectIfDelimiterNotAtBOL (self ):
14+ self .append ("""$foo = @"
15+ hello
16+ "@
17+ """ )
18+ sname = self .getFinestScopeNameAtRowCol (1 , 1 )
19+ self .assertEqual (sname , 'string.quoted.double.heredoc.powershell' )
20+
21+
22+ class Test_SingleQuoted_HereDocStrings (PowerShellSyntaxTest ):
23+ def testIsScopeCorrectIfDelimiterAtBOL (self ):
24+ self .append ("""@'
25+ hello
26+ '@
27+ """ )
28+ sname = self .getFinestScopeNameAtRowCol (1 , 1 )
29+ self .assertEqual (sname , 'string.quoted.single.heredoc.powershell' )
30+
31+ def testIsScopeCorrectIfDelimiterNotAtBOL (self ):
32+ self .append ("""$foo = @'
33+ hello
34+ '@
35+ """ )
36+ sname = self .getFinestScopeNameAtRowCol (1 , 1 )
37+ self .assertEqual (sname , 'string.quoted.single.heredoc.powershell' )
You can’t perform that action at this time.
0 commit comments