[pypy-commit] pypy reflex-support: test to make sure type(this) is checked properly

wlav noreply at buildbot.pypy.org
Sat Feb 11 01:37:57 CET 2012


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r52363:926ef9bae484
Date: 2012-02-10 11:39 -0800
http://bitbucket.org/pypy/pypy/changeset/926ef9bae484/

Log:	test to make sure type(this) is checked properly

diff --git a/pypy/module/cppyy/test/fragile.h b/pypy/module/cppyy/test/fragile.h
--- a/pypy/module/cppyy/test/fragile.h
+++ b/pypy/module/cppyy/test/fragile.h
@@ -5,6 +5,7 @@
 class A {
 public:
     virtual int check() { return (int)'A'; }
+    virtual A* gime_null() { return (A*)0; }
 };
 
 class B {
diff --git a/pypy/module/cppyy/test/test_fragile.py b/pypy/module/cppyy/test/test_fragile.py
--- a/pypy/module/cppyy/test/test_fragile.py
+++ b/pypy/module/cppyy/test/test_fragile.py
@@ -106,3 +106,22 @@
         raises(TypeError, cppyy.addressof, 0)
         raises(TypeError, cppyy.addressof, 1)
         raises(TypeError, cppyy.addressof, None)
+
+    def test06_wrong_this(self):
+        """Test that using an incorrect self argument raises"""
+
+        import cppyy
+
+        assert cppyy.gbl.fragile == cppyy.gbl.fragile
+        fragile = cppyy.gbl.fragile
+
+        a = fragile.A()
+        assert fragile.A.check(a) == ord('A')
+
+        b = fragile.B()
+        assert fragile.B.check(b) == ord('B')
+        raises(TypeError, fragile.A.check, b)
+        raises(TypeError, fragile.B.check, a)
+
+        assert isinstance(a.gime_null(), fragile.A)
+        raises(ReferenceError, fragile.A.check, a.gime_null())


More information about the pypy-commit mailing list