Alex Gaynor avatar Alex Gaynor committed 0f19853 Draft

(alex, fijal) make test_typed start to pass

Comments (0)

Files changed (2)

pypy/translator/c/test/test_genc.py

 
 import py
 
+from pypy.rlib.entrypoint import entrypoint
+from pypy.rlib.unroll import unrolling_iterable
+from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.lltypesystem.lltype import *
-from pypy.translator.translator import TranslationContext, graphof
+from pypy.rpython.lltypesystem.rstr import STR
+from pypy.tool.nullpath import NullPyPathLocal
 from pypy.translator.c import genc
 from pypy.translator.interactive import Translation
-from pypy.rlib.entrypoint import entrypoint
-from pypy.tool.nullpath import NullPyPathLocal
-from pypy.rlib.unroll import unrolling_iterable
+from pypy.translator.translator import TranslationContext, graphof
 
 
 def compile(fn, argtypes, view=False, gcpolicy="none", backendopt=True,
         assert stdout.endswith(' ;\n')
         pos = stdout.rindex('THE RESULT IS: ')
         res = stdout[pos + len('THE RESULT IS: '):-3]
-        if ll_res == Signed:
+        if ll_res == lltype.Signed:
             return int(res)
-        elif ll_res == Char:
+        elif ll_res == lltype.Bool:
+            return bool(int(res))
+        elif ll_res == lltype.Char:
             assert len(res) == 1
             return res
-        elif ll_res == Float:
+        elif ll_res == lltype.Float:
             return float(res)
-        elif ll_res == Void:
+        elif ll_res == lltype.Ptr(STR):
+            return res
+        elif ll_res == lltype.Void:
             return None
         raise NotImplementedError("parsing %s" % (ll_res,))
     f.__name__ = fn.__name__

pypy/translator/c/test/test_typed.py

         assert set_attr() == 2
 
     def test_inheritance2(self):
-        inheritance2 = self.getcompiled(snippet.inheritance2)
-        assert inheritance2() == ((-12, -12.0), (3, 12.3))
+        def wrap():
+            res = snippet.inheritance2()
+            return res == ((-12, -12.0), (3, 12.3))
+        fn = self.getcompiled(wrap)
+        assert fn()
 
     def test_factorial2(self):
         factorial2 = self.getcompiled(snippet.factorial2, [int])
         assert nested_whiles(5, 3) == '!!!!!'
 
     def test_call_unpack_56(self):
-        call_unpack_56 = self.getcompiled(snippet.call_unpack_56, [])
-        result = call_unpack_56()
-        assert result == (2, 5, 6)
+        def wrap():
+            res = snippet.call_unpack_56()
+            return res == (2, 5, 6)
+        fn = self.getcompiled(wrap)
+        assert fn()
 
     def test_class_defaultattr(self):
         class K:
             z = x, y
             while x:
                 x = x - 1
-            return z
+            return z == (6, 'a')
         fn = self.getcompiled(tuple_repr, [int, str])
-        assert fn(6, 'a') == (6, 'a')
+        assert fn()
 
     def test_classattribute(self):
         fn = self.getcompiled(snippet.classattribute, [int])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.