summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-11-15 16:48:29 +1100
committerDamien George <damien.p.george@gmail.com>2016-11-15 16:48:49 +1100
commit30bca45e1ac9fc6953728950695135b491403215 (patch)
tree285b1abb15f73b2db34869000a3e9a57c573d8b4
parent9b525134d1bf5b3f05b39fe90ddaa4bd33ea3e0d (diff)
tests/basics: Add test for logical constant folding.
-rw-r--r--tests/basics/logic_constfolding.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/basics/logic_constfolding.py b/tests/basics/logic_constfolding.py
new file mode 100644
index 000000000..14afe6111
--- /dev/null
+++ b/tests/basics/logic_constfolding.py
@@ -0,0 +1,26 @@
+# tests logical constant folding in parser
+
+def f_true():
+ print('f_true')
+ return True
+
+def f_false():
+ print('f_false')
+ return False
+
+print(0 or False)
+print(1 or foo)
+print(f_false() or 1 or foo)
+print(f_false() or 1 or f_true())
+
+print(0 and foo)
+print(1 and True)
+print(f_true() and 0 and foo)
+print(f_true() and 1 and f_false())
+
+print(not 0)
+print(not False)
+print(not 1)
+print(not True)
+print(not not 0)
+print(not not 1)