Add additional versions of conditional_expressions test
This commit is contained in:
BIN
tests/compiled/conditional_expressions.3.1.pyc
Normal file
BIN
tests/compiled/conditional_expressions.3.1.pyc
Normal file
Binary file not shown.
BIN
tests/compiled/conditional_expressions_py2.2.7.pyc
Normal file
BIN
tests/compiled/conditional_expressions_py2.2.7.pyc
Normal file
Binary file not shown.
44
tests/input/conditional_expressions_py2.py
Normal file
44
tests/input/conditional_expressions_py2.py
Normal file
@@ -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
|
||||
|
30
tests/tokenized/conditional_expressions_py2.txt
Normal file
30
tests/tokenized/conditional_expressions_py2.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
import sys <EOL>
|
||||
a = 1 <EOL>
|
||||
result = 'even' if a % 2 == 0 else 'odd' <EOL>
|
||||
print result <EOL>
|
||||
a = 2 <EOL>
|
||||
result = 'even' if a % 2 == 0 else 'odd' <EOL>
|
||||
print result <EOL>
|
||||
a = 1 <EOL>
|
||||
result = a * 2 if a % 2 == 0 else a * 3 <EOL>
|
||||
print result <EOL>
|
||||
a = 2 <EOL>
|
||||
result = a * 2 if a % 2 == 0 else a * 3 <EOL>
|
||||
print result <EOL>
|
||||
a = 1 <EOL>
|
||||
sys . stdout . write ( 'even\n' ) if a % 2 == 0 else sys . stdout . write ( 'odd\n' ) <EOL>
|
||||
a = 1 <EOL>
|
||||
if a % 2 == 0 : <EOL>
|
||||
<INDENT>
|
||||
print 'even' <EOL>
|
||||
<OUTDENT>
|
||||
else : <EOL>
|
||||
<INDENT>
|
||||
print 'odd' <EOL>
|
||||
<OUTDENT>
|
||||
a = - 2 <EOL>
|
||||
result = 'negative and even' if a < 0 and a % 2 == 0 else 'positive or odd' <EOL>
|
||||
print result <EOL>
|
||||
a = - 1 <EOL>
|
||||
result = 'negative and even' if a < 0 and a % 2 == 0 else 'positive or odd' <EOL>
|
||||
print result <EOL>
|
Reference in New Issue
Block a user