# Copyright 2006-2007 Grant T. Olson.
# See LICENSE for terms.
import unittest
from compyler.test.util import eval_code

stmts = [
# if equal
    ("""

if 1 == 0:
    print "TRUE"
else:
    print "FALSE"

print "DONE"

""","""FALSE\nDONE\n"""),

# if not equal

("""

if 1 != 0:
    print "TRUE"
else:
    print "FALSE"

print "DONE"

""","""TRUE\nDONE\n"""),

#case

("""

a = 3

if a == 1:
    print 1
elif a == 2:
    print 2
elif a == 3:
    print 3
else:
    print "WHAT?"

print "DONE"    
""","""3\nDONE\n"""),

#no else
("""

if 1 != 0:
    print "TRUE"

print "DONE"

""","""TRUE\nDONE\n"""),

]


class test_opcodes_conditional(unittest.TestCase):
    def test_if_statements(self):
        for stmt in stmts:
            self.failUnless(eval_code(stmt[0],stmt[1],"exec",title='test_opcodes_conds'))
                
if __name__ == "__main__":
    unittest.main()

