[pypy-svn] r18470 - in pypy/dist/pypy/translator: . c/test
dialtone at codespeak.net
dialtone at codespeak.net
Wed Oct 12 15:44:39 CEST 2005
Author: dialtone
Date: Wed Oct 12 15:44:38 2005
New Revision: 18470
Modified:
pypy/dist/pypy/translator/c/test/test_standalone.py
pypy/dist/pypy/translator/transform.py
Log:
(valentino, afa, armin)
activate stack_check and refactor a test to not randomly fail
Modified: pypy/dist/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_standalone.py (original)
+++ pypy/dist/pypy/translator/c/test/test_standalone.py Wed Oct 12 15:44:38 2005
@@ -15,14 +15,14 @@
for s in argv:
os.write(1, " '" + str(s) + "'\n")
return 0
-
+
t = Translator(entry_point)
s_list_of_strings = SomeList(ListDef(None, SomeString()))
t.annotate([s_list_of_strings])
t.specialize()
cbuilder = t.cbuilder(standalone=True)
cbuilder.generate_source()
- cbuilder.compile()
+ cbuilder.compile()
data = cbuilder.cmdexec('hi there')
assert data.startswith('''hello world\nargument count: 2\n 'hi'\n 'there'\n''')
@@ -100,10 +100,22 @@
def test_stack_too_big():
+ def f1():
+ return stack_too_big()
+ def f2():
+ return lst[1]()
+ def f3():
+ return lst[2]()
+ def f4():
+ return lst[3]()
+ def f5():
+ return lst[4]()
+ lst = [None,f1,f2,f3,f4,f5]
+
def f(n):
- if stack_too_big():
+ if lst[5]():
return n
- return f(n+1)
+ return f(n)+1
def fn():
return f(0)
@@ -111,7 +123,7 @@
assert int(data.strip()) > 500
-
+
def wrap_stackless_function(fn, stackcheck=False):
def entry_point(argv):
os.write(1, str(fn())+"\n")
@@ -120,13 +132,11 @@
t = Translator(entry_point)
s_list_of_strings = SomeList(ListDef(None, SomeString()))
ann = t.annotate([s_list_of_strings])
- if stackcheck:
- insert_stackcheck(ann)
t.specialize()
cbuilder = t.cbuilder(standalone=True)
cbuilder.stackless = True
cbuilder.generate_source()
- cbuilder.compile()
+ cbuilder.compile()
return cbuilder.cmdexec('')
def test_stack_unwind():
@@ -137,11 +147,10 @@
data = wrap_stackless_function(f)
assert int(data.strip()) == 42
-
def test_auto_stack_unwind():
def f(n):
if n == 1:
- return 1
+ return 1
return (n+f(n-1)) % 1291
def fn():
Modified: pypy/dist/pypy/translator/transform.py
==============================================================================
--- pypy/dist/pypy/translator/transform.py (original)
+++ pypy/dist/pypy/translator/transform.py Wed Oct 12 15:44:38 2005
@@ -222,6 +222,7 @@
# modified by t.simplify() after it had been annotated.
if block_subset is None:
block_subset = fully_annotated_blocks(ann)
+ insert_stackcheck(ann)
if not isinstance(block_subset, dict):
block_subset = dict.fromkeys(block_subset)
if ann.translator:
More information about the Pypy-commit
mailing list