several test cases for ticket 145
authorStefan Behnel <scoder@users.berlios.de>
Tue, 4 May 2010 12:12:54 +0000 (14:12 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 4 May 2010 12:12:54 +0000 (14:12 +0200)
tests/bugs.txt
tests/run/bint_binop_T145.pyx [new file with mode: 0644]

index 06fe279a9c59b865514dbbecdd72e9608ab6b952..c75f5e71bce4f24c492986120209a427ae580af5 100644 (file)
@@ -9,7 +9,8 @@ missing_baseclass_in_predecl_T262
 cfunc_call_tuple_args_T408
 cascaded_list_unpacking_T467
 compile.cpp_operators
+bint_binop_T145
 
-# Pyrex regression tests that don't current work:
+# CPython regression tests that don't current work:
 pyregr.test_threadsignals
 pyregr.test_module
diff --git a/tests/run/bint_binop_T145.pyx b/tests/run/bint_binop_T145.pyx
new file mode 100644 (file)
index 0000000..c23232a
--- /dev/null
@@ -0,0 +1,106 @@
+
+def or_literal_bint():
+    """
+    >>> True or 5
+    True
+    >>> or_literal_bint()
+    True
+    """
+    return True or 5
+
+def and_literal_bint():
+    """
+    >>> 5 and True
+    True
+    >>> and_literal_bint()
+    True
+    """
+    return 5 and True
+
+def False_and_True_or_0():
+    """
+    >>> False and True or 0
+    0
+    >>> False_and_True_or_0()
+    0
+    """
+    return False and True or 0
+
+def True_and_True_or_0():
+    """
+    >>> True and True or 0
+    True
+    >>> True_and_True_or_0()
+    True
+    """
+    return True and True or 0
+
+def x_and_True_or_False(x):
+    """
+    >>> x_and_True_or_False(0)
+    False
+    >>> x_and_True_or_False(1)
+    True
+    >>> x_and_True_or_False('abc')
+    True
+    >>> x_and_True_or_False([])
+    False
+    """
+    return x and True or False
+
+def x_and_True_or_0(x):
+    """
+    >>> 0 and True or 0
+    0
+    >>> x_and_True_or_0(0)
+    0
+
+    >>> 1 and True or 0
+    True
+    >>> x_and_True_or_0(1)
+    True
+
+    >>> x_and_True_or_0('abc')
+    True
+    >>> x_and_True_or_0([])
+    0
+    """
+    return x and True or 0
+
+def x_and_True_or_1(x):
+    """
+    >>> 0 and True or 1
+    1
+    >>> x_and_True_or_1(0)
+    1
+
+    >>> 1 and True or 1
+    True
+    >>> x_and_True_or_1(1)
+    True
+
+    >>> x_and_True_or_1('abc')
+    True
+    >>> x_and_True_or_1([])
+    1
+    """
+    return x and True or 1
+
+def x_and_1_or_False(x):
+    """
+    >>> 0 and 1 or False
+    False
+    >>> x_and_1_or_False(0)
+    False
+
+    >>> 1 and 1 or False
+    1
+    >>> x_and_1_or_False(1)
+    1
+
+    >>> x_and_1_or_False('abc')
+    1
+    >>> x_and_1_or_False([])
+    False
+    """
+    return x and 1 or False