From 819991ce3ba9ef4fad8621626ee109677c2b5b64 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 4 May 2010 14:12:54 +0200 Subject: [PATCH] several test cases for ticket 145 --- tests/bugs.txt | 3 +- tests/run/bint_binop_T145.pyx | 106 ++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 tests/run/bint_binop_T145.pyx diff --git a/tests/bugs.txt b/tests/bugs.txt index 06fe279a..c75f5e71 100644 --- a/tests/bugs.txt +++ b/tests/bugs.txt @@ -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 index 00000000..c23232a8 --- /dev/null +++ b/tests/run/bint_binop_T145.pyx @@ -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 -- 2.26.2