##// END OF EJS Templates
Add test that macros are affected by AST transformations
Thomas Kluyver -
Show More
@@ -469,6 +469,16 b' class TestAstTransform(unittest.TestCase):'
469 with tt.AssertPrints("CPU times"):
469 with tt.AssertPrints("CPU times"):
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
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")
472
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()"""
General Comments 0
You need to be logged in to leave comments. Login now