Beispiel #1
0
 def test_textbook_example(self):
     def fn(z):
         x = 3 + 6
         y = x - 5
         return z * y
     ctx = unemit(fn.__code__, Py27Op)
     self.assertEqual(ctx.ops, [
         Store("x", Const(9)),
         Store("y", Subtract(Load("x"), Const(5))),
         Return(Multiply(Load('z'), Load('y')))])
     # NOTE: this doesn't work yet but the goal is to make it work :)
     ctx = unemit(fn.__code__, Py27Op)
Beispiel #2
0
 def test_unemit_Load_Load_Multiplu_Return(self):
     fn = lambda a, b: a * b
     ctx = unemit(fn.__code__, Py27Op)
     self.assertEqual(ctx.retval, Return(Multiply(Load('a'), Load('b'))))
Beispiel #3
0
 def test_unemit_Load_Load_Add_Return(self):
     fn = lambda a, b: a + b
     ctx = unemit(fn.__code__, Py27Op)
     self.assertEqual(ctx.retval, Return(Add(Load('a'), Load('b'))))
Beispiel #4
0
 def test_unemit_Load_Load_Subtract_Return(self):
     fn = lambda a, b: a - b
     ctx = unemit(fn.__code__, Py27Op)
     self.assertEqual(ctx.retval, Return(Subtract(Load('a'), Load('b'))))
Beispiel #5
0
 def test_unemit_Load_Return(self):
     fn = lambda x: x
     ctx = unemit(fn.__code__, Py27Op)
     self.assertEqual(ctx.retval, Return(Load('x')))