[pypy-commit] pypy default: Add test for an invariant that typeOf() and .convert_const() should obey
rlamy
noreply at buildbot.pypy.org
Thu Apr 9 14:07:32 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r76754:14453a4c1b2b
Date: 2015-04-09 13:07 +0100
http://bitbucket.org/pypy/pypy/changeset/14453a4c1b2b/
Log: Add test for an invariant that typeOf() and .convert_const() should
obey
diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py b/rpython/rtyper/lltypesystem/test/test_lltype.py
--- a/rpython/rtyper/lltypesystem/test/test_lltype.py
+++ b/rpython/rtyper/lltypesystem/test/test_lltype.py
@@ -1,9 +1,11 @@
-from __future__ import with_statement
import py
+import sys
from rpython.rtyper.lltypesystem.lltype import *
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.tool.identity_dict import identity_dict
from rpython.tool import leakfinder
+from rpython.annotator.annrpython import RPythonAnnotator
+from rpython.rtyper.rtyper import RPythonTyper
def isweak(p, T):
try:
@@ -539,6 +541,24 @@
assert S == Sprime
+class Frozen(object):
+ def _freeze_(self):
+ return True
+
+ at py.test.mark.parametrize('x', [
+ 1, sys.maxint, 1.5, 'a', 'abc', u'abc', None, [],
+ py.test.mark.xfail(lambda: None),
+ {1.23: 'abc'},
+ (1, 'x', [2, 3.],),
+ py.test.mark.xfail(Frozen()),])
+def test_typeOf_const(x):
+ a = RPythonAnnotator()
+ bk = a.bookkeeper
+ rtyper = RPythonTyper(a)
+ s_x = bk.immutablevalue(x)
+ r_x = rtyper.getrepr(s_x)
+ assert typeOf(r_x.convert_const(x)) == r_x.lowleveltype
+
def test_cast_primitive():
cases = [
(Float, 1, 1.0),
More information about the pypy-commit
mailing list