[pypy-svn] r13901 - in pypy/dist/pypy/translator/c: . test

mwh at codespeak.net mwh at codespeak.net
Sat Jun 25 20:24:03 CEST 2005


Author: mwh
Date: Sat Jun 25 20:24:02 2005
New Revision: 13901

Modified:
   pypy/dist/pypy/translator/c/node.py
   pypy/dist/pypy/translator/c/test/test_typed.py
Log:
tests that i tried and failed to check in a few minutes ago.

test math.exp (which used gencapi with includes=something which was
fairly broken)

unbreak this.


Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Sat Jun 25 20:24:02 2005
@@ -400,15 +400,19 @@
         if self.funcgen:
             argnames = self.funcgen.argnames()
             self.implementationtypename = db.gettype(T, argnames=argnames)
-        self.name = db.namespace.uniquename('g_' + self.basename())
-        self.ptrname = self.name
         if hasattr(obj, 'includes'):
             self.includes = obj.includes
+            self.name = self.basename()
+        else:
+            self.name = db.namespace.uniquename('g_' + self.basename())
+        self.ptrname = self.name
 
     def basename(self):
         return self.obj._name
 
     def enum_dependencies(self):
+        if self.funcgen is None:
+            return []
         return self.funcgen.allconstantvalues()
 
     def forward_declaration(self):

Modified: pypy/dist/pypy/translator/c/test/test_typed.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_typed.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_typed.py	Sat Jun 25 20:24:02 2005
@@ -253,3 +253,31 @@
 
         fn = self.getcompiled(func)
         assert fn(5.0, 6.0) == func(5.0, 6.0) 
+
+    def test_rpbc_bound_method_static_call(self):
+        class R:
+            def meth(self):
+                return 0
+        r = R()
+        m = r.meth
+        def fn():
+            return m()
+        res = self.getcompiled(fn)()
+        assert res == 0
+
+    def test_constant_return_disagreement(self):
+        class R:
+            def meth(self):
+                return 0
+        r = R()
+        def fn():
+            return r.meth()
+        res = self.getcompiled(fn)()
+        assert res == 0
+
+    def test_math_exp(self):
+        from math import exp
+        def fn(f=float):
+            return exp(f)
+        f = self.getcompiled(fn)
+        assert f(1.0) == exp(1.0)



More information about the Pypy-commit mailing list