short circut bug test #404
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 15 Oct 2009 10:01:39 +0000 (03:01 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 15 Oct 2009 10:01:39 +0000 (03:01 -0700)
tests/run/short_circuit_T404.pyx [new file with mode: 0644]

diff --git a/tests/run/short_circuit_T404.pyx b/tests/run/short_circuit_T404.pyx
new file mode 100644 (file)
index 0000000..7ef2105
--- /dev/null
@@ -0,0 +1,41 @@
+cdef long foo(long x):
+    print "foo(%s)" % x
+    return x
+
+def test_or(long a, long b):
+    """
+    >>> test_or(1,2)
+    foo(1)
+    True
+    >>> test_or(1,0)
+    foo(1)
+    True
+    >>> test_or(0,2)
+    foo(0)
+    foo(2)
+    True
+    >>> test_or(0,0)
+    foo(0)
+    foo(0)
+    False
+    """
+    print foo(a) or foo(b)
+
+def test_and(long a, long b):
+    """
+    >>> test_and(1,2)
+    foo(1)
+    foo(2)
+    True
+    >>> test_and(1,0)
+    foo(1)
+    foo(0)
+    False
+    >>> test_and(0,2)
+    foo(0)
+    False
+    >>> test_and(0,0)
+    foo(0)
+    False
+    """
+    print foo(a) and foo(b)