C++ namespace tests.
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 27 Aug 2010 07:43:25 +0000 (00:43 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 27 Aug 2010 07:43:25 +0000 (00:43 -0700)
tests/run/cpp_namespaces.pyx [new file with mode: 0644]
tests/run/cpp_namespaces_helper.h [new file with mode: 0644]

diff --git a/tests/run/cpp_namespaces.pyx b/tests/run/cpp_namespaces.pyx
new file mode 100644 (file)
index 0000000..e76a1d0
--- /dev/null
@@ -0,0 +1,28 @@
+cdef extern from "cpp_namespaces_helper.h" namespace "A":
+    ctypedef int A_t
+    A_t A_func(A_t first, A_t)
+
+cdef extern from "cpp_namespaces_helper.h" namespace "outer":
+    int outer_value
+
+cdef extern from "cpp_namespaces_helper.h" namespace "outer::inner":
+    int inner_value
+
+def test_function(x, y):
+    """
+    >>> test_function(1, 2)
+    3
+    >>> test_function(9, 16)
+    25
+    """
+    return A_func(x, y)
+
+def test_nested():
+    """
+    >>> test_nested()
+    10
+    100
+    """
+    print outer_value
+    print inner_value
+
diff --git a/tests/run/cpp_namespaces_helper.h b/tests/run/cpp_namespaces_helper.h
new file mode 100644 (file)
index 0000000..1a7f8ac
--- /dev/null
@@ -0,0 +1,25 @@
+namespace outer {
+    
+    int x = 10;
+    
+    int outer_value = 10;
+    
+    namespace inner {
+        
+        int x = 100;
+        
+        int inner_value = 100;
+        
+    }
+    
+}
+
+namespace A {
+    
+    typedef int A_t;
+    
+    A_t A_func(A_t first, A_t second) {
+        return first + second;
+    }
+    
+}