##// END OF EJS Templates
#7548: Fixed handling of != operator. Added tests.
Lev Abalkin -
Show More
@@ -57,7 +57,7 b' ipython_tokens = ['
57 using(BashLexer), Text)),
57 using(BashLexer), Text)),
58 (r'(%)(\w+)(.*\n)', bygroups(Operator, Keyword, Text)),
58 (r'(%)(\w+)(.*\n)', bygroups(Operator, Keyword, Text)),
59 (r'^(!!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)),
59 (r'^(!!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)),
60 (r'((?!=)!)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)),
60 (r'(!)(?!=)(.+)(\n)', bygroups(Operator, using(BashLexer), Text)),
61 (r'^(\s*)(\?\??)(\s*%{0,2}[\w\.\*]*)', bygroups(Text, Operator, Text)),
61 (r'^(\s*)(\?\??)(\s*%{0,2}[\w\.\*]*)', bygroups(Text, Operator, Text)),
62 ]
62 ]
63
63
@@ -109,3 +109,23 b' class TestLexers(TestsBase):'
109 (Token.Text, '\n'),
109 (Token.Text, '\n'),
110 ]
110 ]
111 self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2)))
111 self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2)))
112
113 fragment_2 = 'x != y\n'
114 tokens_2 = [
115 (Token.Name, 'x'),
116 (Token.Text, ' '),
117 (Token.Operator, '!='),
118 (Token.Text, ' '),
119 (Token.Name, 'y'),
120 (Token.Text, '\n'),
121 ]
122 self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2)))
123
124 fragment_2 = ' ?math.sin\n'
125 tokens_2 = [
126 (Token.Text, ' '),
127 (Token.Operator, '?'),
128 (Token.Text, 'math.sin'),
129 (Token.Text, '\n'),
130 ]
131 self.assertEqual(tokens_2, list(self.lexer.get_tokens(fragment_2)))
General Comments 0
You need to be logged in to leave comments. Login now