##// END OF EJS Templates
Add test that macros are affected by AST transformations
Thomas Kluyver -
Show More
@@ -470,6 +470,16 b' class TestAstTransform(unittest.TestCase):'
470 ip.run_line_magic("time", "a = f(-3 + -2)")
470 ip.run_line_magic("time", "a = f(-3 + -2)")
471 self.assertEqual(called, [5])
471 self.assertEqual(called, [5])
472
472
473 def test_macro(self):
474 ip.push({'a':10})
475 # The AST transformation makes this do a+=-1
476 ip.define_macro("amacro", "a+=1\nprint(a)")
477
478 with tt.AssertPrints("9"):
479 ip.run_cell("amacro")
480 with tt.AssertPrints("8"):
481 ip.run_cell("amacro")
482
473 class IntegerWrapper(ast.NodeTransformer):
483 class IntegerWrapper(ast.NodeTransformer):
474 """Wraps all integers in a call to Integer()"""
484 """Wraps all integers in a call to Integer()"""
475 def visit_Num(self, node):
485 def visit_Num(self, node):
General Comments 0
You need to be logged in to leave comments. Login now