[pypy-svn] r33165 - pypy/branch/even-more-config3/pypy/translator/c/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Oct 11 14:39:26 CEST 2006
Author: cfbolz
Date: Wed Oct 11 14:39:25 2006
New Revision: 33165
Modified:
pypy/branch/even-more-config3/pypy/translator/c/test/test_exception.py
pypy/branch/even-more-config3/pypy/translator/c/test/test_lltyped.py
Log:
two more test files that used the default parameter way to specify annotations
Modified: pypy/branch/even-more-config3/pypy/translator/c/test/test_exception.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/translator/c/test/test_exception.py (original)
+++ pypy/branch/even-more-config3/pypy/translator/c/test/test_exception.py Wed Oct 11 14:39:25 2006
@@ -20,7 +20,7 @@
raise MyException()
else:
return 3
- def fn(i=int):
+ def fn(i):
try:
a = raise_(i) + 11
b = raise_(i) + 12
@@ -33,19 +33,19 @@
except:
return 22
return 66
- f = getcompiled(fn)
+ f = getcompiled(fn, [int])
assert f(0) == fn(0)
assert f(1) == fn(1)
assert f(2) == fn(2)
def test_implicit_index_error_lists():
- def fn(n=int):
+ def fn(n):
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
try:
return lst[n]
except:
return 2
- f = getcompiled(fn)
+ f = getcompiled(fn, [int])
assert f(-1) == fn(-1)
assert f( 0) == fn( 0)
assert f(10) == fn(10)
@@ -64,12 +64,12 @@
assert f1() == 5
def test_raise_outside_testfn():
- def testfn(n=int):
+ def testfn(n):
if n < 0:
raise ValueError("hello")
else:
raise MyException("world")
- f1 = getcompiled(testfn)
+ f1 = getcompiled(testfn, [int])
assert py.test.raises(ValueError, f1, -1)
try:
f1(1)
@@ -99,7 +99,7 @@
s = lltype.malloc(S, n)
tag.a = 42
return s
- def testfn(n=int):
+ def testfn(n):
tag = lltype.malloc(S, 0)
try:
s = g(n, tag)
@@ -107,7 +107,7 @@
except MemoryError:
result = 1000
return result + tag.a
- f1 = getcompiled(testfn)
+ f1 = getcompiled(testfn, [int])
assert f1(10) == 42
assert f1(sys.maxint) == 1000
for i in range(20):
@@ -116,14 +116,14 @@
assert f1(sys.maxint // 2 + 16384) == 1000
def test_assert():
- def testfn(n=int):
+ def testfn(n):
assert n >= 0
# big confusion with py.test's AssertionError handling here...
# some hacks to try to disable it for the current test.
saved = no_magic()
try:
- f1 = getcompiled(testfn)
+ f1 = getcompiled(testfn, [int])
res = f1(0)
assert res is None, repr(res)
res = f1(42)
Modified: pypy/branch/even-more-config3/pypy/translator/c/test/test_lltyped.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/translator/c/test/test_lltyped.py (original)
+++ pypy/branch/even-more-config3/pypy/translator/c/test/test_lltyped.py Wed Oct 11 14:39:25 2006
@@ -101,13 +101,13 @@
s.a1 = malloc(A, immortal=True)
s.a1[2].x = 50
s.a2[2].x = 60
- def llf(n=int):
+ def llf(n):
if n == 1:
a = s.a1
else:
a = s.a2
return a[2].x
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [int])
res = fn(1)
assert res == 50
res = fn(2)
@@ -119,12 +119,12 @@
A.become(FixedSizeArray(Struct('s1', ('f', Ptr(F)), ('n', Signed)), 5))
a = malloc(A, immortal=True)
a[3].n = 42
- def llf(n=int):
+ def llf(n):
if a[n].f:
return a[n].f(a)
else:
return -1
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [int])
res = fn(4)
assert res == -1
@@ -139,7 +139,7 @@
b0 = direct_arrayitems(a)
b1 = direct_ptradd(b0, 1)
b2 = direct_ptradd(b1, 1)
- def llf(n=int):
+ def llf(n):
b0 = direct_arrayitems(a)
b3 = direct_ptradd(direct_ptradd(b0, 5), -2)
saved = a[n]
@@ -148,7 +148,7 @@
return b0[0] + b3[-2] + b2[1] + b1[3]
finally:
a[n] = saved
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [int])
res = fn(0)
assert res == 1000 + 10 + 30 + 40
res = fn(1)
@@ -162,13 +162,13 @@
def test_direct_fieldptr(self):
S = GcStruct('S', ('x', Signed), ('y', Signed))
- def llf(n=int):
+ def llf(n):
s = malloc(S)
a = direct_fieldptr(s, 'y')
a[0] = n
return s.y
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [int])
res = fn(34)
assert res == 34
@@ -238,17 +238,18 @@
fn = self.getcompiled(llf)
res = fn()
assert res == 27
+ del self.process
def test_union(self):
U = Struct('U', ('s', Signed), ('c', Char),
hints={'union': True})
u = malloc(U, immortal=True)
- def llf(c=int):
+ def llf(c):
u.s = 0x10203040
u.c = chr(c)
return u.s
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [int])
res = fn(0x33)
assert res in [0x10203033, 0x33203040]
@@ -257,12 +258,12 @@
A = Array(Void)
size1 = llmemory.sizeof(A, 1)
size2 = llmemory.sizeof(A, 14)
- def f(x=int):
+ def f(x):
if x:
return size1
else:
return size2
- fn = self.getcompiled(f)
+ fn = self.getcompiled(f, [int])
res1 = fn(1)
res2 = fn(0)
assert res1 == res2
@@ -279,11 +280,11 @@
def trailing_byte(s):
adr_s = llmemory.cast_ptr_to_adr(s)
return (adr_s + chars_offset).char[len(s)]
- def f(x=int):
+ def f(x):
r = 0
for i in range(x):
r += ord(trailing_byte(' '*(100-x*x)))
return r
- fn = self.getcompiled(f)
+ fn = self.getcompiled(f, [int])
res = fn(10)
assert res == 0
More information about the Pypy-commit
mailing list