[pypy-commit] pypy reflex-support: test that a trailing underscore is allowed in class names

wlav noreply at buildbot.pypy.org
Thu Aug 18 01:20:07 CEST 2011


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r46583:249d77dbfa51
Date: 2011-08-17 15:50 -0700
http://bitbucket.org/pypy/pypy/changeset/249d77dbfa51/

Log:	test that a trailing underscore is allowed in class names

diff --git a/pypy/module/cppyy/test/example01.cxx b/pypy/module/cppyy/test/example01.cxx
--- a/pypy/module/cppyy/test/example01.cxx
+++ b/pypy/module/cppyy/test/example01.cxx
@@ -135,3 +135,7 @@
 int ns_example01::globalAddOneToInt(int a) {
    return ::globalAddOneToInt(a);
 }
+
+
+// special case naming
+z_& z_::gime_z_(z_& z) { return z; }
diff --git a/pypy/module/cppyy/test/example01.h b/pypy/module/cppyy/test/example01.h
--- a/pypy/module/cppyy/test/example01.h
+++ b/pypy/module/cppyy/test/example01.h
@@ -58,3 +58,11 @@
 namespace ns_example01 {
     int globalAddOneToInt(int a);
 }
+
+
+// special case naming
+class z_ {
+public:
+   z_& gime_z_(z_& z);
+   int myint;
+};
diff --git a/pypy/module/cppyy/test/example01.xml b/pypy/module/cppyy/test/example01.xml
--- a/pypy/module/cppyy/test/example01.xml
+++ b/pypy/module/cppyy/test/example01.xml
@@ -2,6 +2,7 @@
 
   <class name="payload" />
   <class name="example01" />
+  <class name="z_" />
 
   <function name="globalAddOneToInt" />
 
diff --git a/pypy/module/cppyy/test/example01_LinkDef.h b/pypy/module/cppyy/test/example01_LinkDef.h
--- a/pypy/module/cppyy/test/example01_LinkDef.h
+++ b/pypy/module/cppyy/test/example01_LinkDef.h
@@ -6,5 +6,6 @@
 
 #pragma link C++ class example01;
 #pragma link C++ class payload;
+#pragma link C++ class z_;
 
 #endif
diff --git a/pypy/module/cppyy/test/test_pythonify.py b/pypy/module/cppyy/test/test_pythonify.py
--- a/pypy/module/cppyy/test/test_pythonify.py
+++ b/pypy/module/cppyy/test/test_pythonify.py
@@ -201,6 +201,8 @@
         assert cppyy.gbl.ns_example01.globalAddOneToInt(4) == 5
 
     def test09_memory(self):
+        """Test proper C++ destruction by the garbage collector"""
+
         import cppyy, gc
         example01_class = cppyy.gbl.example01
         payload_class = cppyy.gbl.payload
@@ -240,3 +242,16 @@
         assert payload_class.count == 0
 
         # TODO: need ReferenceError on touching pl_a
+
+    def test10_underscore_in_class_name(self):
+        """Test recognition of '_' as part of a valid class name"""
+
+        import cppyy
+
+        assert cppyy.gbl.z_ == cppyy.gbl.z_
+
+        z = cppyy.gbl.z_()
+
+        assert hasattr(z, 'myint')
+        assert z.gime_z_(z)
+


More information about the pypy-commit mailing list