From 0eedf9cbd04be8b83a5663a751548bd072cc9efa Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 4 Dec 2008 21:08:14 +0100 Subject: [PATCH] same test for 'and' operator --- tests/run/and.pyx | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/run/and.pyx diff --git a/tests/run/and.pyx b/tests/run/and.pyx new file mode 100644 index 00000000..86165930 --- /dev/null +++ b/tests/run/and.pyx @@ -0,0 +1,51 @@ +u""" +>>> a,b = 'a *','b *' # use non-interned strings + +>>> and2_assign(2,3) == (2 and 3) +True +>>> and2_assign('a', 'b') == ('a' and 'b') +True +>>> and2_assign(a, b) == (a and b) +True + +>>> and2(2,3) == (2 and 3) +True +>>> and2(0,2) == (0 and 2) +True +>>> and2('a', 'b') == ('a' and 'b') +True +>>> and2(a, b) == (a and b) +True +>>> and2('', 'b') == ('' and 'b') +True +>>> and2([], [1]) == ([] and [1]) +True +>>> and2([], [a]) == ([] and [a]) +True + +>>> and3(0,1,2) == (0 and 1 and 2) +True +>>> and3([],(),[1]) == ([] and () and [1]) +True + +>>> and2_no_result(2,3) +>>> and2_no_result(0,2) +>>> and2_no_result('a','b') +>>> and2_no_result(a,b) +>>> a and b +'b *' +""" + +def and2_assign(a,b): + c = a and b + return c + +def and2(a,b): + return a and b + +def and3(a,b,c): + d = a and b and c + return d + +def and2_no_result(a,b): + a and b -- 2.26.2