[pypy-svn] r46285 - in pypy/dist/pypy/translator: cli/test jvm/test oosupport/test_template

antocuni at codespeak.net antocuni at codespeak.net
Mon Sep 3 17:38:59 CEST 2007


Author: antocuni
Date: Mon Sep  3 17:38:59 2007
New Revision: 46285

Added:
   pypy/dist/pypy/translator/oosupport/test_template/class_.py   (contents, props changed)
Modified:
   pypy/dist/pypy/translator/cli/test/test_class.py
   pypy/dist/pypy/translator/jvm/test/test_class.py
Log:
move some tests shared by cli and jvm to oosupport. More jvm tests
pass.



Modified: pypy/dist/pypy/translator/cli/test/test_class.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_class.py	(original)
+++ pypy/dist/pypy/translator/cli/test/test_class.py	Mon Sep  3 17:38:59 2007
@@ -1,69 +1,9 @@
 import py
 from pypy.translator.cli.test.runtest import CliTest
-from pypy.rpython.test.test_rclass import BaseTestRclass
-from pypy.rpython.test.test_rspecialcase import BaseTestRspecialcase
+from pypy.translator.oosupport.test_template.class_ import BaseTestClass, BaseTestSpecialcase
 
-class TestCliClass(CliTest, BaseTestRclass):    
-    def test_abstract_method(self):
-        class Base:
-            pass
-        class A(Base):
-            def f(self, x):
-                return x+1
-        class B(Base):
-            def f(self, x):
-                return x+2
-        def call(obj, x):
-            return obj.f(x)
-        def fn(x):
-            a = A()
-            b = B()
-            return call(a, x) + call(b, x)
-        assert self.interpret(fn, [0]) == 3
-
-    def test_abstract_method2(self):
-        class Root:
-            pass
-        class Class1(Root):
-            pass
-        class Derived(Class1):
-            x = 1
-        class Class2(Root):
-            x = 2
-        def get_x(obj):
-            return obj.x
-        def fn():
-            a = Derived()
-            b = Class2()
-            return get_x(a) + get_x(b)
-        assert self.interpret(fn, []) == 3
-
-    def test_same_name(self):
-        class A:
-            def __init__(self, x):
-                self.x = x
-        B=A
-        class A:
-            def __init__(self, y):
-                self.y = y
-        assert A is not B
-        assert A.__name__ == B.__name__
-        def fn(x, y):
-            obj1 = B(x)
-            obj2 = A(y)
-            return obj1.x + obj2.y
-        assert self.interpret(fn, [1, 2]) == 3
-
-    def test_ctr_location(self):
-        class A:
-            _annspecialcase_ = "specialize:ctr_location"
-            def __init__(self, x):
-                self.x = x
-        def fn(x, y):
-            a = A(x)
-            b = A(y)
-            return a.x + b.x
-        assert self.interpret(fn, [1, 2]) == 3
+class TestCliClass(CliTest, BaseTestClass):    
+    pass
 
-class TestCliSpecialCase(CliTest, BaseTestRspecialcase):
+class TestCliSpecialCase(CliTest, BaseTestSpecialcase):
     pass

Modified: pypy/dist/pypy/translator/jvm/test/test_class.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/test/test_class.py	(original)
+++ pypy/dist/pypy/translator/jvm/test/test_class.py	Mon Sep  3 17:38:59 2007
@@ -1,52 +1,10 @@
 import py
 from pypy.translator.jvm.test.runtest import JvmTest
-from pypy.rpython.test.test_rclass import BaseTestRclass
-from pypy.rpython.test.test_rspecialcase import BaseTestRspecialcase
+from pypy.translator.oosupport.test_template.class_ import BaseTestClass, BaseTestSpecialcase
 
-class TestJvmClass(JvmTest, BaseTestRclass):    
+class TestJvmClass(JvmTest, BaseTestClass):    
     def test_overridden_classattr_as_defaults(self):
         py.test.skip("JVM doesn't support overridden default value yet")
 
-    def test_abstract_method(self):
-        class Base(object):
-            pass
-        class A(Base):
-            def f(self, x):
-                return x+1
-        class B(Base):
-            def f(self, x):
-                return x+2
-        def call(obj, x):
-            return obj.f(x)
-        def fn(x):
-            a = A()
-            b = B()
-            return call(a, x) + call(b, x)
-        assert self.interpret(fn, [0]) == 3
-
-    def test_abstract_method2(self):
-        class Root(object):
-            pass
-        class Class1(Root):
-            pass
-        class Derived(Class1):
-            x = 1
-        class Class2(Root):
-            x = 2
-        def get_x(obj):
-            return obj.x
-        def fn():
-            derived = Derived()
-            cls2 = Class2()
-            return get_x(derived) + get_x(cls2)
-        assert self.interpret(fn, []) == 3
-
-    def test_same_name(self):
-        py.test.skip("JVM doesn't support classes with the same name")
-
-    def test_ctr_location(self):
-        py.test.skip("Ask cuni if this applies to JVM -I don't think so")
-
-
-#class TestCliSpecialCase(CliTest, BaseTestRspecialcase):
-#    pass
+class TestJvmSpecialCase(JvmTest, BaseTestSpecialcase):
+    pass

Added: pypy/dist/pypy/translator/oosupport/test_template/class_.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/oosupport/test_template/class_.py	Mon Sep  3 17:38:59 2007
@@ -0,0 +1,68 @@
+import py
+from pypy.rpython.test.test_rclass import BaseTestRclass
+from pypy.rpython.test.test_rspecialcase import BaseTestRspecialcase
+
+class BaseTestClass(BaseTestRclass):    
+    def test_abstract_method(self):
+        class Base:
+            pass
+        class A(Base):
+            def f(self, x):
+                return x+1
+        class B(Base):
+            def f(self, x):
+                return x+2
+        def call(obj, x):
+            return obj.f(x)
+        def fn(x):
+            a = A()
+            b = B()
+            return call(a, x) + call(b, x)
+        assert self.interpret(fn, [0]) == 3
+
+    def test_abstract_method2(self):
+        class Root:
+            pass
+        class Class1(Root):
+            pass
+        class Derived(Class1):
+            x = 1
+        class Class2(Root):
+            x = 2
+        def get_x(obj):
+            return obj.x
+        def fn():
+            a = Derived()
+            b = Class2()
+            return get_x(a) + get_x(b)
+        assert self.interpret(fn, []) == 3
+
+    def test_same_name(self):
+        class A:
+            def __init__(self, x):
+                self.x = x
+        B=A
+        class A:
+            def __init__(self, y):
+                self.y = y
+        assert A is not B
+        assert A.__name__ == B.__name__
+        def fn(x, y):
+            obj1 = B(x)
+            obj2 = A(y)
+            return obj1.x + obj2.y
+        assert self.interpret(fn, [1, 2]) == 3
+
+    def test_ctr_location(self):
+        class A:
+            _annspecialcase_ = "specialize:ctr_location"
+            def __init__(self, x):
+                self.x = x
+        def fn(x, y):
+            a = A(x)
+            b = A(y)
+            return a.x + b.x
+        assert self.interpret(fn, [1, 2]) == 3
+
+class BaseTestSpecialcase(BaseTestRspecialcase):
+    pass



More information about the Pypy-commit mailing list