Commits

Armin Rigo committed 03fee08

Fix test_lltyped.

  • Participants
  • Parent commits 9fb4be9
  • Branches kill-someobject

Comments (0)

Files changed (4)

File pypy/rpython/tool/rffi_platform.py

         allfields = tuple(['c_' + name for name, _ in fields])
         padfields = tuple(padfields)
         name = self.name
-        padding_drop = PaddingDrop(name, allfields, padfields,
-                                   config_result.CConfig._compilation_info_)
+        eci = config_result.CConfig._compilation_info_
+        padding_drop = PaddingDrop(name, allfields, padfields, eci)
         hints = {'align': info['align'],
                  'size': info['size'],
                  'fieldoffsets': tuple(fieldoffsets),
                  'padding': padfields,
-                 'get_padding_drop': padding_drop}
+                 'get_padding_drop': padding_drop,
+                 'eci': eci}
         if name.startswith('struct '):
             name = name[7:]
         else:

File pypy/translator/c/genc.py

             eci = node.compilation_info()
             if eci:
                 all.append(eci)
+        for node in self.db.getstructdeflist():
+            try:
+                all.append(node.STRUCT._hints['eci'])
+            except (AttributeError, KeyError):
+                pass
         self.merge_eci(*all)
 
     def get_gcpolicyclass(self):

File pypy/translator/c/test/test_genc.py

             else:
                 args += (a,)
         res = fn(*args)
+        if isinstance(res, float):
+            from pypy.rlib.rfloat import formatd, DTSF_ADD_DOT_0
+            res = formatd(res, 'r', 0, DTSF_ADD_DOT_0)
         print "THE RESULT IS:", res, ";"
         return 0
 

File pypy/translator/c/test/test_lltyped.py

 import py
 from pypy.rpython.lltypesystem.lltype import *
-from pypy.translator.c.test import test_typed
+from pypy.translator.c.test.test_genc import compile
 from pypy.tool.sourcetools import func_with_new_name
 
 
-class TestLowLevelType(test_typed.CompilationTestCase):
+class TestLowLevelType(object):
+    def getcompiled(self, func, argtypes):
+        return compile(func, argtypes, backendopt=False)
 
     def test_simple(self):
         S = GcStruct("s", ('v', Signed))
         def llf():
             s = malloc(S)
             return s.v
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         assert fn() == 0
 
     def test_simple2(self):
             s.a.v = 6
             s.b.v = 12
             return s.a.v + s.b.v
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         assert fn() == 18
 
     def test_fixedsizearray(self):
             assert a42[0][0] == -5
             assert a42[5][6] == -6
             return len(a42)*100 + len(a42[4])
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         res = fn()
         assert fn() == 607
 
             tree.root[0].a = tree.root
             tree.root[1].a = tree.other
             assert tree.root[0].a[0].a[0].a[0].a[0].a[1].a == tree.other
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         fn()
 
     def test_prebuilt_array(self):
             for i in range(5):
                 s += chr(64+a[i])
             assert s == "HELLO"
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         fn()
 
     def test_call_with_fixedsizearray(self):
             s = malloc(S)
             s.a = a
             return g(s.a)
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         res = fn()
         assert res == 123
 
             s.y   +=    1
             return p1[0] + p2[0] + p3[0] + p4[0]
 
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         res = fn()
         assert res == 8765
 
                     x = getmax(cls)
                     res1 = OP(x, nn)
                     result = result + (res1,)
-            return result
-
-        def assert_eq(a, b):
-            # for better error messages when it fails
-            assert len(a) == len(b)
-            for i in range(len(a)):
-                assert a[i] == b[i]
+            return str(result)
 
         fn = self.getcompiled(f, [int])
         res = fn(1)
         print res
-        assert_eq(res, (
+        assert eval(res) == (
             # int
             -sys.maxint, undefined,               # add
             undefined, sys.maxint-1,              # sub
             0, 0,                                 # mod
             0, maxlonglong*2,                     # lshift
             0, maxlonglong,                       # rshift
-            ))
+            )
 
         res = fn(5)
         print res
-        assert_eq(res, (
+        assert eval(res) == (
             # int
             -sys.maxint+4, undefined,             # add
             undefined, sys.maxint-5,              # sub
             0, (maxlonglong*2+1)%5,               # mod
             0, maxlonglong*2-30,                  # lshift
             0, maxlonglong>>4,                    # rshift
-            ))
+            )
 
     def test_direct_ptradd_barebone(self):
         from pypy.rpython.lltypesystem import rffi
                 assert a2[i] == a[i + 2]
             free(a, flavor='raw')
 
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         fn()
 
     def test_r_singlefloat(self):
         a[2][5] = 888000
         def llf():
             return b[3][4] + a[2][5]
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         assert fn() == 888999
 
     def test_prebuilt_nolength_array(self):
             for i in range(5):
                 s += chr(64+a[i])
             assert s == "HELLO"
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         fn()
 
     def test_prebuilt_nolength_char_array(self):
                     s += a[i]
                 print s
                 assert s == "85?!" + lastchar
-            fn = self.getcompiled(llf)
+            fn = self.getcompiled(llf, [])
             fn()
 
     def test_prebuilt_raw_arrays(self):
                     return i    # returns the index of the failing function
                 i += 1
             return -42
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         res = fn()
         assert res == -42, "failing function: %r" % (records[res],)
 
                 s += a[i]
             return 'abcd' == s
 
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         assert fn()
 
     def test_ll2ctypes_array_from_c(self):
                 s += a[i]
             print s
             return s == 'abcd'
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         assert fn()
 
     def test_cast_to_void_array(self):
         def llf():
             TYPE = Ptr(rffi.CArray(Void))
             y = rffi.cast(TYPE, 0)
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         fn()
 
     def test_llgroup(self):
         from pypy.rpython.lltypesystem.test import test_llgroup
         f = test_llgroup.build_test()
-        fn = self.getcompiled(f)
+        fn = self.getcompiled(f, [])
         res = fn()
         assert res == 42
 
                                            ("l3", Signed)])
         S = rffi_platform.configure(CConfig)['STRUCT']
         assert 'get_padding_drop' in S._hints
+        assert 'eci' in S._hints
         s1 = malloc(S, immortal=True)
         s1.c_c1 = rffi.cast(S.c_c1, -12)
         s1.c_s1 = rffi.cast(S.c_s1, -7843)
                 s = s2
             return s.c_l3
         #
-        self.include_also_eci = eci
         fn = self.getcompiled(f, [int])
         res = fn(10)
         assert res == -98765432
             render_immortal(a2)
             a2[0] = 3
             return a1[0] + a2[0]
-        fn = self.getcompiled(llf)
+        fn = self.getcompiled(llf, [])
         assert fn() == 45
 
     def test_rstring_to_float(self):