[pypy-svn] r28388 - pypy/dist/pypy/rpython/test

antocuni at codespeak.net antocuni at codespeak.net
Tue Jun 6 16:19:40 CEST 2006


Author: antocuni
Date: Tue Jun  6 16:19:39 2006
New Revision: 28388

Modified:
   pypy/dist/pypy/rpython/test/test_rconstantdict.py
Log:
More ootypesystem tests. At the moment one is actually skipping
because ootypesystem still misses support for r_dict constants.



Modified: pypy/dist/pypy/rpython/test/test_rconstantdict.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rconstantdict.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rconstantdict.py	Tue Jun  6 16:19:39 2006
@@ -1,60 +1,70 @@
 import py
-from pypy.rpython.test.test_llinterp import interpret
 from pypy.rpython.objectmodel import r_dict
+from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
 
-def test_constant_int_dict(): 
-    d = {1: 2, 2: 3, 3: 4} 
-    def func(i): 
-        return d[i]
-    res = interpret(func, [3])
-    assert res == 4
-
-def test_constantdict_contains():
-    d = {1: True, 4: True, 16: True}
-    def func(i):
-        return i in d
-    res = interpret(func, [15])
-    assert res is False
-    res = interpret(func, [4])
-    assert res is True
-
-def test_constantdict_get():
-    d = {1: -11, 4: -44, 16: -66}
-    def func(i, j):
-        return d.get(i, j)
-    res = interpret(func, [15, 62])
-    assert res == 62
-    res = interpret(func, [4, 25])
-    assert res == -44
-
-def test_unichar_dict():
-    d = {u'a': 5, u'b': 123, u'?': 321}
-    def func(i):
-        return d[unichr(i)]
-    res = interpret(func, [97])
-    assert res == 5
-    res = interpret(func, [98])
-    assert res == 123
-    res = interpret(func, [63])
-    assert res == 321
-
-def test_constant_r_dict():
-    def strange_key_eq(key1, key2):
-        return key1[0] == key2[0]   # only the 1st character is relevant
-    def strange_key_hash(key):
-        return ord(key[0])
-
-    d = r_dict(strange_key_eq, strange_key_hash)
-    d['hello'] = 42
-    d['world'] = 43
-    for x in range(65, 91):
-        d[chr(x)] = x*x
-    def func(i):
-        return d[chr(i)]
-    res = interpret(func, [ord('h')])
-    assert res == 42
-    res = interpret(func, [ord('w')])
-    assert res == 43
-    for x in range(65, 91):
-        res = interpret(func, [x])
-        assert res == x*x
+class BaseTestRconstantdict(BaseRtypingTest):
+
+    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
+
+    def test_constantdict_contains(self):
+        d = {1: True, 4: True, 16: True}
+        def func(i):
+            return i in d
+        res = self.interpret(func, [15])
+        assert res is False
+        res = self.interpret(func, [4])
+        assert res is True
+
+    def test_constantdict_get(self):
+        d = {1: -11, 4: -44, 16: -66}
+        def func(i, j):
+            return d.get(i, j)
+        res = self.interpret(func, [15, 62])
+        assert res == 62
+        res = self.interpret(func, [4, 25])
+        assert res == -44
+
+    def test_unichar_dict(self):
+        d = {u'a': 5, u'b': 123, u'?': 321}
+        def func(i):
+            return d[unichr(i)]
+        res = self.interpret(func, [97])
+        assert res == 5
+        res = self.interpret(func, [98])
+        assert res == 123
+        res = self.interpret(func, [63])
+        assert res == 321
+
+    def test_constant_r_dict(self):
+        self._skip_oo('constant r_dict')
+        def strange_key_eq(key1, key2):
+            return key1[0] == key2[0]   # only the 1st character is relevant
+        def strange_key_hash(key):
+            return ord(key[0])
+
+        d = r_dict(strange_key_eq, strange_key_hash)
+        d['hello'] = 42
+        d['world'] = 43
+        for x in range(65, 91):
+            d[chr(x)] = x*x
+        def func(i):
+            return d[chr(i)]
+        res = self.interpret(func, [ord('h')])
+        assert res == 42
+        res = self.interpret(func, [ord('w')])
+        assert res == 43
+        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



More information about the Pypy-commit mailing list