From: Stefan Behnel Date: Sat, 23 Feb 2013 10:36:26 +0000 (+0100) Subject: add constant folding tests for bool values X-Git-Tag: 0.19b1~126^2~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7da7092980f44fb1b423b91ba78c975f31a8d0e;p=platform%2Fupstream%2Fpython-cython.git add constant folding tests for bool values --- diff --git a/tests/run/constant_folding.py b/tests/run/constant_folding.py index f3ca3bc..7845a52 100644 --- a/tests/run/constant_folding.py +++ b/tests/run/constant_folding.py @@ -11,14 +11,16 @@ import cython def unop_floats(): """ >>> unop_floats() - (1.0, -1.0, 1.0, -1.0, -1.0) + (False, 2.0, -2.0, False, 2.0, -2.0, -2.0) """ - plus1 = + 1.0 - minus1 = - 1.0 - plus3 = +++ 1.0 - minus3 = --- 1.0 - mix = +-++-- 1.0 - return plus1, minus1, plus3, minus3, mix + not1 = not 2.0 + plus1 = + 2.0 + minus1 = - 2.0 + not3 = not not not 2.0 + plus3 = +++ 2.0 + minus3 = --- 2.0 + mix = +-++-- 2.0 + return not1, plus1, minus1, not3, plus3, minus3, mix @cython.test_fail_if_path_exists( @@ -28,11 +30,33 @@ def unop_floats(): def unop_ints(): """ >>> unop_ints() - (1, -1, 1, -1, -1) + (False, 2, -2, False, 2, -2, -2) """ - plus1 = + 1 - minus1 = - 1 - plus3 = +++ 1 - minus3 = --- 1 - mix = +-++-- 1 - return plus1, minus1, plus3, minus3, mix + not1 = not 2 + plus1 = + 2 + minus1 = - 2 + not3 = not not not 2 + plus3 = +++ 2 + minus3 = --- 2 + mix = +-++-- 2 + return not1, plus1, minus1, not3, plus3, minus3, mix + + +@cython.test_fail_if_path_exists( + "//UnaryMinusNode", + "//UnaryPlusNode", + "//NotNode", +) +def unop_bool(): + """ + >>> unop_bool() + (False, 1, -1, False, 1, -1, -1) + """ + not1 = not True + plus1 = + True + minus1 = - True + not3 = not not not True + plus3 = +++ True + minus3 = --- True + mix = +-++-- True + return not1, plus1, minus1, not3, plus3, minus3, mix