Lines Matching refs:self
46 def test_lexer_error(self): argument
50 self.assertEqual(exc.line, 1)
51 self.assertEqual(exc.column, 3)
52 self.assertEqual(exc.message, 'unexpected character')
53 self.assertEqual(str(exc), 'LexerError: 1:3: unexpected character')
56 self.assertEqual(exc.line, 3)
57 self.assertEqual(exc.column, 5)
58 self.assertEqual(exc.message, 'unexpected character')
59 self.assertEqual(str(exc), 'LexerError: 3:5: unexpected character')
62 def test_hierarchy(self): argument
64 with self.assertRaises(ValueError):
71 def test_compute_line_column(self): argument
76 self.assertEqual(line, 1)
77 self.assertEqual(column, 1)
80 self.assertEqual(line, 1)
81 self.assertEqual(column, 2)
84 self.assertEqual(line, 1)
85 self.assertEqual(column, 3)
89 self.assertEqual(line, 2)
90 self.assertEqual(column, 1)
93 self.assertEqual(line, 2)
94 self.assertEqual(column, 2)
97 self.assertEqual(line, 2)
98 self.assertEqual(column, 3)
101 self.assertEqual(line, 2)
102 self.assertEqual(column, 4)
106 self.assertEqual(line, 3)
107 self.assertEqual(column, 1)
110 self.assertEqual(line, 3)
111 self.assertEqual(column, 2)
114 self.assertEqual(line, 3)
115 self.assertEqual(column, 3)
119 self.assertEqual(line, 4)
120 self.assertEqual(column, 1)
130 def test_raw_string_lit(self): argument
134 self.assertEqual(end, 3)
135 self.assertEqual(lit, 'a')
138 self.assertEqual(end, 5)
139 self.assertEqual(lit, 'a\nb')
142 self.assertEqual(end, 6)
143 self.assertEqual(lit, 'b')
145 with self.assertRaises(LexerError) as ctx:
147 self.assertEqual(ctx.exception.line, 1)
148 self.assertEqual(ctx.exception.column, 3)
150 with self.assertRaises(LexerError) as ctx:
152 self.assertEqual(ctx.exception.line, 1)
153 self.assertEqual(ctx.exception.column, 3)
156 def test_interpreted_string_literal(self): argument
161 self.assertEqual(end, 3)
162 self.assertEqual(lit, 'a')
165 self.assertEqual(end, 3)
166 self.assertEqual(lit, 'n')
168 with self.assertRaises(LexerError) as ctx:
170 self.assertEqual(ctx.exception.line, 1)
171 self.assertEqual(ctx.exception.column, 2)
174 def test_literal_escape_char(self): argument
179 self.assertEqual(end, 4)
180 self.assertEqual(lit, '\a')
183 self.assertEqual(end, 4)
184 self.assertEqual(lit, '\b')
187 self.assertEqual(end, 4)
188 self.assertEqual(lit, '\f')
191 self.assertEqual(end, 4)
192 self.assertEqual(lit, '\n')
195 self.assertEqual(end, 4)
196 self.assertEqual(lit, '\r')
199 self.assertEqual(end, 4)
200 self.assertEqual(lit, '\t')
203 self.assertEqual(end, 4)
204 self.assertEqual(lit, '\v')
207 self.assertEqual(end, 4)
208 self.assertEqual(lit, '\\')
211 self.assertEqual(end, 4)
212 self.assertEqual(lit, '\'')
215 self.assertEqual(end, 4)
216 self.assertEqual(lit, '\"')
218 with self.assertRaises(LexerError) as ctx:
220 self.assertEqual(ctx.exception.line, 1)
221 self.assertEqual(ctx.exception.column, 2)
224 def test_literal_escape_octal(self): argument
229 self.assertEqual(end, 6)
230 self.assertEqual(lit, '\0')
233 self.assertEqual(end, 6)
234 self.assertEqual(lit, '\377')
244 with self.assertRaises(LexerError) as ctx:
246 self.assertEqual(ctx.exception.line, 1)
247 self.assertEqual(ctx.exception.column, 2)
250 def test_literal_escape_hex(self): argument
255 self.assertEqual(end, 6)
256 self.assertEqual(lit, '\0')
259 self.assertEqual(end, 6)
260 self.assertEqual(lit, '\xff')
271 with self.assertRaises(LexerError) as ctx:
273 self.assertEqual(ctx.exception.line, 1)
274 self.assertEqual(ctx.exception.column, 2)
277 def test_literal_escape_little_u(self): argument
282 self.assertEqual(end, 8)
283 self.assertEqual(lit, '\0')
286 self.assertEqual(end, 8)
287 self.assertEqual(lit, py3_str(u'\uffff'))
300 with self.assertRaises(LexerError) as ctx:
302 self.assertEqual(ctx.exception.line, 1)
303 self.assertEqual(ctx.exception.column, 2)
306 def test_literal_escape_big_u(self): argument
311 self.assertEqual(end, 12)
312 self.assertEqual(lit, '\0')
315 self.assertEqual(end, 12)
316 self.assertEqual(lit, py3_str(u'\U0001ffff'))
334 with self.assertRaises(LexerError) as ctx:
336 self.assertEqual(ctx.exception.line, 1)
337 self.assertEqual(ctx.exception.column, 2)
347 def test_lex_char(self): argument
351 self.assertEqual(token, Token.LPAREN)
352 self.assertEqual(end, 1)
353 self.assertEqual(lit, None)
356 self.assertEqual(token, Token.RPAREN)
357 self.assertEqual(end, 1)
358 self.assertEqual(lit, None)
361 self.assertEqual(token, Token.LBRACKET)
362 self.assertEqual(end, 1)
363 self.assertEqual(lit, None)
366 self.assertEqual(token, Token.RBRACKET)
367 self.assertEqual(end, 1)
368 self.assertEqual(lit, None)
371 self.assertEqual(token, Token.LBRACE)
372 self.assertEqual(end, 1)
373 self.assertEqual(lit, None)
376 self.assertEqual(token, Token.RBRACE)
377 self.assertEqual(end, 1)
378 self.assertEqual(lit, None)
381 self.assertEqual(token, Token.COLON)
382 self.assertEqual(end, 1)
383 self.assertEqual(lit, None)
386 self.assertEqual(token, Token.ASSIGN)
387 self.assertEqual(end, 1)
388 self.assertEqual(lit, None)
391 self.assertEqual(token, Token.PLUS)
392 self.assertEqual(end, 1)
393 self.assertEqual(lit, None)
396 self.assertEqual(token, Token.COMMA)
397 self.assertEqual(end, 1)
398 self.assertEqual(lit, None)
401 def test_lex_assign_plus(self): argument
405 self.assertEqual(token, Token.ASSIGNPLUS)
406 self.assertEqual(end, 2)
407 self.assertEqual(lit, None)
410 def test_lex_space(self): argument
414 self.assertEqual(token, Token.SPACE)
415 self.assertEqual(end, 1)
416 self.assertEqual(lit, None)
419 self.assertEqual(token, Token.SPACE)
420 self.assertEqual(end, 1)
421 self.assertEqual(lit, None)
424 self.assertEqual(token, Token.SPACE)
425 self.assertEqual(end, 1)
426 self.assertEqual(lit, None)
429 self.assertEqual(token, Token.SPACE)
430 self.assertEqual(end, 1)
431 self.assertEqual(lit, None)
434 self.assertEqual(token, Token.SPACE)
435 self.assertEqual(end, 5)
436 self.assertEqual(lit, None)
439 def test_lex_comment(self): argument
443 self.assertEqual(token, Token.COMMENT)
444 self.assertEqual(end, 7)
445 self.assertEqual(lit, None)
448 self.assertEqual(token, Token.COMMENT)
449 self.assertEqual(end, 7)
450 self.assertEqual(lit, None)
453 self.assertEqual(token, Token.COMMENT)
454 self.assertEqual(end, 7)
455 self.assertEqual(lit, None)
458 self.assertEqual(token, Token.COMMENT)
459 self.assertEqual(end, 9)
460 self.assertEqual(lit, None)
463 self.assertEqual(token, Token.COMMENT)
464 self.assertEqual(end, 8)
465 self.assertEqual(lit, None)
468 self.assertEqual(token, Token.COMMENT)
469 self.assertEqual(end, 9)
470 self.assertEqual(lit, None)
473 self.assertEqual(token, Token.COMMENT)
474 self.assertEqual(end, 4)
475 self.assertEqual(lit, None)
478 self.assertEqual(token, Token.COMMENT)
479 self.assertEqual(end, 5)
480 self.assertEqual(lit, None)
483 self.assertEqual(token, Token.COMMENT)
484 self.assertEqual(end, 6)
485 self.assertEqual(lit, None)
488 self.assertEqual(token, Token.COMMENT)
489 self.assertEqual(end, 6)
490 self.assertEqual(lit, None)
493 self.assertEqual(token, Token.COMMENT)
494 self.assertEqual(end, 7)
495 self.assertEqual(lit, None)
498 self.assertEqual(token, Token.COMMENT)
499 self.assertEqual(end, 7)
500 self.assertEqual(lit, None)
503 def test_lex_string(self): argument
507 self.assertEqual(token, Token.STRING)
508 self.assertEqual(end, 3)
509 self.assertEqual(lit, 'a')
512 self.assertEqual(token, Token.STRING)
513 self.assertEqual(end, 5)
514 self.assertEqual(lit, 'a\nb')
517 def test_lex_ident(self): argument
521 self.assertEqual(token, Token.IDENT)
522 self.assertEqual(end, 5)
523 self.assertEqual(lit, 'ident')
526 def test_lex_offset(self): argument
530 self.assertEqual(token, Token.IDENT)
531 self.assertEqual(end, 1)
532 self.assertEqual(lit, 'a')
535 self.assertEqual(token, Token.SPACE)
536 self.assertEqual(end, 2)
537 self.assertEqual(lit, None)
540 self.assertEqual(token, Token.STRING)
541 self.assertEqual(end, 5)
542 self.assertEqual(lit, 'b')
552 def test_lexer(self): argument
557 self.assertEqual(lexer.start, 0)
558 self.assertEqual(lexer.end, 1)
559 self.assertEqual(lexer.token, Token.IDENT)
560 self.assertEqual(lexer.literal, 'a')
563 self.assertEqual(lexer.start, 2)
564 self.assertEqual(lexer.end, 3)
565 self.assertEqual(lexer.token, Token.IDENT)
566 self.assertEqual(lexer.literal, 'b')
569 self.assertEqual(lexer.start, 9)
570 self.assertEqual(lexer.end, 12)
571 self.assertEqual(lexer.token, Token.STRING)
572 self.assertEqual(lexer.literal, 'c')
575 self.assertEqual(lexer.start, 12)
576 self.assertEqual(lexer.end, 12)
577 self.assertEqual(lexer.token, Token.EOF)
578 self.assertEqual(lexer.literal, None)
581 def test_lexer_offset(self): argument
586 self.assertEqual(lexer.start, 2)
587 self.assertEqual(lexer.end, 3)
588 self.assertEqual(lexer.token, Token.IDENT)
589 self.assertEqual(lexer.literal, 'b')
592 self.assertEqual(lexer.start, 3)
593 self.assertEqual(lexer.end, 3)
594 self.assertEqual(lexer.token, Token.EOF)
595 self.assertEqual(lexer.literal, None)
599 def test_lexer_path(self): argument
602 self.assertEqual(lexer.path, 'test_path')