| 54 | |
| 55 | class TestEffects(unittest.TestCase): |
| 56 | def test_effect_sizes(self): |
| 57 | stack = Stack() |
| 58 | inputs = [ |
| 59 | x := StackItem("x", "1"), |
| 60 | y := StackItem("y", "oparg"), |
| 61 | z := StackItem("z", "oparg*2"), |
| 62 | ] |
| 63 | outputs = [ |
| 64 | StackItem("x", "1"), |
| 65 | StackItem("b", "oparg*4"), |
| 66 | StackItem("c", "1"), |
| 67 | ] |
| 68 | null = CWriter.null() |
| 69 | stack.pop(z, null) |
| 70 | stack.pop(y, null) |
| 71 | stack.pop(x, null) |
| 72 | for out in outputs: |
| 73 | stack.push(Local.undefined(out)) |
| 74 | self.assertEqual(stack.base_offset.to_c(), "-1 - oparg - oparg*2") |
| 75 | self.assertEqual(stack.physical_sp.to_c(), "0") |
| 76 | self.assertEqual(stack.logical_sp.to_c(), "1 - oparg - oparg*2 + oparg*4") |
| 77 | |
| 78 | |
| 79 | class TestGeneratedCases(unittest.TestCase): |