new test for pointer operations
authorStefan Behnel <scoder@users.berlios.de>
Wed, 5 May 2010 19:53:25 +0000 (21:53 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 5 May 2010 19:53:25 +0000 (21:53 +0200)
tests/run/pointers.pyx [new file with mode: 0644]

diff --git a/tests/run/pointers.pyx b/tests/run/pointers.pyx
new file mode 100644 (file)
index 0000000..384e5d1
--- /dev/null
@@ -0,0 +1,49 @@
+
+cdef char* c_string = b'abcdefg'
+cdef void* void_ptr = c_string
+
+def compare():
+    """
+    >>> compare()
+    True
+    True
+    True
+    False
+    False
+    """
+    print c_string == c_string
+    print c_string == void_ptr
+    print c_string is void_ptr
+    print c_string != void_ptr
+    print c_string is not void_ptr
+
+def if_tests():
+    """
+    >>> if_tests()
+    True
+    """
+    if c_string == void_ptr:
+        print True
+    if c_string != void_ptr:
+        print False
+
+def bool_binop():
+    """
+    >>> bool_binop()
+    True
+    """
+    if c_string == void_ptr and c_string == c_string:
+        print True
+
+def bool_binop_truth(int x):
+    """
+    >>> bool_binop_truth(1)
+    True
+    True
+    >>> bool_binop_truth(0)
+    True
+    """
+    if c_string and void_ptr and c_string == c_string:
+        print True
+    if c_string and x or not void_ptr or x:
+        print True