Author: Alex Gaynor <[email protected]>
Branch: kill-someobject
Changeset: r57903:0f19853384ee
Date: 2012-10-08 13:47 +0200
http://bitbucket.org/pypy/pypy/changeset/0f19853384ee/
Log: (alex, fijal) make test_typed start to pass
diff --git a/pypy/translator/c/test/test_genc.py
b/pypy/translator/c/test/test_genc.py
--- a/pypy/translator/c/test/test_genc.py
+++ b/pypy/translator/c/test/test_genc.py
@@ -2,13 +2,15 @@
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,
@@ -58,14 +60,18 @@
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__
diff --git a/pypy/translator/c/test/test_typed.py
b/pypy/translator/c/test/test_typed.py
--- a/pypy/translator/c/test/test_typed.py
+++ b/pypy/translator/c/test/test_typed.py
@@ -54,8 +54,11 @@
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])
@@ -78,9 +81,11 @@
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:
@@ -97,9 +102,9 @@
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])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit