[pypy-svn] r20892 - pypy/dist/pypy/translator/c/test
rxe at codespeak.net
rxe at codespeak.net
Thu Dec 8 13:53:28 CET 2005
Author: rxe
Date: Thu Dec 8 13:53:27 2005
New Revision: 20892
Modified:
pypy/dist/pypy/translator/c/test/test_typed.py
Log:
Try to track some obscure bug with list length and is true - but failed.
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 Thu Dec 8 13:53:27 2005
@@ -397,3 +397,35 @@
assert fn(7, 1) == 5040 # detection must work several times, too
assert fn(7, 1) == 5040
py.test.raises(RuntimeError, fn, -1, 0)
+
+ def test_list_len_is_true(self):
+
+ class X(object):
+ pass
+ class A(object):
+ def __init__(self):
+ self.l = []
+
+ def append_to_list(self, e):
+ self.l.append(e)
+
+ def check_list_is_true(self):
+ did_loop = 0
+ while self.l:
+ did_loop = 1
+ if len(self.l):
+ break
+ return did_loop
+
+ a1 = A()
+ def f():
+ a2 = A()
+ for ii in range(1):
+ a1.append_to_list(X())
+ a2.append_to_list(X())
+ return a1.check_list_is_true() + 2 * a2.check_list_is_true()
+ fn = self.getcompiled(f)
+ assert fn() == 3
+
+
+
More information about the Pypy-commit
mailing list