diff --git a/tests/compiled/conditional_expressions.3.1.pyc b/tests/compiled/conditional_expressions.3.1.pyc new file mode 100644 index 0000000..4526bd5 Binary files /dev/null and b/tests/compiled/conditional_expressions.3.1.pyc differ diff --git a/tests/compiled/conditional_expressions_py2.2.7.pyc b/tests/compiled/conditional_expressions_py2.2.7.pyc new file mode 100644 index 0000000..72c8187 Binary files /dev/null and b/tests/compiled/conditional_expressions_py2.2.7.pyc differ diff --git a/tests/input/conditional_expressions_py2.py b/tests/input/conditional_expressions_py2.py new file mode 100644 index 0000000..a8c5f5d --- /dev/null +++ b/tests/input/conditional_expressions_py2.py @@ -0,0 +1,44 @@ +import sys + +a = 1 +result = 'even' if a % 2 == 0 else 'odd' +print result +# odd + +a = 2 +result = 'even' if a % 2 == 0 else 'odd' +print result +# even + +a = 1 +result = a * 2 if a % 2 == 0 else a * 3 +print result +# 3 + +a = 2 +result = a * 2 if a % 2 == 0 else a * 3 +print result +# 4 + +a = 1 +sys.stdout.write('even\n') if a % 2 == 0 else sys.stdout.write('odd\n') +# odd + +a = 1 + +if a % 2 == 0: + print 'even' +else: + print 'odd' +# odd + +a = -2 +result = 'negative and even' if a < 0 and a % 2 == 0 else 'positive or odd' +print result +# negative and even + +a = -1 +result = 'negative and even' if a < 0 and a % 2 == 0 else 'positive or odd' +print result +# positive or odd + diff --git a/tests/tokenized/conditional_expressions_py2.txt b/tests/tokenized/conditional_expressions_py2.txt new file mode 100644 index 0000000..ac637cc --- /dev/null +++ b/tests/tokenized/conditional_expressions_py2.txt @@ -0,0 +1,30 @@ +import sys +a = 1 +result = 'even' if a % 2 == 0 else 'odd' +print result +a = 2 +result = 'even' if a % 2 == 0 else 'odd' +print result +a = 1 +result = a * 2 if a % 2 == 0 else a * 3 +print result +a = 2 +result = a * 2 if a % 2 == 0 else a * 3 +print result +a = 1 +sys . stdout . write ( 'even\n' ) if a % 2 == 0 else sys . stdout . write ( 'odd\n' ) +a = 1 +if a % 2 == 0 : + +print 'even' + +else : + +print 'odd' + +a = - 2 +result = 'negative and even' if a < 0 and a % 2 == 0 else 'positive or odd' +print result +a = - 1 +result = 'negative and even' if a < 0 and a % 2 == 0 else 'positive or odd' +print result