[pypy-svn] pypy default: add the possibility to pass parameters

antocuni commits-noreply at bitbucket.org
Tue Feb 22 17:41:33 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42214:c7277f58c1f5
Date: 2011-02-22 17:30 +0100
http://bitbucket.org/pypy/pypy/changeset/c7277f58c1f5/

Log:	add the possibility to pass parameters

diff --git a/pypy/module/pypyjit/test_pypy_c/test_model.py b/pypy/module/pypyjit/test_pypy_c/test_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_model.py
@@ -18,11 +18,12 @@
     def setup_method(self, meth):
         self.filepath = self.tmpdir.join(meth.im_func.func_name + '.py')
 
-    def run(self, func, threshold=1000):
+    def run(self, func, args=[], threshold=1000):
         # write the snippet
+        arglist = ', '.join(map(repr, args))
         with self.filepath.open("w") as f:
             f.write(str(py.code.Source(func)) + "\n")
-            f.write("print %s()\n" % func.func_name)
+            f.write("print %s(%s)\n" % (func.func_name, arglist))
         #
         # run a child pypy-c with logging enabled
         logfile = self.filepath.new(ext='.log')
@@ -77,6 +78,12 @@
 
 class TestRunPyPyC(BaseTestPyPyC):
 
+    def test_run_function(self):
+        def f(a, b):
+            return a+b
+        log = self.run(f, [30, 12])
+        assert log.result == 42
+
     def test_parse_jitlog(self):
         def f():
             i = 0


More information about the Pypy-commit mailing list