[pypy-svn] r66141 - pypy/branch/pyjitpl5/pypy/jit/tl/test

antocuni at codespeak.net antocuni at codespeak.net
Tue Jul 7 11:14:32 CEST 2009


Author: antocuni
Date: Tue Jul  7 11:14:31 2009
New Revision: 66141

Modified:
   pypy/branch/pyjitpl5/pypy/jit/tl/test/test_tla.py
Log:
more tests


Modified: pypy/branch/pyjitpl5/pypy/jit/tl/test/test_tla.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/test/test_tla.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/test/test_tla.py	Tue Jul  7 11:14:31 2009
@@ -1,5 +1,6 @@
 import py
 from pypy.jit.tl import tla
+from pypy.jit.tl.tla import CONST_INT, POP, ADD, RETURN, JUMP_IF
 
 def test_stack():
     f = tla.Frame('')
@@ -30,8 +31,40 @@
     return tla.run(bytecode, w_arg)
 
 def test_interp():
-    bytecode = [
+    code = [
         tla.RETURN
         ]
-    assert interp(bytecode, tla.W_IntObject(42)).intvalue == 42
+    res = interp(code, tla.W_IntObject(42))
+    assert res.intvalue == 42
 
+def test_pop():
+    code = [
+        tla.CONST_INT, 99,
+        tla.POP,
+        tla.RETURN
+        ]
+    res = interp(code, tla.W_IntObject(42))
+    assert res.intvalue == 42
+
+def test_add():
+    code = [
+        CONST_INT, 20,
+        ADD,
+        RETURN
+        ]
+    res = interp(code, tla.W_IntObject(22))
+    assert res.intvalue == 42
+
+def test_jump_if():
+    code = [
+        JUMP_IF, 5,   # jump to target
+        CONST_INT, 123,
+        RETURN,
+        CONST_INT, 234,  # target
+        RETURN
+        ]
+    res = interp(code, tla.W_IntObject(0))
+    assert res.intvalue == 123
+    
+    res = interp(code, tla.W_IntObject(1))
+    assert res.intvalue == 234



More information about the Pypy-commit mailing list