[pypy-svn] r33932 - pypy/dist/pypy/translator/js/test
fijal at codespeak.net
fijal at codespeak.net
Tue Oct 31 00:03:12 CET 2006
Author: fijal
Date: Tue Oct 31 00:03:09 2006
New Revision: 33932
Modified:
pypy/dist/pypy/translator/js/test/runtest.py
pypy/dist/pypy/translator/js/test/test_class.py
Log:
Patch by James W Ascroft
Modified: pypy/dist/pypy/translator/js/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/runtest.py (original)
+++ pypy/dist/pypy/translator/js/test/runtest.py Tue Oct 31 00:03:09 2006
@@ -3,7 +3,7 @@
Sests with DONT in front of them will probably not be fixed for the time being.
'''
-import py, os, re
+import py, os, re, subprocess
from pypy.translator.translator import TranslationContext
from pypy.translator.backendopt.all import backend_optimizations
from pypy.translator.js.js import JS
@@ -54,6 +54,7 @@
else:
self.root = root
self.run_browser = run_browser
+ self.function_calls = []
def source(self):
return self.js.tmpfile.open().read()
@@ -74,6 +75,7 @@
else:
entry_function = self.js.translator.annotator.bookkeeper.getdesc(entry_function).cached_graph(None)
function_call = "%s(%s)" % (entry_function, args)
+ self.function_calls.append(function_call)
#if self.js.stackless:
# function_call = "slp_entry_point('%s')" % function_call
@@ -89,9 +91,20 @@
output = out[0]
port += 1
else:
- cmd = 'echo "load(\'%s\'); print(%s)" | js 2>&1' % (self.js.filename, function_call)
- log(cmd)
- output = os.popen(cmd).read().strip()
+# cmd = 'echo "load(\'%s\'); print(%s)" | js 2>&1' % (self.js.filename, function_call)
+# log(cmd)
+# output = os.popen(cmd).read().strip()
+ js = subprocess.Popen(["js"],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ input = "load(%r);\n" % self.js.filename.strpath
+ for call in self.function_calls[:-1]:
+ input += "%s;\n" % call
+ input += "print(%s);\n" % self.function_calls[-1]
+ js.stdin.write(input)
+ stdout, stderr = js.communicate()
+ output = (stderr + stdout).strip()
for s in output.split('\n'):
log(s)
Modified: pypy/dist/pypy/translator/js/test/test_class.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_class.py (original)
+++ pypy/dist/pypy/translator/js/test/test_class.py Tue Oct 31 00:03:09 2006
@@ -67,7 +67,7 @@
assert f(True) == 1
assert f(False) == 2
- def DONTtest_global_instance(self): #issue we restart every test with a fresh set of globals
+ def test_global_instance(self): #issue we restart every test with a fresh set of globals
f = compile_function(llvmsnippet.global_instance, [int])
assert f(-1) == llvmsnippet.global_instance(-1)
for i in range(20):
@@ -125,8 +125,8 @@
return b.a[2]
fn = compile_function(init_list, [int])
- assert fn(8) == 1
assert fn(3) == INIT_VAL
+ assert fn(8) == 1
class C(object):
pass
More information about the Pypy-commit
mailing list