[pypy-commit] pypy kill-ootype: Remove all uses of OORtypeMixin and LLRtypeMixin
rlamy
noreply at buildbot.pypy.org
Tue Jul 9 03:00:35 CEST 2013
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-ootype
Changeset: r65271:c125ce6208a1
Date: 2013-07-07 19:11 +0200
http://bitbucket.org/pypy/pypy/changeset/c125ce6208a1/
Log: Remove all uses of OORtypeMixin and LLRtypeMixin
diff too long, truncating to 2000 out of 2364 lines
diff --git a/rpython/rlib/unicodedata/test/test_ucd.py b/rpython/rlib/unicodedata/test/test_ucd.py
--- a/rpython/rlib/unicodedata/test/test_ucd.py
+++ b/rpython/rlib/unicodedata/test/test_ucd.py
@@ -1,9 +1,9 @@
from rpython.rlib.runicode import code_to_unichr
from rpython.rlib.unicodedata import unicodedb_5_2_0
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
-class TestTranslated(BaseRtypingTest, LLRtypeMixin):
+class TestTranslated(BaseRtypingTest):
def test_translated(self):
def f(n):
if n == 0:
diff --git a/rpython/rtyper/lltypesystem/module/test/test_llinterp_math.py b/rpython/rtyper/lltypesystem/module/test/test_llinterp_math.py
--- a/rpython/rtyper/lltypesystem/module/test/test_llinterp_math.py
+++ b/rpython/rtyper/lltypesystem/module/test/test_llinterp_math.py
@@ -1,13 +1,12 @@
"""Just another bunch of tests for llmath, run on top of llinterp."""
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.rtyper.lltypesystem.module import ll_math
import math
from rpython.rlib import rfloat
-# XXX no OORtypeMixin here
-class TestMath(BaseRtypingTest, LLRtypeMixin):
+class TestMath(BaseRtypingTest):
def new_unary_test(name):
try:
fn = getattr(math, name)
diff --git a/rpython/rtyper/lltypesystem/test/test_rffi.py b/rpython/rtyper/lltypesystem/test/test_rffi.py
--- a/rpython/rtyper/lltypesystem/test/test_rffi.py
+++ b/rpython/rtyper/lltypesystem/test/test_rffi.py
@@ -6,11 +6,9 @@
from rpython.rlib.rposix import get_errno, set_errno
from rpython.translator.c.test.test_genc import compile as compile_c
from rpython.rtyper.lltypesystem.lltype import Signed, Ptr, Char, malloc
-from rpython.rtyper.lltypesystem.rstr import STR
from rpython.rtyper.lltypesystem import lltype
from rpython.tool.udir import udir
from rpython.rtyper.test.test_llinterp import interpret
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
from rpython.annotator.annrpython import RPythonAnnotator
from rpython.rtyper.rtyper import RPythonTyper
from rpython.translator.backendopt.all import backend_optimizations
@@ -56,33 +54,33 @@
xf = self.compile(f, [])
assert xf() == 8+3
-
+
def test_string(self):
eci = ExternalCompilationInfo(includes=['string.h'])
z = llexternal('strlen', [CCHARP], Signed, compilation_info=eci)
-
+
def f():
s = str2charp("xxx")
res = z(s)
free_charp(s)
return res
-
+
xf = self.compile(f, [], backendopt=False)
assert xf() == 3
-
+
def test_unicode(self):
eci = ExternalCompilationInfo(includes=['string.h'])
z = llexternal('wcslen', [CWCHARP], Signed, compilation_info=eci)
-
+
def f():
s = unicode2wcharp(u"xxx\xe9")
res = z(s)
free_wcharp(s)
return res
-
+
xf = self.compile(f, [], backendopt=False)
assert xf() == 4
-
+
def test_string_reverse(self):
c_source = py.code.Source("""
#include <string.h>
@@ -103,7 +101,7 @@
eci = ExternalCompilationInfo(separate_module_sources=[c_source],
post_include_bits=['char *f(char*);'])
z = llexternal('f', [CCHARP], CCHARP, compilation_info=eci)
-
+
def f():
s = str2charp("xxx")
l_res = z(s)
@@ -111,14 +109,14 @@
lltype.free(l_res, flavor='raw')
free_charp(s)
return len(res)
-
+
xf = self.compile(f, [], backendopt=False)
assert xf() == 3
-
+
def test_stringstar(self):
c_source = """
#include <string.h>
-
+
int f(char *args[]) {
char **p = args;
int l = 0;
@@ -131,17 +129,17 @@
"""
eci = ExternalCompilationInfo(separate_module_sources=[c_source])
z = llexternal('f', [CCHARPP], Signed, compilation_info=eci)
-
+
def f():
l = ["xxx", "x", "xxxx"]
ss = liststr2charpp(l)
result = z(ss)
free_charpp(ss)
return result
-
+
xf = self.compile(f, [], backendopt=False)
assert xf() == 8
-
+
def test_struct(self):
h_source = """
#ifndef _MY_SOURCE_H
@@ -155,24 +153,24 @@
"""
h_file = udir.join("structxx.h")
h_file.write(h_source)
-
+
c_source = """
#include <structxx.h>
-
+
int f(struct xx* z)
{
return (z->one + z->three);
}
"""
TP = CStructPtr('xx', ('one', INT), ('two', Char), ('three', INT))
-
+
eci = ExternalCompilationInfo(
includes=['structxx.h'],
include_dirs=[udir],
separate_module_sources=[c_source]
)
z = llexternal('f', [TP], INT, compilation_info=eci)
-
+
def f():
struct = lltype.malloc(TP.TO, flavor='raw')
struct.c_one = cast(INT, 3)
@@ -181,10 +179,10 @@
result = z(struct)
lltype.free(struct, flavor='raw')
return cast(SIGNED, result)
-
+
fn = self.compile(f, [], backendopt=False)
assert fn() == 8
-
+
def test_externvar(self):
import os
if os.name == 'nt':
@@ -192,25 +190,25 @@
bad_fd = 0
else:
bad_fd = 12312312
-
+
def f():
set_errno(12)
return get_errno()
-
+
def g():
try:
os.write(bad_fd, "xxx")
except OSError:
pass
return get_errno()
-
+
fn = self.compile(f, [])
assert fn() == 12
gn = self.compile(g, [])
import errno
assert gn() == errno.EBADF
-
-
+
+
def test_extra_include_dirs(self):
udir.ensure("incl", dir=True)
udir.join("incl", "incl.h").write("#define C 3")
@@ -227,21 +225,21 @@
separate_module_sources=[c_source]
)
z = llexternal('fun', [], Signed, compilation_info=eci)
-
+
def f():
return z()
-
+
res = self.compile(f, [])
assert res() == 3
-
+
def test_compile_cast(self):
def f(n):
return cast(SIZE_T, n)
-
+
f1 = self.compile(f, [int])
res = f1(-1)
assert res == r_size_t(-1)
-
+
def test_opaque_type(self):
h_source = py.code.Source("""
#ifndef _OPAQUE_H
@@ -251,22 +249,22 @@
};
#endif /* _OPAQUE_H */
""")
-
+
c_source = py.code.Source("""
#include "opaque.h"
-
+
char get(struct stuff* x)
{
x->data[13] = 'a';
return x->data[13];
}
""")
-
+
# if it doesn't segfault, than we probably malloced it :-)
h_file = udir.join("opaque.h")
h_file.write(h_source)
-
+
from rpython.rtyper.tool import rffi_platform
eci = ExternalCompilationInfo(
includes=['opaque.h'],
@@ -274,15 +272,15 @@
separate_module_sources=[c_source]
)
STUFFP = COpaquePtr('struct stuff', compilation_info=eci)
-
+
ll_get = llexternal('get', [STUFFP], CHAR, compilation_info=eci)
-
+
def f():
ll_stuff = lltype.malloc(STUFFP.TO, flavor='raw')
result = ll_get(ll_stuff)
lltype.free(ll_stuff, flavor='raw')
return result
-
+
f1 = self.compile(f, [])
assert f1() == 'a'
@@ -319,25 +317,25 @@
""" % (ctype_pref, ))
h_file = udir.join("opaque2%s.h" % (ctype_pref, ))
h_file.write(h_source)
-
+
from rpython.rtyper.tool import rffi_platform
eci = ExternalCompilationInfo(
includes=[h_file.basename],
include_dirs=[str(udir)]
)
ll_returnchar = llexternal('returnchar', [], rffi_type, compilation_info=eci)
-
+
def f():
result = ll_returnchar()
return result
-
+
f1 = self.compile(f, [])
assert f1() == chr(42)
def test_generate_return_char_tests(self):
yield self.return_char, False
yield self.return_char, True
-
+
def test_prebuilt_constant(self):
py.test.skip("Think how to do it sane")
h_source = py.code.Source("""
@@ -347,19 +345,19 @@
""")
h_include = udir.join('constants.h')
h_include.write(h_source)
-
+
eci = ExternalCompilationInfo(includes=['stdio.h',
str(h_include.basename)],
include_dirs=[str(udir)])
-
+
get_x, set_x = CExternVariable(lltype.Signed, 'x', eci)
get_z, set_z = CExternVariable(CCHARPP, 'z', eci)
-
+
def f():
one = get_x()
set_x(13)
return one + get_x()
-
+
def g():
l = liststr2charpp(["a", "b", "c"])
try:
@@ -367,7 +365,7 @@
return charp2str(get_z()[2])
finally:
free_charpp(l)
-
+
fn = self.compile(f, [])
assert fn() == 16
gn = self.compile(g, [])
@@ -380,7 +378,7 @@
extern Signed eating_callback(Signed arg, Signed(*call)(Signed));
#endif /* _CALLBACK_H */
""")
-
+
h_include = udir.join('callback.h')
h_include.write(h_source)
@@ -425,7 +423,7 @@
def two(i):
return i + 2
-
+
def f(i):
if i > 3:
return eating_callback(i, one)
@@ -471,7 +469,7 @@
TP = lltype.Ptr(lltype.GcStruct('X', ('x', lltype.Signed)))
struct = lltype.malloc(TP.TO) # gc structure
struct.x = 8
-
+
def g(i):
return get_keepalive_object(i, TP).x
@@ -495,7 +493,7 @@
assert f() == d[:-1]
fn = self.compile(f, [], gcpolicy='ref')
assert fn() == d[:-1]
-
+
def test_nonmoving_unicode(self):
d = u'non-moving data'
def f():
@@ -558,7 +556,7 @@
return cast(SIGNED, res)
assert f() == 3
assert interpret(f, []) == 3
-
+
def test_structcopy(self):
X2 = lltype.Struct('X2', ('x', SIGNED))
X1 = lltype.Struct('X1', ('a', SIGNED), ('x2', X2), ('p', lltype.Ptr(X2)))
@@ -582,7 +580,7 @@
assert f() == 123
res = interpret(f, [])
assert res == 123
-
+
def test_make_annotation(self):
X = CStruct('xx', ('one', INT))
def f():
@@ -594,14 +592,14 @@
lltype.free(p, flavor='raw')
return 3
assert interpret(f, []) == 3
-
+
def test_implicit_cast(self):
z = llexternal('z', [USHORT, ULONG, USHORT, DOUBLE], USHORT,
sandboxsafe=True) # to allow the wrapper to be inlined
-
+
def f(x, y, xx, yy):
return z(x, y, xx, yy)
-
+
a = RPythonAnnotator()
r = a.build_types(f, [int, int, int, int])
rtyper = RPythonTyper(a)
@@ -616,14 +614,14 @@
expected = {'force_cast': 3, 'cast_int_to_float': 1, 'direct_call': 1}
for k, v in expected.items():
assert s[k] == v
-
+
def test_stringpolicy1(self):
eci = ExternalCompilationInfo(includes=['string.h'])
strlen = llexternal('strlen', [CCHARP], SIZE_T, compilation_info=eci)
def f():
return cast(SIGNED, strlen("Xxx"))
assert interpret(f, [], backendopt=True) == 3
-
+
def test_stringpolicy3(self):
eci = ExternalCompilationInfo(includes=['string.h'])
strlen = llexternal('strlen', [CCHARP], INT, compilation_info=eci)
@@ -632,9 +630,9 @@
res = strlen(ll_str)
lltype.free(ll_str, flavor='raw')
return res
-
+
assert interpret(f, [], backendopt=True) == 3
-
+
def test_stringpolicy_mixed(self):
eci = ExternalCompilationInfo(includes=['string.h'])
strlen = llexternal('strlen', [CCHARP], SIZE_T,
@@ -645,9 +643,9 @@
res2 = strlen(ll_str)
lltype.free(ll_str, flavor='raw')
return cast(SIGNED, res1*10 + res2)
-
- assert interpret(f, [], backendopt=True) == 43
-
+
+ assert interpret(f, [], backendopt=True) == 43
+
def test_around_extcall(self):
if sys.platform == "win32":
py.test.skip('No pipes on windows')
@@ -666,7 +664,7 @@
os.write(write_fd, s)
register_external(mywrite, [str], annmodel.s_None, 'll_mywrite',
llfakeimpl=llimpl, sandboxsafe=True)
-
+
def before():
mywrite("B")
def after():
@@ -675,11 +673,11 @@
os.write(write_fd, "-")
invoke_around_extcall(before, after)
os.write(write_fd, "E")
-
+
interpret(f, [])
data = os.read(read_fd, 99)
assert data == "-BEA"
-
+
finally:
os.close(write_fd)
os.close(read_fd)
@@ -688,16 +686,16 @@
""" Try to call some llexternal function with llinterp
"""
z = llexternal('z', [Signed], Signed, _callable=lambda x:x+1)
-
+
def f():
return z(2)
-
+
res = interpret(f, [])
assert res == 3
def test_size_t_sign(self):
assert r_size_t(-1) > 0
-
+
def test_cast(self):
res = cast(SIZE_T, -1)
assert type(res) is r_size_t
@@ -705,7 +703,7 @@
#
res = cast(lltype.Signed, 42.5)
assert res == 42
-
+
res = cast(lltype.SingleFloat, 12.3)
assert res == r_singlefloat(12.3)
res = cast(lltype.SingleFloat, res)
@@ -738,7 +736,7 @@
ULONGLONG: ctypes.c_ulonglong,
SIZE_T: ctypes.c_size_t,
}
-
+
for ll, ctp in cache.items():
assert sizeof(ll) == ctypes.sizeof(ctp)
assert sizeof(lltype.Typedef(ll, 'test')) == sizeof(ll)
@@ -747,7 +745,7 @@
assert size_and_sign(lltype.UniChar)[1]
assert size_and_sign(UINT)[1]
assert not size_and_sign(INT)[1]
-
+
def test_rffi_offsetof(self):
import struct
from rpython.rtyper.tool import rffi_platform
@@ -777,7 +775,7 @@
for i in xrange(len(data) - 2):
assert a2[i] == a[i + 2]
lltype.free(a, flavor='raw')
-
+
def test_ptradd_interpret():
interpret(test_ptradd, [])
diff --git a/rpython/rtyper/module/test/test_ll_strtod.py b/rpython/rtyper/module/test/test_ll_strtod.py
--- a/rpython/rtyper/module/test/test_ll_strtod.py
+++ b/rpython/rtyper/module/test/test_ll_strtod.py
@@ -1,9 +1,9 @@
import py
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.rlib import rfloat
-class BaseTestStrtod(BaseRtypingTest):
+class TestStrtod(BaseRtypingTest):
def test_formatd(self):
for flags in [0,
rfloat.DTSF_ADD_DOT_0]:
@@ -14,12 +14,12 @@
def test_parts_to_float(self):
from rpython.rtyper.annlowlevel import hlstr
-
+
def f(a, b, c, d):
a,b,c,d = hlstr(a), hlstr(b), hlstr(c), hlstr(d)
-
+
return rfloat.parts_to_float(a, b, c, d)
-
+
data = [
(("","1","","") , 1.0),
(("-","1","","") , -1.0),
@@ -32,6 +32,3 @@
for parts, val in data:
args = [self.string_to_ll(i) for i in parts]
assert self.interpret(f, args) == val
-
-class TestLLStrtod(BaseTestStrtod, LLRtypeMixin):
- pass
diff --git a/rpython/rtyper/module/test/test_ll_time.py b/rpython/rtyper/module/test/test_ll_time.py
--- a/rpython/rtyper/module/test/test_ll_time.py
+++ b/rpython/rtyper/module/test/test_ll_time.py
@@ -1,14 +1,14 @@
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
#from rpython.translator.c.test.test_genc import compile
import time, sys
-class BaseTestTime(BaseRtypingTest):
+class TestTime(BaseRtypingTest):
def test_time_time(self):
def fn():
return time.time()
-
+
t0 = time.time()
res0 = self.interpret(fn, [])
t1 = time.time()
@@ -54,9 +54,3 @@
t1 = time.time()
assert t0 <= t1
assert t1 - t0 >= 0.15
-
-class TestLLType(BaseTestTime, LLRtypeMixin):
- pass
-
-class TestOOType(BaseTestTime, OORtypeMixin):
- pass
diff --git a/rpython/rtyper/module/test/test_posix.py b/rpython/rtyper/module/test/test_posix.py
--- a/rpython/rtyper/module/test/test_posix.py
+++ b/rpython/rtyper/module/test/test_posix.py
@@ -1,5 +1,5 @@
import py
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.tool.udir import udir
from rpython.rlib.rarithmetic import is_valid_int
@@ -10,7 +10,7 @@
testf = udir.join('test.txt')
module.path = testf.strpath
-class BaseTestPosix(BaseRtypingTest):
+class TestPosix(BaseRtypingTest):
def setup_method(self, meth):
# prepare/restore the file before each test
@@ -70,7 +70,7 @@
def f(fi, pos):
posix.lseek(fi, pos, 0)
fi = os.open(path, os.O_RDONLY, 0777)
- func = self.interpret(f, [fi, 5])
+ func = self.interpret(f, [fi, 5])
res = os.read(fi, 2)
assert res =='is'
@@ -129,11 +129,11 @@
return 1
except OSError:
return 2
-
+
assert self.interpret(f, []) == 1
os.unlink(path)
assert self.interpret(f, []) == 2
-
+
def test_close(self):
def f(fi):
return posix.close(fi)
@@ -148,7 +148,7 @@
def f(fi,len):
os.ftruncate(fi,len)
fi = os.open(path,os.O_RDWR,0777)
- func = self.interpret(f,[fi,6])
+ func = self.interpret(f,[fi,6])
assert os.fstat(fi).st_size == 6
if hasattr(os, 'getuid'):
@@ -197,9 +197,7 @@
for value in [0, 1, 127, 128, 255]:
res = self.interpret(fun, [value])
- assert res == fun(value)
-
-class TestLLtype(BaseTestPosix, LLRtypeMixin):
+ assert res == fun(value)
if hasattr(os, 'getgroups'):
def test_getgroups(self):
@@ -207,19 +205,3 @@
return os.getgroups()
ll_a = self.interpret(f, [])
assert self.ll_to_list(ll_a) == f()
-
-class TestOOtype(BaseTestPosix, OORtypeMixin):
- def test_fstat(self):
- py.test.skip("ootypesystem does not support os.fstat")
-
- def test_os_chroot(self):
- py.test.skip("ootypesystem does not support os.chroot")
-
- def test_stat(self):
- py.test.skip("ootypesystem does not support os.stat")
-
- def test_stat_exception(self):
- py.test.skip("ootypesystem does not support os.stat")
-
- def test_chown(self):
- py.test.skip("ootypesystem does not support os.chown")
diff --git a/rpython/rtyper/test/test_annlowlevel.py b/rpython/rtyper/test/test_annlowlevel.py
--- a/rpython/rtyper/test/test_annlowlevel.py
+++ b/rpython/rtyper/test/test_annlowlevel.py
@@ -2,16 +2,15 @@
""" Few tests for annlowlevel helpers
"""
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.rtyper.lltypesystem.rstr import mallocstr, mallocunicode
from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.ootypesystem import ootype
-from rpython.rtyper.annlowlevel import hlstr, llstr, oostr
+from rpython.rtyper.annlowlevel import hlstr, llstr
from rpython.rtyper.annlowlevel import hlunicode, llunicode
from rpython.rtyper import annlowlevel
-class TestLLType(BaseRtypingTest, LLRtypeMixin):
+class TestLLType(BaseRtypingTest):
def test_hlstr(self):
s = mallocstr(3)
s.chars[0] = "a"
@@ -33,7 +32,7 @@
res = self.interpret(f, [self.string_to_ll("abc")])
assert res == 3
-
+
def test_hlunicode(self):
s = mallocunicode(3)
s.chars[0] = u"a"
@@ -64,31 +63,3 @@
assert lltype.typeOf(ptr) == annlowlevel.base_ptr_lltype()
y = annlowlevel.cast_base_ptr_to_instance(X, ptr)
assert y is x
-
-
-class TestOOType(BaseRtypingTest, OORtypeMixin):
- def test_hlstr(self):
- s = ootype.make_string("abc")
- assert hlstr(s) == "abc"
-
- def test_oostr(self):
- s = oostr("abc")
- assert ootype.typeOf(s) == ootype.String
- assert s._str == "abc"
-
- def test_oostr_compile(self):
- def f(arg):
- s = oostr(hlstr(arg))
- return s.ll_strlen()
-
- res = self.interpret(f, [self.string_to_ll("abc")])
- assert res == 3
-
- def test_cast_instance_to_base_obj(self):
- class X(object):
- pass
- x = X()
- obj = annlowlevel.cast_instance_to_base_obj(x)
- assert lltype.typeOf(obj) == annlowlevel.base_obj_ootype()
- y = annlowlevel.cast_base_ptr_to_instance(X, obj)
- assert y is x
diff --git a/rpython/rtyper/test/test_exception.py b/rpython/rtyper/test/test_exception.py
--- a/rpython/rtyper/test/test_exception.py
+++ b/rpython/rtyper/test/test_exception.py
@@ -1,7 +1,7 @@
import py
from rpython.translator.translator import TranslationContext
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.rtyper.llinterp import LLException
from rpython.rtyper.error import MissingRTypeOperation
@@ -33,7 +33,7 @@
rtype(dummyfn)
-class BaseTestException(BaseRtypingTest):
+class TestException(BaseRtypingTest):
def test_exception_with_arg(self):
def g(n):
raise OSError(n, "?")
@@ -113,8 +113,6 @@
res = self.interpret(f, [42])
assert res == 42
-
-class TestLLtype(BaseTestException, LLRtypeMixin):
def test_cannot_raise_ll_exception(self):
from rpython.rtyper.annlowlevel import cast_instance_to_base_ptr
def g():
@@ -127,6 +125,3 @@
except OverflowError:
return 42
py.test.raises(MissingRTypeOperation, self.interpret, f, [])
-
-class TestOOtype(BaseTestException, OORtypeMixin):
- pass
diff --git a/rpython/rtyper/test/test_generator.py b/rpython/rtyper/test/test_generator.py
--- a/rpython/rtyper/test/test_generator.py
+++ b/rpython/rtyper/test/test_generator.py
@@ -1,9 +1,9 @@
import py
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
-class BaseTestGenerator(BaseRtypingTest):
+class TestGenerator(BaseRtypingTest):
def test_simple_explicit(self):
def g(a, b, c):
@@ -88,12 +88,3 @@
return s
res = self.interpret(g, [])
assert res == 6
-
-
-class TestLLtype(BaseTestGenerator, LLRtypeMixin):
- pass
-
-
-class TestOOtype(BaseTestGenerator, OORtypeMixin):
- def test_iterating_generator(self):
- py.test.skip("Iterators aren't supported on OOtype yet")
diff --git a/rpython/rtyper/test/test_rbool.py b/rpython/rtyper/test/test_rbool.py
--- a/rpython/rtyper/test/test_rbool.py
+++ b/rpython/rtyper/test/test_rbool.py
@@ -1,7 +1,7 @@
from rpython.translator.translator import TranslationContext
from rpython.annotator import unaryop, binaryop
from rpython.rtyper.test import snippet
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
class TestSnippet(object):
@@ -33,7 +33,7 @@
for opname in binaryop.BINARY_OPERATIONS:
print 'BINARY_OPERATIONS:', opname
-class BaseTestRbool(BaseRtypingTest):
+class TestRbool(BaseRtypingTest):
def test_bool2int(self):
def f(n):
@@ -82,9 +82,3 @@
assert res == 1
res = self.interpret(f, [1, True])
assert res == 1
-
-class TestLLtype(BaseTestRbool, LLRtypeMixin):
- pass
-
-class TestOOtype(BaseTestRbool, OORtypeMixin):
- pass
diff --git a/rpython/rtyper/test/test_rbuilder.py b/rpython/rtyper/test/test_rbuilder.py
--- a/rpython/rtyper/test/test_rbuilder.py
+++ b/rpython/rtyper/test/test_rbuilder.py
@@ -6,7 +6,7 @@
from rpython.rtyper.annlowlevel import llstr, hlstr
from rpython.rtyper.lltypesystem import rffi
from rpython.rtyper.lltypesystem.rbuilder import StringBuilderRepr
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
class TestStringBuilderDirect(object):
@@ -25,7 +25,7 @@
assert StringBuilderRepr.ll_build(sb) == sb.buf
-class BaseTestStringBuilder(BaseRtypingTest):
+class TestStringBuilder(BaseRtypingTest):
def test_simple(self):
def func():
s = StringBuilder()
@@ -92,7 +92,7 @@
if s:
s.append("3")
return bool(s)
-
+
def func(i):
if i:
s = StringBuilder()
@@ -109,7 +109,7 @@
if s:
s.append(u"3")
return bool(s)
-
+
def func(i):
if i:
s = UnicodeBuilder()
@@ -120,11 +120,3 @@
assert not res
res = self.interpret(func, [1])
assert res
-
-
-class TestLLtype(BaseTestStringBuilder, LLRtypeMixin):
- pass
-
-class TestOOtype(BaseTestStringBuilder, OORtypeMixin):
- def test_append_charpsize(self):
- py.test.skip("append_charpsize(): not implemented on ootype")
diff --git a/rpython/rtyper/test/test_rbuiltin.py b/rpython/rtyper/test/test_rbuiltin.py
--- a/rpython/rtyper/test/test_rbuiltin.py
+++ b/rpython/rtyper/test/test_rbuiltin.py
@@ -11,7 +11,7 @@
from rpython.rtyper.annlowlevel import hlstr, LowLevelAnnotatorPolicy
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rtyper.test import test_llinterp
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.tool import udir
from rpython.translator.translator import graphof
@@ -24,7 +24,7 @@
yield op
-class BaseTestRbuiltin(BaseRtypingTest):
+class TestRbuiltin(BaseRtypingTest):
def test_method_join(self):
# this is tuned to catch a specific bug:
@@ -453,9 +453,8 @@
assert x0 != x2
# the following checks are probably too precise, but work at
# least on top of llinterp
- if type(self) is TestLLtype:
- assert x1 == intmask(x0)
- assert x3 == intmask(x2)
+ assert x1 == intmask(x0)
+ assert x3 == intmask(x2)
def test_id_on_builtins(self):
def fn():
@@ -537,8 +536,6 @@
res = self.interpret(f, [12])
assert res == 512
-
-class TestLLtype(BaseTestRbuiltin, LLRtypeMixin):
def test_cast(self):
def llfn(v):
return rffi.cast(rffi.VOIDP, v)
@@ -559,23 +556,3 @@
res = self.interpret(llfn, [lltype.nullptr(rffi.VOIDP.TO)])
assert res == 0
assert isinstance(res, r_ulonglong)
-
-
-class TestOOtype(BaseTestRbuiltin, OORtypeMixin):
-
- def test_instantiate_multiple_meta(self):
- class A:
- x = 2
- class B(A):
- x = 3
- def do_stuff(cls):
- return cls.x
- def f(i):
- if i == 1:
- cls = A
- else:
- cls = B
- do_stuff(cls)
- return instantiate(cls)
- res = self.interpret(f, [1])
- assert res.getmeta() # check that it exists
diff --git a/rpython/rtyper/test/test_rbytearray.py b/rpython/rtyper/test/test_rbytearray.py
--- a/rpython/rtyper/test/test_rbytearray.py
+++ b/rpython/rtyper/test/test_rbytearray.py
@@ -1,9 +1,9 @@
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.rtyper.lltypesystem.rbytearray import hlbytearray
from rpython.rtyper.annlowlevel import llstr, hlstr
-class TestByteArray(BaseRtypingTest, LLRtypeMixin):
+class TestByteArray(BaseRtypingTest):
def test_bytearray_creation(self):
def f(x):
if x:
diff --git a/rpython/rtyper/test/test_rclass.py b/rpython/rtyper/test/test_rclass.py
--- a/rpython/rtyper/test/test_rclass.py
+++ b/rpython/rtyper/test/test_rclass.py
@@ -10,7 +10,7 @@
from rpython.rtyper.error import TyperError
from rpython.rtyper.rclass import (IR_IMMUTABLE, IR_IMMUTABLE_ARRAY,
IR_QUASIIMMUTABLE, IR_QUASIIMMUTABLE_ARRAY)
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.translator.translator import TranslationContext, graphof
@@ -36,7 +36,7 @@
class C(B):
pass
-class BaseTestRclass(BaseRtypingTest):
+class TestRclass(BaseRtypingTest):
def test_instanceattr(self):
def dummyfn():
@@ -71,7 +71,7 @@
return A
else:
return B
-
+
def dummyfn(i):
C = pick(i)
i = C()
@@ -93,7 +93,7 @@
return A
else:
return B
-
+
def dummyfn(i):
C = pick(i)
i = C()
@@ -281,14 +281,14 @@
class B(A):
pass
-
+
def f():
a = A()
b = B()
a.meth(1) # the self of this variant is annotated with A
b.meth(2) # the self of this variant is annotated with B
return 42
-
+
res = self.interpret(f, [])
assert res == 42
@@ -300,18 +300,18 @@
class B(A):
pass
def f(i):
- if i == 0:
+ if i == 0:
c1 = A()
- else:
+ else:
c1 = B()
return issubclass(type(c1), B)
- assert self.interpret(f, [0]) == False
+ assert self.interpret(f, [0]) == False
assert self.interpret(f, [1]) == True
def g(i):
- if i == 0:
+ if i == 0:
c1 = A()
- else:
+ else:
c1 = B()
return issubclass(type(c1), A)
assert self.interpret(g, [0]) == True
@@ -468,11 +468,9 @@
# a value that is (or was) the current_object_addr_as_int().
# --- disabled: assert res.item0 == res.item1
# the following property is essential on top of the lltypesystem
- # otherwise prebuilt dictionaries are broken. It's wrong on
- # top of the ootypesystem though.
- if isinstance(self, LLRtypeMixin):
- assert res.item2 == h_c
- assert res.item3 == h_d
+ # otherwise prebuilt dictionaries are broken.
+ assert res.item2 == h_c
+ assert res.item3 == h_d
def test_circular_hash_initialization(self):
class B:
@@ -517,10 +515,10 @@
def f():
return type(a) is A
-
+
res = self.interpret(f, [])
-
-
+
+
def test_void_fnptr(self):
def g():
return 42
@@ -732,7 +730,7 @@
def test_immutable(self):
class I(object):
_immutable_ = True
-
+
def __init__(self, v):
self.v = v
@@ -973,8 +971,6 @@
self.gengraph(f, [])
-class TestLLtype(BaseTestRclass, LLRtypeMixin):
-
def test__del__(self):
class A(object):
def __init__(self):
@@ -1161,7 +1157,7 @@
class Iterable(object):
def __init__(self):
self.counter = 0
-
+
def __iter__(self):
return self
@@ -1184,7 +1180,7 @@
class BaseIterable(object):
def __init__(self):
self.counter = 0
-
+
def __iter__(self):
return self
@@ -1193,7 +1189,7 @@
raise StopIteration
self.counter += self.step
return self.counter - 1
-
+
class Iterable(BaseIterable):
step = 1
@@ -1212,125 +1208,3 @@
assert self.interpret(f, [True]) == f(True)
assert self.interpret(f, [False]) == f(False)
-
-
-class TestOOtype(BaseTestRclass, OORtypeMixin):
-
- def test__del__(self):
- class A(object):
- def __init__(self):
- self.a = 2
- def __del__(self):
- self.a = 3
- def f():
- a = A()
- return a.a
- t = TranslationContext()
- t.buildannotator().build_types(f, [])
- t.buildrtyper(type_system=self.type_system).specialize()
- graph = graphof(t, f)
- TYPE = graph.startblock.operations[0].args[0].value
- _, meth = TYPE._lookup("o__del__")
- assert meth.finalizer
-
- def test_del_inheritance(self):
- from rpython.rlib import rgc
- class State:
- pass
- s = State()
- s.a_dels = 0
- s.b_dels = 0
- class A(object):
- def __del__(self):
- s.a_dels += 1
- class B(A):
- def __del__(self):
- s.b_dels += 1
- class C(A):
- pass
- def f():
- A()
- B()
- C()
- A()
- B()
- C()
- rgc.collect()
- return s.a_dels * 10 + s.b_dels
- res = f()
- assert res == 42
- t = TranslationContext()
- t.buildannotator().build_types(f, [])
- t.buildrtyper(type_system=self.type_system).specialize()
- graph = graphof(t, f)
- TYPEA = graph.startblock.operations[0].args[0].value
- TYPEB = graph.startblock.operations[1].args[0].value
- TYPEC = graph.startblock.operations[2].args[0].value
- _, destra = TYPEA._lookup("o__del__")
- _, destrb = TYPEB._lookup("o__del__")
- _, destrc = TYPEC._lookup("o__del__")
- assert destra == destrc
- assert destrb is not None
- assert destra is not None
-
- def test_cast_object_instance(self):
- A = ootype.Instance("Foo", ootype.ROOT)
-
- def fn_instance():
- a = ootype.new(A)
- obj = ootype.cast_to_object(a)
- a2 = ootype.cast_from_object(A, obj)
- a3 = ootype.cast_from_object(ootype.ROOT, obj)
- assert a is a2
- assert a is a3
- self.interpret(fn_instance, [])
-
- def test_cast_object_record(self):
- B = ootype.Record({'x': ootype.Signed})
-
- def fn_record():
- b = ootype.new(B)
- b.x = 42
- obj = ootype.cast_to_object(b)
- b2 = ootype.cast_from_object(B, obj)
- assert b2.x == 42
- assert b is b2
- self.interpret(fn_record, [])
-
- def test_cast_object_null(self):
- A = ootype.Instance("Foo", ootype.ROOT)
- B = ootype.Record({'x': ootype.Signed})
-
- def fn_null():
- a = ootype.null(A)
- b = ootype.null(B)
- obj1 = ootype.cast_to_object(a)
- obj2 = ootype.cast_to_object(b)
- assert obj1 == obj2
- assert ootype.cast_from_object(A, obj1) == a
- assert ootype.cast_from_object(B, obj2) == b
- self.interpret(fn_null, [])
-
- def test_cast_object_is_true(self):
- A = ootype.Instance("Foo", ootype.ROOT)
- def fn_is_true(flag):
- if flag:
- a = ootype.new(A)
- else:
- a = ootype.null(A)
- obj = ootype.cast_to_object(a)
- return bool(obj)
- assert self.interpret(fn_is_true, [True]) is True
- assert self.interpret(fn_is_true, [False]) is False
-
- def test_cast_object_mix_null(self):
- A = ootype.Instance("Foo", ootype.ROOT)
- def fn_mix_null(flag):
- a = ootype.new(A)
- obj = ootype.cast_to_object(a)
- if flag:
- return obj
- else:
- return ootype.NULL
- res = self.interpret(fn_mix_null, [False])
- assert res is ootype.NULL
diff --git a/rpython/rtyper/test/test_rconstantdict.py b/rpython/rtyper/test/test_rconstantdict.py
--- a/rpython/rtyper/test/test_rconstantdict.py
+++ b/rpython/rtyper/test/test_rconstantdict.py
@@ -1,12 +1,12 @@
import py
from rpython.rlib.objectmodel import r_dict
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
-class BaseTestRconstantdict(BaseRtypingTest):
+class TestRconstantdict(BaseRtypingTest):
- def test_constant_int_dict(self):
- d = {1: 2, 2: 3, 3: 4}
- def func(i):
+ def test_constant_int_dict(self):
+ d = {1: 2, 2: 3, 3: 4}
+ def func(i):
return d[i]
res = self.interpret(func, [3])
assert res == 4
@@ -60,10 +60,3 @@
for x in range(65, 91):
res = self.interpret(func, [x])
assert res == x*x
-
-
-class TestLLtype(BaseTestRconstantdict, LLRtypeMixin):
- pass
-
-class TestOOtype(BaseTestRconstantdict, OORtypeMixin):
- pass
diff --git a/rpython/rtyper/test/test_rdict.py b/rpython/rtyper/test/test_rdict.py
--- a/rpython/rtyper/test/test_rdict.py
+++ b/rpython/rtyper/test/test_rdict.py
@@ -2,7 +2,7 @@
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rtyper import rint
from rpython.rtyper.lltypesystem import rdict, rstr
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.rlib.objectmodel import r_dict
from rpython.rlib.rarithmetic import r_int, r_uint, r_longlong, r_ulonglong
@@ -22,7 +22,7 @@
yield x
-class BaseTestRdict(BaseRtypingTest):
+class TestRdict(BaseRtypingTest):
def test_dict_creation(self):
def createdict(i):
@@ -683,7 +683,6 @@
res = self.interpret(f, [700])
assert res == 12
-class TestLLtype(BaseTestRdict, LLRtypeMixin):
def test_dict_but_not_with_char_keys(self):
def func(i):
d = {'h': i}
@@ -1003,21 +1002,6 @@
finally:
lltype._array._check_range = original_check_range
- # ____________________________________________________________
-
-
-
-class TestOOtype(BaseTestRdict, OORtypeMixin):
-
- def test_recursive(self):
- def func(i):
- dic = {i: {}}
- dic[i] = dic
- return dic[i]
- res = self.interpret(func, [5])
- assert res.ll_get(5) is res
-
- # ____________________________________________________________
class TestStress:
diff --git a/rpython/rtyper/test/test_remptydict.py b/rpython/rtyper/test/test_remptydict.py
--- a/rpython/rtyper/test/test_remptydict.py
+++ b/rpython/rtyper/test/test_remptydict.py
@@ -1,5 +1,5 @@
import py
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
class BaseTestRemptydict(BaseRtypingTest):
def test_empty_dict(self):
@@ -26,16 +26,3 @@
return n
res = self.interpret(f, [])
assert res == 0
-
-class TestLLtype(BaseTestRemptydict, LLRtypeMixin):
- pass
-
-class TestOOtype(BaseTestRemptydict, OORtypeMixin):
- def test_almost_empty_dict(self):
- def f(flag):
- d = {}
- if flag:
- d[None] = None
- return None in d
- assert self.interpret(f, [True]) is True
- assert self.interpret(f, [False]) is False
diff --git a/rpython/rtyper/test/test_rfloat.py b/rpython/rtyper/test/test_rfloat.py
--- a/rpython/rtyper/test/test_rfloat.py
+++ b/rpython/rtyper/test/test_rfloat.py
@@ -2,7 +2,7 @@
from rpython.translator.translator import TranslationContext
from rpython.annotator import unaryop, binaryop
from rpython.rtyper.test import snippet
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.rlib.rarithmetic import (
r_int, r_uint, r_longlong, r_ulonglong, r_singlefloat)
from rpython.rlib.objectmodel import compute_hash
@@ -13,8 +13,8 @@
t = TranslationContext()
t.buildannotator().build_types(func, types)
t.buildrtyper().specialize()
- t.checkgraphs()
-
+ t.checkgraphs()
+
def test_not1(self):
self._test(snippet.not1, [float])
@@ -37,7 +37,7 @@
for opname in binaryop.BINARY_OPERATIONS:
print 'BINARY_OPERATIONS:', opname
-class BaseTestRfloat(BaseRtypingTest):
+class TestRfloat(BaseRtypingTest):
inf = 'inf'
minus_inf = '-inf'
@@ -73,9 +73,9 @@
res = self.interpret(fn, [1.0])
assert res == 1
- assert type(res) is int
+ assert type(res) is int
res = self.interpret(fn, [2.34])
- assert res == fn(2.34)
+ assert res == fn(2.34)
def test_longlong_conversion(self):
def fn(f):
@@ -89,7 +89,7 @@
else:
assert self.is_of_type(res, r_longlong)
res = self.interpret(fn, [2.34])
- assert res == fn(2.34)
+ assert res == fn(2.34)
big = float(0x7fffffffffffffff)
x = big - 1.e10
assert x != big
@@ -276,27 +276,8 @@
assert self.interpret(func, [0]) == 1e23
assert self.interpret(func, [1]) == -1e23
-
-
-class TestLLtype(BaseTestRfloat, LLRtypeMixin):
-
def test_hash(self):
def fn(f):
return compute_hash(f)
res = self.interpret(fn, [1.5])
assert res == compute_hash(1.5)
-
-
-class TestOOtype(BaseTestRfloat, OORtypeMixin):
-
- def test_formatd(self):
- py.test.skip('formatd is broken on ootype')
-
- def test_formatd_repr(self):
- py.test.skip('formatd is broken on ootype')
-
- def test_formatd_huge(self):
- py.test.skip('formatd is broken on ootype')
-
- def test_parts_to_float(self):
- py.test.skip('parts_to_float is broken on ootype')
diff --git a/rpython/rtyper/test/test_rint.py b/rpython/rtyper/test/test_rint.py
--- a/rpython/rtyper/test/test_rint.py
+++ b/rpython/rtyper/test/test_rint.py
@@ -6,11 +6,8 @@
from rpython.rlib.rarithmetic import r_int, r_uint, r_longlong, r_ulonglong
from rpython.rlib.rarithmetic import ovfcheck, r_int64, intmask, int_between
from rpython.rlib import objectmodel
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
-from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.ootypesystem import ootype
-from rpython.rtyper.lltypesystem.lloperation import llop
class TestSnippet(object):
@@ -43,7 +40,7 @@
print 'BINARY_OPERATIONS:', opname
-class BaseTestRint(BaseRtypingTest):
+class TestRint(BaseRtypingTest):
def test_char_constant(self):
def dummyfn(i):
@@ -424,15 +421,3 @@
assert not self.interpret(fn, [1, 5, 2])
assert not self.interpret(fn, [1, 2, 2])
assert not self.interpret(fn, [1, 1, 1])
-
-
-
-class TestLLtype(BaseTestRint, LLRtypeMixin):
- pass
-
-class TestOOtype(BaseTestRint, OORtypeMixin):
- def test_oobox_int(self):
- def f():
- x = llop.oobox_int(ootype.Object, 42)
- return llop.oounbox_int(lltype.Signed, x)
- assert self.interpret(f, []) == 42
diff --git a/rpython/rtyper/test/test_rlist.py b/rpython/rtyper/test/test_rlist.py
--- a/rpython/rtyper/test/test_rlist.py
+++ b/rpython/rtyper/test/test_rlist.py
@@ -8,10 +8,9 @@
from rpython.rtyper.llinterp import LLException
from rpython.rtyper.lltypesystem import rlist as ll_rlist
from rpython.rtyper.lltypesystem.rlist import ListRepr, FixedSizeListRepr, ll_newlist, ll_fixed_newlist
-from rpython.rtyper.ootypesystem import rlist as oo_rlist
from rpython.rtyper.rint import signed_repr
from rpython.rtyper.rlist import *
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
from rpython.translator.translator import TranslationContext
@@ -188,6 +187,8 @@
class BaseTestRlist(BaseRtypingTest):
+ type_system = 'lltype'
+ rlist = ll_rlist
def test_simple(self):
def dummyfn():
@@ -1139,13 +1140,7 @@
res = self.interpret(f, [0])
assert res == 1
- if self.type_system == 'lltype':
- # on lltype we always get an AssertionError
- py.test.raises(AssertionError, self.interpret, f, [1])
- else:
- # on ootype we happen to get through the ll_asserts and to
- # hit the IndexError from ootype.py
- self.interpret_raises(IndexError, f, [1])
+ py.test.raises(AssertionError, self.interpret, f, [1])
def f(x):
l = [1]
@@ -1190,13 +1185,7 @@
res = self.interpret(f, [0])
assert res == 1
- if self.type_system == 'lltype':
- # on lltype we always get an AssertionError
- py.test.raises(AssertionError, self.interpret, f, [1])
- else:
- # on ootype we happen to get through the ll_asserts and to
- # hit the IndexError from ootype.py
- self.interpret_raises(IndexError, f, [1])
+ py.test.raises(AssertionError, self.interpret, f, [1])
def f(x):
l = [1]
@@ -1233,13 +1222,7 @@
res = self.interpret(f, [0])
assert res == 1
- if self.type_system == 'lltype':
- # on lltype we always get an AssertionError
- py.test.raises(AssertionError, self.interpret, f, [1])
- else:
- # on ootype we happen to get through the ll_asserts and to
- # hit the IndexError from ootype.py
- self.interpret_raises(IndexError, f, [1])
+ py.test.raises(AssertionError, self.interpret, f, [1])
def test_charlist_extension_1(self):
def f(n):
@@ -1435,10 +1418,6 @@
res = self.interpret(f, [0])
assert self.ll_to_string(res) == 'abc'
-class TestLLtype(BaseTestRlist, LLRtypeMixin):
- type_system = 'lltype'
- rlist = ll_rlist
-
def test_memoryerror(self):
def fn(i):
lst = [0] * i
@@ -1610,11 +1589,3 @@
assert res == sum(map(ord, 'abcdef'))
finally:
rlist.ll_getitem_foldable_nonneg = prev
-
-
-class TestOOtype(BaseTestRlist, OORtypeMixin):
- rlist = oo_rlist
- type_system = 'ootype'
-
- def test_reversed(self):
- py.test.skip("unsupported")
diff --git a/rpython/rtyper/test/test_rpbc.py b/rpython/rtyper/test/test_rpbc.py
--- a/rpython/rtyper/test/test_rpbc.py
+++ b/rpython/rtyper/test/test_rpbc.py
@@ -2,7 +2,7 @@
from rpython.annotator import policy, specialize
from rpython.rtyper.lltypesystem.lltype import typeOf
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
class MyBase:
@@ -40,7 +40,7 @@
return self.x + y
-class BaseTestRPBC(BaseRtypingTest):
+class TestRPBC(BaseRtypingTest):
def test_easy_call(self):
def f(x):
@@ -182,7 +182,7 @@
class DeviceTask(Task):
def fn(self, a):
return self.waitTask(a)+3
-
+
def f(a, b):
if b:
inst = HandlerTask()
@@ -190,7 +190,7 @@
inst = DeviceTask()
return inst.runTask(a)
-
+
assert self.interpret(f, [42, True]) == 45
assert self.interpret(f, [42, False]) == 46
@@ -323,9 +323,9 @@
fr = fr2
return getorbuild(fr)
- res = self.interpret(f1, [0])
+ res = self.interpret(f1, [0])
assert res == 7
- res = self.interpret(f1, [1])
+ res = self.interpret(f1, [1])
assert res == 3
def test_call_memoized_function_with_bools(self):
@@ -357,25 +357,25 @@
def test_call_memoized_cache(self):
- # this test checks that we add a separate field
- # per specialization and also it uses a subclass of
+ # this test checks that we add a separate field
+ # per specialization and also it uses a subclass of
# the standard rpython.rlib.cache.Cache
from rpython.rlib.cache import Cache
fr1 = Freezing()
fr2 = Freezing()
- class Cache1(Cache):
- def _build(self, key):
- "NOT_RPYTHON"
+ class Cache1(Cache):
+ def _build(self, key):
+ "NOT_RPYTHON"
if key is fr1:
- return fr2
+ return fr2
else:
- return fr1
+ return fr1
- class Cache2(Cache):
- def _build(self, key):
- "NOT_RPYTHON"
+ class Cache2(Cache):
+ def _build(self, key):
+ "NOT_RPYTHON"
a = 1
if key is fr1:
result = eval("a+2")
@@ -394,9 +394,9 @@
newfr = cache1.getorbuild(fr)
return cache2.getorbuild(newfr)
- res = self.interpret(f1, [0])
+ res = self.interpret(f1, [0])
assert res == 3
- res = self.interpret(f1, [1])
+ res = self.interpret(f1, [1])
assert res == 7
def test_call_memo_with_single_value(self):
@@ -525,7 +525,7 @@
res = self.interpret(f, [7])
assert res == 42
- def test_simple_function_pointer(self):
+ def test_simple_function_pointer(self):
def f1(x):
return x + 1
def f2(x):
@@ -533,7 +533,7 @@
l = [f1, f2]
- def pointersimple(i):
+ def pointersimple(i):
return l[i](i)
res = self.interpret(pointersimple, [1])
@@ -621,7 +621,7 @@
class A(object): pass
def none():
return None
-
+
def f(i):
if i == 1:
return none()
@@ -631,7 +631,7 @@
assert not res
res = self.interpret(f, [0])
assert self.ll_to_string(res) == "ab"
-
+
def g(i):
if i == 1:
return none()
@@ -642,7 +642,7 @@
res = self.interpret(g, [0])
assert self.class_name(res) == 'A'
-
+
def test_conv_from_classpbcset_to_larger(self):
class A(object): pass
class B(A): pass
@@ -652,7 +652,7 @@
return A
def b():
return B
-
+
def g(i):
if i == 1:
@@ -682,10 +682,10 @@
res = self.interpret(g, [0, 0])
assert self.class_name(res) == 'C'
res = self.interpret(g, [0, 1])
- assert self.class_name(res) == 'B'
+ assert self.class_name(res) == 'B'
res = self.interpret(g, [1, 0])
- assert self.class_name(res) == 'A'
-
+ assert self.class_name(res) == 'A'
+
def test_call_starargs(self):
def g(x=-100, *arg):
return x + len(arg)
@@ -849,7 +849,7 @@
return f1
def b():
return f2
-
+
def g(i):
if i == 1:
@@ -932,7 +932,7 @@
class B(A):
def meth(self, a, b=0):
return a+b
-
+
class C(A):
def meth(self, a, b=0):
return a*b
@@ -949,7 +949,7 @@
assert res == 1+3+2+7+11
res = self.interpret(f, [1])
assert res == 3*2+11*7
-
+
def test_multiple_ll_one_hl_op(self):
class E(Exception):
@@ -1609,7 +1609,7 @@
if a.func:
return a.func(n)
return -1
-
+
res = self.interpret(fn, [0])
assert res == -1
@@ -1640,20 +1640,14 @@
res = self.interpret(g, [])
assert res == False
-class TestLLtype(BaseTestRPBC, LLRtypeMixin):
- pass
-
-class TestOOtype(BaseTestRPBC, OORtypeMixin):
- pass
-
# ____________________________________________________________
-class BaseTestRPBCExtra(BaseRtypingTest):
-
+class TestRPBCExtra(BaseRtypingTest):
+
def test_folding_specialize_support(self):
class S(object):
-
+
def w(s, x):
if isinstance(x, int):
return x
@@ -1690,7 +1684,7 @@
return funcdesc.cachedgraph(typ)
p = P()
-
+
res = self.interpret(f, [0, 66], policy=p)
assert res == 0
res = self.interpret(f, [1, 66], policy=p)
@@ -1699,18 +1693,7 @@
assert res == 12
res = self.interpret(f, [3, 5555], policy=p)
assert res == 4
-
-class TestExtraLLtype(BaseTestRPBCExtra, LLRtypeMixin):
- pass
-class TestExtraOOtype(BaseTestRPBCExtra, OORtypeMixin):
- pass
-
-# ____________________________________________________________
-# We don't care about the following test_hlinvoke tests working on
-# ootype. Maybe later. This kind of thing is only used in rdict
-# anyway, that will probably have a different kind of implementation
-# in ootype.
def test_hlinvoke_simple():
def f(a,b):
@@ -1719,8 +1702,8 @@
from rpython.annotator import annrpython
a = annrpython.RPythonAnnotator()
from rpython.annotator import model as annmodel
-
- s_f = a.bookkeeper.immutablevalue(f)
+
+ s_f = a.bookkeeper.immutablevalue(f)
a.bookkeeper.emulate_pbc_call('f', s_f, [annmodel.SomeInteger(), annmodel.SomeInteger()])
a.complete()
@@ -1757,7 +1740,7 @@
from rpython.annotator import annrpython
a = annrpython.RPythonAnnotator()
from rpython.annotator import model as annmodel
-
+
def g(i):
if i:
f = f1
@@ -1765,7 +1748,7 @@
f = f2
f(5,4)
f(3,2)
-
+
a.build_types(g, [int])
from rpython.rtyper import rtyper
@@ -1838,10 +1821,10 @@
s = a.binding(ll_h_graph.getreturnvar())
assert s.ll_ptrtype == A_repr.lowleveltype
rt.specialize_more_blocks()
-
+
from rpython.rtyper.llinterp import LLInterpreter
interp = LLInterpreter(rt)
-
+
#a.translator.view()
c_a = A_repr.convert_const(A(None))
res = interp.eval_graph(ll_h_graph, [None, None, c_a])
@@ -1889,15 +1872,15 @@
s_R = a.bookkeeper.immutablevalue(r_f)
s_ll_f = annmodel.lltype_to_annotation(r_f.lowleveltype)
A_repr = rclass.getinstancerepr(rt, a.bookkeeper.getdesc(A).
- getuniqueclassdef())
+ getuniqueclassdef())
ll_h_graph = annlowlevel.annotate_lowlevel_helper(a, ll_h, [s_R, s_ll_f, annmodel.SomePtr(A_repr.lowleveltype)])
s = a.binding(ll_h_graph.getreturnvar())
assert s.ll_ptrtype == A_repr.lowleveltype
rt.specialize_more_blocks()
- from rpython.rtyper.llinterp import LLInterpreter
+ from rpython.rtyper.llinterp import LLInterpreter
interp = LLInterpreter(rt)
-
+
# low-level value is just the instance
c_f = rclass.getinstancerepr(rt, Impl_def).convert_const(Impl())
c_a = A_repr.convert_const(A(None))
@@ -1951,7 +1934,7 @@
assert s.ll_ptrtype == A_repr.lowleveltype
rt.specialize_more_blocks()
- from rpython.rtyper.llinterp import LLInterpreter
+ from rpython.rtyper.llinterp import LLInterpreter
interp = LLInterpreter(rt)
c_f = r_f.convert_const(i.f)
@@ -1961,7 +1944,7 @@
# ____________________________________________________________
-class TestLLtypeSmallFuncSets(TestLLtype):
+class TestSmallFuncSets(TestRPBC):
def setup_class(cls):
from rpython.config.translationoption import get_combined_translation_config
cls.config = get_combined_translation_config(translating=True)
@@ -1969,7 +1952,7 @@
def interpret(self, fn, args, **kwds):
kwds['config'] = self.config
- return TestLLtype.interpret(self, fn, args, **kwds)
+ return TestRPBC.interpret(self, fn, args, **kwds)
def test_smallfuncsets_basic():
from rpython.translator.translator import TranslationContext, graphof
diff --git a/rpython/rtyper/test/test_rrange.py b/rpython/rtyper/test/test_rrange.py
--- a/rpython/rtyper/test/test_rrange.py
+++ b/rpython/rtyper/test/test_rrange.py
@@ -1,20 +1,21 @@
from rpython.rlib.rarithmetic import intmask
from rpython.rtyper.rrange import ll_rangelen, ll_rangeitem, ll_rangeitem_nonneg, dum_nocheck
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.lltypesystem import rrange
+from rpython.rtyper.test.tool import BaseRtypingTest
-class BaseTestRrange(BaseRtypingTest):
+class TestRrange(BaseRtypingTest):
def test_rlist_range(self):
def test1(start, stop, step, varstep):
expected = range(start, stop, step)
length = len(expected)
if varstep:
- l = self.rrange.ll_newrangest(start, stop, step)
+ l = rrange.ll_newrangest(start, stop, step)
step = l.step
else:
- RANGE = self.rrange.RangeRepr(step).RANGE
- l = self.rrange.ll_newrange(RANGE, start, stop)
+ RANGE = rrange.RangeRepr(step).RANGE
+ l = rrange.ll_newrange(RANGE, start, stop)
assert ll_rangelen(l, step) == length
lst = [ll_rangeitem(dum_nocheck, l, i, step) for i in range(length)]
assert lst == expected
@@ -183,12 +184,3 @@
return 5
res = self.interpret(fn, [1])
assert res == 20
-
-
-
-class TestLLtype(BaseTestRrange, LLRtypeMixin):
- from rpython.rtyper.lltypesystem import rrange
-
-
-class TestOOtype(BaseTestRrange, OORtypeMixin):
- from rpython.rtyper.ootypesystem import rrange
diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py
--- a/rpython/rtyper/test/test_rstr.py
+++ b/rpython/rtyper/test/test_rstr.py
@@ -7,7 +7,7 @@
from rpython.rtyper.lltypesystem.rstr import LLHelpers, STR
from rpython.rtyper.rstr import AbstractLLHelpers
from rpython.rtyper.rtyper import TyperError
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
def test_parse_fmt():
@@ -1073,7 +1073,7 @@
res = interpret(g, [-2])
assert res._obj.value == 42
-class BaseTestRstr(AbstractTestRstr):
+class TestRstr(AbstractTestRstr):
const = str
constchar = chr
@@ -1089,9 +1089,6 @@
for c in ["a", "A", "1"]:
assert self.interpret(fn, [ord(c)]) == c.upper()
-
-class TestLLtype(BaseTestRstr, LLRtypeMixin):
More information about the pypy-commit
mailing list