• Home
  • Raw
  • Download

Lines Matching refs:self

16     def __init__(self, *args, **kwargs):  argument
17 super(MockedParser, self).__init__(*args, **kwargs)
18 self.mocked_env = []
20 def _push_context(self, lexer, env): argument
21 super(MockedParser, self)._push_context(lexer, env)
22 self.mocked_env.append(env)
26 def test_empty(self): argument
28 self.assertFalse(s)
29 self.assertEqual('', ninja.eval_string(s, ninja.EvalEnv()))
31 def test_append_raw(self): argument
33 self.assertTrue(s)
34 self.assertEqual('a', ninja.eval_string(s, ninja.EvalEnv()))
36 def test_append_raw_concat(self): argument
42 self.assertTrue(s)
43 self.assertEqual('ab', ninja.eval_string(s, ninja.EvalEnv()))
45 def test_append_var(self): argument
47 self.assertTrue(s)
49 def test_var_eval(self): argument
54 self.assertEqual('value', ninja.eval_string(s, env))
56 def test_var_concat_eval(self): argument
66 self.assertEqual('ab', ninja.eval_string(s, env))
68 def test_var_repeat_eval(self): argument
81 self.assertEqual('aabab', ninja.eval_string(s, env))
83 def test_var_recursive_eval(self): argument
98 self.assertEqual('dddd', ninja.eval_string(s, env))
100 def test_unknown_variable_eval_error(self): argument
102 self.assertEqual('', ninja.eval_string(s, ninja.EvalEnv()))
104 def test_circular_eval_eval_error(self): argument
110 with self.assertRaises(ninja.EvalCircularError):
113 def test_raw_and_var_eval(self): argument
123 self.assertEqual('adc', ninja.eval_string(s, env))
127 def test_repr(self): argument
129 self.assertEqual('ParseError: build.ninja:5:1', repr(ex))
132 self.assertEqual('ParseError: build.ninja:5:1: invalid char', repr(ex))
136 def test_peek_skip_comment(self): argument
139 self.assertEqual(ninja.TK.EOF, tok.kind)
141 def test_peek_skip_comment_line(self): argument
144 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
148 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
152 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
156 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
158 def test_peek_skip_empty_line(self): argument
161 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
165 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
169 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
171 def test_peek_newline(self): argument
174 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
176 def test_peek_space(self): argument
180 self.assertEqual(ninja.TK.SPACE, tok.kind)
182 self.assertEqual(ninja.TK.SPACE, tok.kind) # Not changed
185 self.assertEqual(ninja.TK.SPACE, tok.kind) # Not changed
187 self.assertEqual(ninja.TK.IDENT, tok.kind)
189 def test_lex_space(self): argument
192 self.assertEqual(ninja.TK.SPACE, tok.kind)
196 self.assertEqual(ninja.TK.SPACE, tok.kind)
200 self.assertEqual(ninja.TK.SPACE, tok.kind)
204 self.assertEqual(ninja.TK.SPACE, tok.kind)
208 self.assertEqual(ninja.TK.SPACE, tok.kind)
210 self.assertEqual(ninja.TK.IDENT, tok.kind)
212 def test_lex_skip_space(self): argument
216 self.assertEqual(ninja.TK.IDENT, tok.kind)
217 self.assertEqual(1, tok.line)
218 self.assertEqual(1, tok.column)
221 self.assertEqual(ninja.TK.IDENT, tok.kind)
222 self.assertEqual(1, tok.line)
223 self.assertEqual(3, tok.column)
225 def test_lex_skip_space_newline_escape(self): argument
228 self.assertEqual(ninja.TK.IDENT, tok.kind)
229 self.assertEqual(1, tok.line)
230 self.assertEqual(1, tok.column)
232 self.assertEqual(ninja.TK.IDENT, tok.kind)
233 self.assertEqual(2, tok.line)
234 self.assertEqual(3, tok.column)
238 self.assertEqual(ninja.TK.IDENT, tok.kind)
239 self.assertEqual(1, tok.line)
240 self.assertEqual(1, tok.column)
242 self.assertEqual(ninja.TK.IDENT, tok.kind)
243 self.assertEqual(2, tok.line)
244 self.assertEqual(1, tok.column)
248 self.assertEqual(ninja.TK.IDENT, tok.kind)
249 self.assertEqual(1, tok.line)
250 self.assertEqual(1, tok.column)
252 self.assertEqual(ninja.TK.IDENT, tok.kind)
253 self.assertEqual(1, tok.line)
254 self.assertEqual(7, tok.column)
256 self.assertEqual(ninja.TK.COLON, tok.kind)
257 self.assertEqual(1, tok.line)
258 self.assertEqual(8, tok.column)
260 self.assertEqual(ninja.TK.IDENT, tok.kind)
261 self.assertEqual(2, tok.line)
262 self.assertEqual(1, tok.column)
267 self.assertEqual(ninja.TK.IDENT, tok.kind)
268 self.assertEqual(1, tok.line)
269 self.assertEqual(1, tok.column)
271 self.assertEqual(ninja.TK.IDENT, tok.kind)
272 self.assertEqual(4, tok.line)
273 self.assertEqual(1, tok.column)
275 def test_peek_space_after_newline(self): argument
279 self.assertEqual(ninja.TK.IDENT, tok.kind)
280 self.assertEqual(1, tok.line)
281 self.assertEqual(1, tok.column)
284 self.assertEqual(ninja.TK.IDENT, tok.kind)
285 self.assertEqual(1, tok.line)
286 self.assertEqual(3, tok.column)
289 self.assertEqual(ninja.TK.NEWLINE, tok.kind)
290 self.assertEqual(1, tok.line)
291 self.assertEqual(4, tok.column)
295 self.assertEqual(ninja.TK.SPACE, tok.kind)
296 self.assertEqual(2, tok.line)
297 self.assertEqual(1, tok.column)
300 self.assertEqual(ninja.TK.IDENT, tok.kind)
301 self.assertEqual(2, tok.line)
302 self.assertEqual(2, tok.column)
304 def test_lex_ident(self): argument
307 self.assertEqual(ninja.TK.IDENT, tok.kind)
311 self.assertEqual(ninja.TK.IDENT, tok.kind)
315 self.assertEqual(ninja.TK.IDENT, tok.kind)
319 self.assertEqual(ninja.TK.IDENT, tok.kind)
323 self.assertEqual(ninja.TK.IDENT, tok.kind)
327 self.assertEqual(ninja.TK.IDENT, tok.kind)
329 def test_lex_assign(self): argument
332 self.assertEqual(ninja.TK.ASSIGN, tok.kind)
334 def test_lex_colon(self): argument
337 self.assertEqual(ninja.TK.COLON, tok.kind)
339 def test_lex_pipe(self): argument
342 self.assertEqual(ninja.TK.PIPE, tok.kind)
344 def test_lex_pipe2(self): argument
347 self.assertEqual(ninja.TK.PIPE2, tok.kind)
349 def test_lex_non_trivial(self): argument
351 with self.assertRaises(ninja.ParseError):
354 with self.assertRaises(ninja.ParseError):
357 def test_lex_match(self): argument
359 with self.assertRaises(ninja.ParseError):
362 def test_lex_path_char(self): argument
366 self.assertEqual(ninja.TK.PATH, tok.kind)
367 self.assertEqual(1, tok.line)
368 self.assertEqual(1, tok.column)
369 self.assertEqual(('t', 'path1'), tok.value)
372 self.assertEqual(ninja.TK.PATH, tok.kind)
373 self.assertEqual(1, tok.line)
374 self.assertEqual(7, tok.column)
375 self.assertEqual(('t', 'path2'), tok.value)
377 def test_lex_str_char(self): argument
380 self.assertEqual(ninja.TK.STRING, tok.kind)
381 self.assertEqual(1, tok.line)
382 self.assertEqual(1, tok.column)
383 self.assertEqual(('t', 'string with spaces'), tok.value)
385 def test_lex_path_escape_char(self): argument
389 self.assertEqual(ninja.TK.PATH, tok.kind)
390 self.assertEqual(1, tok.line)
391 self.assertEqual(1, tok.column)
392 self.assertEqual(('t', char), tok.value)
394 def test_lex_str_escape_char(self): argument
398 self.assertEqual(ninja.TK.STRING, tok.kind)
399 self.assertEqual(1, tok.line)
400 self.assertEqual(1, tok.column)
401 self.assertEqual(('t', char), tok.value)
403 def test_lex_path_escape_char_bad(self): argument
405 with self.assertRaises(ninja.ParseError):
409 with self.assertRaises(ninja.ParseError):
412 def test_lex_str_escape_char_bad(self): argument
414 with self.assertRaises(ninja.ParseError):
418 with self.assertRaises(ninja.ParseError):
421 def test_lex_path_end_char(self): argument
425 self.assertEqual(ninja.TK.PATH, tok.kind)
426 self.assertEqual(1, tok.line)
427 self.assertEqual(1, tok.column)
428 self.assertEqual(('t', 'path'), tok.value)
430 def test_lex_path_var(self): argument
433 self.assertIs(type(tok.value), ninja.EvalString)
434 self.assertEqual(('v', 'a',), tok.value)
438 self.assertIs(type(tok.value), ninja.EvalString)
439 self.assertEqual(('v', 'a',), tok.value)
443 self.assertIs(type(tok.value), ninja.EvalString)
444 self.assertEqual(('tv' ,'path/', 'a'), tok.value)
446 def test_lex_str_var(self): argument
449 self.assertIs(type(tok.value), ninja.EvalString)
450 self.assertEqual(('v', 'a'), tok.value)
454 self.assertIs(type(tok.value), ninja.EvalString)
455 self.assertEqual(('v', 'a'), tok.value)
459 self.assertIs(type(tok.value), ninja.EvalString)
460 self.assertEqual(('tv', 'path/', 'a'), tok.value)
464 self.assertIs(type(tok.value), ninja.EvalString)
465 self.assertEqual(('tvt', 'path/', 'a', ' with space'), tok.value)
469 def test_init_base_dir(self): argument
471 self.assertEqual(os.getcwd(), parser._base_dir)
473 self.assertEqual('/path/to/a/dir', parser._base_dir)
475 def test_global_binding_stmt(self): argument
482 self.assertEqual('1', env['a'])
483 self.assertEqual('2', env['b'])
484 self.assertEqual('3', env['c'])
485 self.assertEqual('1 2 3', env['d'])
486 self.assertEqual('mixed 1 and 2', env['e'])
488 def test_rule_stmt(self): argument
494 self.assertEqual(2, len(manifest.rules))
497 self.assertEqual('cc', rule_cc.name)
498 self.assertEqual(1, len(rule_cc.bindings))
506 self.assertEqual(sb.getvalue(), rule_cc.bindings['command'])
509 self.assertEqual('ld', rule_ld.name)
510 self.assertEqual(1, len(rule_ld.bindings))
518 self.assertEqual(sb.getvalue(), rule_ld.bindings['command'])
520 def test_build_stmt(self): argument
526 self.assertEqual(1, len(manifest.builds))
529 self.assertEqual('explicit_out1', build.explicit_outs[0])
530 self.assertEqual('explicit_out2', build.explicit_outs[1])
531 self.assertEqual('implicit_out1', build.implicit_outs[0])
532 self.assertEqual('implicit_out2', build.implicit_outs[1])
533 self.assertEqual('phony', build.rule)
534 self.assertEqual('explicit_in1', build.explicit_ins[0])
535 self.assertEqual('explicit_in2', build.explicit_ins[1])
536 self.assertEqual('implicit_in1', build.implicit_ins[0])
537 self.assertEqual('implicit_in2', build.implicit_ins[1])
538 self.assertEqual('order_only1', build.prerequisites[0])
539 self.assertEqual('order_only2', build.prerequisites[1])
541 self.assertEqual(('t', '1',), build.bindings['a'])
542 self.assertEqual(('t', '2',), build.bindings['b'])
544 def test_default_stmt(self): argument
550 self.assertEqual(1, len(manifest.defaults))
553 self.assertEqual('foo.o', default.outs[0])
554 self.assertEqual('bar.o', default.outs[1])
556 def test_pool_stmt(self): argument
562 self.assertEqual(1, len(manifest.pools))
565 self.assertEqual('example', pool.name)
566 self.assertEqual(('t', '5',), pool.bindings['depth'])
568 def test_subninja_stmt(self): argument
575 self.assertEqual('original', env['a'])
576 self.assertEqual(2, len(manifest.builds))
579 self.assertEqual('changed', env['a'])
581 def test_include_stmt(self): argument
588 self.assertEqual('changed', env['a'])
589 self.assertEqual(2, len(manifest.builds))
593 def test_unexpected_trivial_token(self): argument
595 with self.assertRaises(ninja.ParseError) as ctx:
598 self.assertEqual(input_path, ctx.exception.path)
599 self.assertEqual(1, ctx.exception.line)
600 self.assertEqual(1, ctx.exception.column)
602 def test_unexpected_non_trivial_token(self): argument
604 with self.assertRaises(ninja.ParseError) as ctx:
607 self.assertEqual(input_path, ctx.exception.path)
608 self.assertEqual(1, ctx.exception.line)
609 self.assertEqual(1, ctx.exception.column)
611 def test_bad_after_good(self): argument
613 with self.assertRaises(ninja.ParseError) as ctx:
616 self.assertEqual(input_path, ctx.exception.path)
617 self.assertEqual(4, ctx.exception.line)
618 self.assertEqual(1, ctx.exception.column)
620 def test_bad_path(self): argument
622 with self.assertRaises(ninja.ParseError) as ctx:
625 self.assertEqual(input_path, ctx.exception.path)
626 self.assertEqual(1, ctx.exception.line)
627 self.assertEqual(9, ctx.exception.column)