import unittest
import cStringIO
import sys
from util import eval_code

class test_opcodes_binary(unittest.TestCase):
    def test_binary_math_opcodes(self):
        self.failUnless(eval_code("1+3","4\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("4L-1","3L\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("10/2","5\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("10*2.0", "20.0\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("(1+2)/(7*3)-2L", "-2L\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("15//4","3\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("100%30","10\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("20<<20","20971520\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("20>>2","5\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("1221 & 2112","64\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("1221 ^ 2112","3205\n",title="test_opcodes_binary"))
        self.failUnless(eval_code("1221 | 2112", "3269\n",title="test_opcodes_binary"))

if __name__ == "__main__":
    unittest.main()

