[pypy-svn] r70555 - pypy/branch/separate-compilation/pypy/translator/c/test

afa at codespeak.net afa at codespeak.net
Wed Jan 13 13:17:29 CET 2010


Author: afa
Date: Wed Jan 13 13:17:28 2010
New Revision: 70555

Modified:
   pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py
Log:
Add a test, which works.
Next: directly call the constructor


Modified: pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py
==============================================================================
--- pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py	(original)
+++ pypy/branch/separate-compilation/pypy/translator/c/test/test_separate.py	Wed Jan 13 13:17:28 2010
@@ -121,3 +121,38 @@
         assert fn() == 73.5
         c_fn = self.compile_function(fn, [])
         assert c_fn() == 73.5
+
+    def test_create_structure(self):
+        class S:
+            @export(float)
+            def __init__(self, x):
+                self.x = x
+
+        # functions exported from the 'first' module
+        @export(float)
+        def newS(x):
+            return S(x)
+
+        @export(S)
+        def f(s):
+            return s.x + 1.5
+        firstmodule = self.compile_separated("first", newS=newS, f=f)
+
+        # call them from a function compiled in another module
+        @export()
+        def g():
+            s = firstmodule.newS(41.0)
+            return firstmodule.f(s)
+        secondmodule = self.compile_separated("second", g=g)
+
+        def fn():
+            return secondmodule.g()
+
+        if sys.platform == 'win32':
+            filepath = os.path.dirname(firstmodule.__file__)
+            os.environ['PATH'] = "%s;%s" % (filepath, os.environ['PATH'])
+
+        assert fn() == 42.5
+        c_fn = self.compile_function(fn, [])
+        assert c_fn() == 42.5
+



More information about the Pypy-commit mailing list