@@ -35,3 +35,147 @@ describe "Python grammar", ->
3535 expect (tokens[1 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.python' , ' punctuation.definition.string.end.python' ]
3636
3737 expect (tokens[1 ][2 ]).not .toBeDefined ()
38+
39+ it " terminates a single-quoted raw string containing opening parenthesis at closing quote" , ->
40+ tokens = grammar .tokenizeLines (" r'(' #foo" )
41+
42+ expect (tokens[0 ][0 ].value ).toBe ' r'
43+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' storage.type.string.python' ]
44+ expect (tokens[0 ][1 ].value ).toBe " '"
45+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' punctuation.definition.string.begin.python' ]
46+ expect (tokens[0 ][2 ].value ).toBe ' ('
47+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' meta.group.regexp' , ' punctuation.definition.group.regexp' ]
48+ expect (tokens[0 ][3 ].value ).toBe " '"
49+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' punctuation.definition.string.end.python' ]
50+ expect (tokens[0 ][4 ].value ).toBe ' '
51+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
52+ expect (tokens[0 ][5 ].value ).toBe ' #'
53+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
54+ expect (tokens[0 ][6 ].value ).toBe ' foo'
55+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
56+
57+ it " terminates a single-quoted raw string containing opening bracket at closing quote" , ->
58+ tokens = grammar .tokenizeLines (" r'[' #foo" )
59+
60+ expect (tokens[0 ][0 ].value ).toBe ' r'
61+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' storage.type.string.python' ]
62+ expect (tokens[0 ][1 ].value ).toBe " '"
63+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' punctuation.definition.string.begin.python' ]
64+ expect (tokens[0 ][2 ].value ).toBe ' ['
65+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' constant.other.character-class.set.regexp' , ' punctuation.definition.character-class.regexp' ]
66+ expect (tokens[0 ][3 ].value ).toBe " '"
67+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.raw-regex.python' , ' punctuation.definition.string.end.python' ]
68+ expect (tokens[0 ][4 ].value ).toBe ' '
69+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
70+ expect (tokens[0 ][5 ].value ).toBe ' #'
71+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
72+ expect (tokens[0 ][6 ].value ).toBe ' foo'
73+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
74+
75+ it " terminates a double-quoted raw string containing opening parenthesis at closing quote" , ->
76+ tokens = grammar .tokenizeLines (' r"(" #foo' )
77+
78+ expect (tokens[0 ][0 ].value ).toBe ' r'
79+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' storage.type.string.python' ]
80+ expect (tokens[0 ][1 ].value ).toBe ' "'
81+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' punctuation.definition.string.begin.python' ]
82+ expect (tokens[0 ][2 ].value ).toBe ' ('
83+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' meta.group.regexp' , ' punctuation.definition.group.regexp' ]
84+ expect (tokens[0 ][3 ].value ).toBe ' "'
85+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' punctuation.definition.string.end.python' ]
86+ expect (tokens[0 ][4 ].value ).toBe ' '
87+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
88+ expect (tokens[0 ][5 ].value ).toBe ' #'
89+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
90+ expect (tokens[0 ][6 ].value ).toBe ' foo'
91+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
92+
93+ it " terminates a double-quoted raw string containing opening bracket at closing quote" , ->
94+ tokens = grammar .tokenizeLines (' r"[" #foo' )
95+
96+ expect (tokens[0 ][0 ].value ).toBe ' r'
97+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' storage.type.string.python' ]
98+ expect (tokens[0 ][1 ].value ).toBe ' "'
99+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' punctuation.definition.string.begin.python' ]
100+ expect (tokens[0 ][2 ].value ).toBe ' ['
101+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' constant.other.character-class.set.regexp' , ' punctuation.definition.character-class.regexp' ]
102+ expect (tokens[0 ][3 ].value ).toBe ' "'
103+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.raw-regex.python' , ' punctuation.definition.string.end.python' ]
104+ expect (tokens[0 ][4 ].value ).toBe ' '
105+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
106+ expect (tokens[0 ][5 ].value ).toBe ' #'
107+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
108+ expect (tokens[0 ][6 ].value ).toBe ' foo'
109+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
110+
111+ it " terminates a unicode single-quoted raw string containing opening parenthesis at closing quote" , ->
112+ tokens = grammar .tokenizeLines (" ur'(' #foo" )
113+
114+ expect (tokens[0 ][0 ].value ).toBe ' ur'
115+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' storage.type.string.python' ]
116+ expect (tokens[0 ][1 ].value ).toBe " '"
117+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.begin.python' ]
118+ expect (tokens[0 ][2 ].value ).toBe ' ('
119+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' meta.group.regexp' , ' punctuation.definition.group.regexp' ]
120+ expect (tokens[0 ][3 ].value ).toBe " '"
121+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.end.python' ]
122+ expect (tokens[0 ][4 ].value ).toBe ' '
123+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
124+ expect (tokens[0 ][5 ].value ).toBe ' #'
125+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
126+ expect (tokens[0 ][6 ].value ).toBe ' foo'
127+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
128+
129+ it " terminates a unicode single-quoted raw string containing opening bracket at closing quote" , ->
130+ tokens = grammar .tokenizeLines (" ur'[' #foo" )
131+
132+ expect (tokens[0 ][0 ].value ).toBe ' ur'
133+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' storage.type.string.python' ]
134+ expect (tokens[0 ][1 ].value ).toBe " '"
135+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.begin.python' ]
136+ expect (tokens[0 ][2 ].value ).toBe ' ['
137+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' constant.other.character-class.set.regexp' , ' punctuation.definition.character-class.regexp' ]
138+ expect (tokens[0 ][3 ].value ).toBe " '"
139+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.single.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.end.python' ]
140+ expect (tokens[0 ][4 ].value ).toBe ' '
141+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
142+ expect (tokens[0 ][5 ].value ).toBe ' #'
143+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
144+ expect (tokens[0 ][6 ].value ).toBe ' foo'
145+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
146+
147+ it " terminates a unicode double-quoted raw string containing opening parenthesis at closing quote" , ->
148+ tokens = grammar .tokenizeLines (' ur"(" #foo' )
149+
150+ expect (tokens[0 ][0 ].value ).toBe ' ur'
151+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' storage.type.string.python' ]
152+ expect (tokens[0 ][1 ].value ).toBe ' "'
153+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.begin.python' ]
154+ expect (tokens[0 ][2 ].value ).toBe ' ('
155+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' meta.group.regexp' , ' punctuation.definition.group.regexp' ]
156+ expect (tokens[0 ][3 ].value ).toBe ' "'
157+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.end.python' ]
158+ expect (tokens[0 ][4 ].value ).toBe ' '
159+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
160+ expect (tokens[0 ][5 ].value ).toBe ' #'
161+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
162+ expect (tokens[0 ][6 ].value ).toBe ' foo'
163+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
164+
165+ it " terminates a unicode double-quoted raw string containing opening bracket at closing quote" , ->
166+ tokens = grammar .tokenizeLines (' ur"[" #foo' )
167+
168+ expect (tokens[0 ][0 ].value ).toBe ' ur'
169+ expect (tokens[0 ][0 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' storage.type.string.python' ]
170+ expect (tokens[0 ][1 ].value ).toBe ' "'
171+ expect (tokens[0 ][1 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.begin.python' ]
172+ expect (tokens[0 ][2 ].value ).toBe ' ['
173+ expect (tokens[0 ][2 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' constant.other.character-class.set.regexp' , ' punctuation.definition.character-class.regexp' ]
174+ expect (tokens[0 ][3 ].value ).toBe ' "'
175+ expect (tokens[0 ][3 ].scopes ).toEqual [' source.python' , ' string.quoted.double.single-line.unicode-raw-regex.python' , ' punctuation.definition.string.end.python' ]
176+ expect (tokens[0 ][4 ].value ).toBe ' '
177+ expect (tokens[0 ][4 ].scopes ).toEqual [' source.python' ]
178+ expect (tokens[0 ][5 ].value ).toBe ' #'
179+ expect (tokens[0 ][5 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' , ' punctuation.definition.comment.python' ]
180+ expect (tokens[0 ][6 ].value ).toBe ' foo'
181+ expect (tokens[0 ][6 ].scopes ).toEqual [' source.python' , ' comment.line.number-sign.python' ]
0 commit comments