Ejemplo n.º 1
0
 def test_assignment_visa_variabel(self):
     line = "3 = a"
     line1 = "a"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     wtok1 = TokenizeWrapper(line1)
     self.assertEqual( my_calculator.assignment(wtok1) , 3 )
Ejemplo n.º 2
0
 def test_assignment_full(self):
     line = "(2=x) + (3=y=z) = a"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual(my_calculator.vardict.get('x') , 2 )
     self.assertEqual(my_calculator.vardict.get('y') , 3 )
     self.assertEqual(my_calculator.vardict.get('z') , 3 )
     self.assertEqual(my_calculator.vardict.get('a') , 5 )
Ejemplo n.º 3
0
 def test_assignment_two_equal_vars(self):
     line = "(2=x=y)"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual(my_calculator.vardict.get('x') , 2 )
     self.assertEqual(my_calculator.vardict.get('y') , 2 )
Ejemplo n.º 4
0
 def test_assignment_parantes(self):
     line = "(3 = z)"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual( my_calculator.vardict.get('z') , 3 )
Ejemplo n.º 5
0
 def test_assignment_inget_lika_med(self):
     line = "1 - (5 - 2*2)/(1+1) - (-2 + 1)"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual(result , 1.5 )        
Ejemplo n.º 6
0
 def test_assignment_z(self):
     line = "1 + 2 + 3 = z"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual( my_calculator.vardict.get('z') , 6 )
Ejemplo n.º 7
0
 def test_assignment_pythagoras(self):
     line = "sin(2)*sin(2) + cos(2)*cos(2)"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual(result , 1.0 )
Ejemplo n.º 8
0
 def test_assignment_minus(self):
     line = "-(2+2)"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual( result , -4.0)        
Ejemplo n.º 9
0
 def test_assignment_exp(self):
     line = 'exp( 0 )'
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual( result , 1.0)
Ejemplo n.º 10
0
 def test_assignment_log(self):
     line = "log( 2.718281828459045 )"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment(wtok)
     self.assertEqual( result , 1.0)
Ejemplo n.º 11
0
 def test_assingment_cos(self):
     line = "cos(3.141592653589793)"
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual( result , math.cos(math.pi))
Ejemplo n.º 12
0
 def test_assingment_sin(self):
     line = 'sin( 10 )'
     wtok = TokenizeWrapper( line )
     result = my_calculator.assignment( wtok )
     self.assertEqual( result , math.sin( 10 ) )