def test_visit_index(self): fake_span = self.fake_span # Make a t[i] inde xnode. t = ast.NameRef(fake_span, 't', ast.NameDef(fake_span, 't')) i = ast.NameRef(fake_span, 'i', ast.NameDef(fake_span, 'i')) index = ast.Index(fake_span, t, i) c = _Collector() index.accept(c) self.assertEqual(c.collected, [t, i, index])
def test_visit_unop(self): fake_span = self.fake_span i_def = ast.NameDef(fake_span, 'i') i_ref = ast.NameRef(fake_span, 'i', i_def) negated = ast.Unop(Token(TokenKind.MINUS, fake_span), i_ref) c = _Collector() negated.accept(c) self.assertEqual(c.collected, [i_ref, negated])
def _builtin_name_ref(self, identifier: Text) -> ast.NameRef: return ast.NameRef(self.fake_span, identifier, ast.BuiltinNameDef(identifier))
def _make_name_ref(self, name_def: ast.NameDef) -> ast.NameRef: return ast.NameRef(self.fake_span, name_def.identifier, name_def)