[pypy-svn] r64610 - pypy/branch/pyjitpl5/pypy/jit/backend/test

arigo at codespeak.net arigo at codespeak.net
Thu Apr 23 22:13:33 CEST 2009


Author: arigo
Date: Thu Apr 23 22:13:32 2009
New Revision: 64610

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
Log:
Fix the output format to be directly copy-pastable as a test.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	Thu Apr 23 22:13:32 2009
@@ -23,25 +23,30 @@
         names = {None: 'None'}
         for v in self.vars:
             names[v] = 'v%d' % len(names)
-            print '        %s = BoxInt()' % (names[v],)
+            print '    %s = BoxInt()' % (names[v],)
         for op in self.loop.operations:
             v = op.result
             if v not in names:
                 names[v] = 'tmp%d' % len(names)
-                print '        %s = BoxInt()' % (names[v],)
-        print '        inputargs = [%s]' % (
+                print '    %s = BoxInt()' % (names[v],)
+        print "    loop = TreeLoop('test')"
+        print '    loop.inputargs = [%s]' % (
             ', '.join([names[v] for v in self.loop.inputargs]))
-        print '        inputvalues = [%s]' % (
-            ', '.join(str(v.value) for v in self.loop.inputargs))
         from pypy.jit.metainterp.resoperation import opname
-        print '        operations = ['
+        print '    loop.operations = ['
         for op in self.loop.operations:
-            print '            ResOperation(rop.%s, [%s], %s),' % (
+            print '        ResOperation(rop.%s, [%s], %s),' % (
                 opname[op.opnum],
                 ', '.join([names.get(v, 'ConstInt(%d)' % v.value)
                            for v in op.args]),
                 names[op.result])
         print '            ]'
+        print '    cpu = CPU(None, None)'
+        print '    cpu.compile_operations(loop)'
+        print '    cpu.execute_operations(loop, [%s])' % (
+            ', '.join(['BoxInt(%d)' % v.value for v in self.loop.inputargs]))
+        for v in self.loop.operations[-1].args:
+            print '    assert %s.value == %d' % (names[v], v.value)
         self.names = names
 
 class AbstractOperation:
@@ -207,7 +212,7 @@
                                                          builder.names[v])
             )
 
-    print '        # passed.'
+    print '    # passed.'
     print
 
 



More information about the Pypy-commit mailing list