[pypy-svn] r30637 - pypy/dist/pypy/translator/js/test
fijal at codespeak.net
fijal at codespeak.net
Thu Jul 27 15:59:25 CEST 2006
Author: fijal
Date: Thu Jul 27 15:59:08 2006
New Revision: 30637
Modified:
pypy/dist/pypy/translator/js/test/runtest.py
pypy/dist/pypy/translator/js/test/test_exception.py
pypy/dist/pypy/translator/js/test/test_seq.py
Log:
Added some tests.
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 Thu Jul 27 15:59:08 2006
@@ -58,6 +58,8 @@
def _conv(self, v):
#if isinstance(v, str):
# return "{hash:0, chars:'%s'}" % v
+ if isinstance(v, str):
+ return repr(v)
return str(v).lower()
def __call__(self, *kwds):
Modified: pypy/dist/pypy/translator/js/test/test_exception.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_exception.py (original)
+++ pypy/dist/pypy/translator/js/test/test_exception.py Thu Jul 27 15:59:08 2006
@@ -269,3 +269,16 @@
def restore_magic(saved):
if saved:
py.magic.invoke(assertion=True)
+
+def test_always_raise():
+ def function_raise2(i):
+ if i == 3:
+ raise IndexError()
+ else:
+ pass
+
+ def function_raise1(i):
+ function_raise2(i)
+
+ fn = compile_function(function_raise1, [int])
+ fn()
Modified: pypy/dist/pypy/translator/js/test/test_seq.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_seq.py (original)
+++ pypy/dist/pypy/translator/js/test/test_seq.py Thu Jul 27 15:59:08 2006
@@ -53,6 +53,28 @@
fn = compile_function(dict_iter, [])
assert fn() == dict_iter()
+
+ def test_const_dict(self):
+ c = {'aa':'asd', 'ab':'ds', 'ac':'asddsa', 'ad':'sadsad', 'ae':'sadsa'}
+
+ def const_dict(ind):
+ return c[ind]
+
+ fn = compile_function(const_dict, [str])
+ for i in c.keys():
+ assert fn(i) == const_dict(i)
+
+ def test_sophisticated_const(self):
+ c = {'aa':1, 'bb':2, 'cc':3, 'dd':4}
+ c1 = {'fff' : 'aa', 'zzz' : 'bb', 'xxx' : 'cc', 'bbb' : 'dd'}
+ c2 = {'xxx' : 'aa', 'kkk' : 'bb', 'aaaa' : 'cc', 'www' : 'dd'}
+ def soph_const(i1, i2):
+ return c1[i1] + c2[i2]
+
+ fn = compile_function(soph_const, [str, str])
+ for x in c1.keys():
+ for y in c2.keys():
+ assert fn(x, y) == soph_const(x, y)
class TestTuple(object):
def test_f1(self):
More information about the Pypy-commit
mailing list