Beispiel #1
0
 def test24(self):
     self.assertEqual(
         1.0 + 2.0 * 4.0 / 3.0 + 1.0 != 1.0 + 2.0 * 4.0 / 3.0 + 2.0,
         calc([
             1.0, 2.0, 4.0, '*', 3.0, '/', '+', 1.0, '+', 1.0, 2.0, 4.0,
             '*', 3.0, '/', '+', 2.0, '+', '!='
         ]))
Beispiel #2
0
 def test33(self):
     self.assertEqual((2.0**(math.pi / math.pi + math.e / math.e +
                             2.0**0.0))**(1.0 / 3.0),
                      calc([
                          2.0, 'pi', 'pi', '/', 'e', 'e', '/', '+', 2.0,
                          0.0, '^', '+', '^', 1.0, 3.0, '/', '^'
                      ]))
Beispiel #3
0
 def test34(self):
     self.assertEqual(
         math.sin(math.pi / 2.0**1.0) + math.log(1 * 4 + 2**2 + 1, 3**2),
         calc([
             'pi', 2.0, 1.0, '^', '/', 'sin', 1.0, 4.0, '*', 2.0, 2.0, '^',
             '+', 1.0, '+', 3.0, 2.0, '^', 'log', '+'
         ]))
Beispiel #4
0
 def test38(self):
     self.assertEqual(
         math.sin(math.e**math.log(math.e**math.e**math.sin(23.0), 45.0) +
                  math.cos(3.0 + math.log10(math.e**-math.e))),
         calc([
             'e', 'e', 'e', 23.0, 'sin', '^', '^', 45.0, 'log', '^', 3.0,
             'e', 0.0, 'e', '-', '^', 'log10', '+', 'cos', '+', 'sin'
         ]))
Beispiel #5
0
 def test84(self):
     self.assertEqual(
         math.pow(2.0**(2.0**2.0 * 2.0**2.0),
                  math.log10(100.0) * math.log10(1000.0)),
         calc([
             2.0, 2.0, 2.0, '^', 2.0, 2.0, '^', '*', '^', 100.0, 'log10',
             1000.0, 'log10', '*', 'pow'
         ]))
Beispiel #6
0
 def test35(self):
     self.assertEqual(
         10.0 * math.e**0.0 * math.log10(.4 - 5.0 / -0.1 - 10.0) -
         -abs(-53.0 / 10.0) + -5.0,
         calc([
             10.0, 'e', 0.0, '^', '*', 0.4, 5.0, 0.0, 0.1, '-', '/', '-',
             10.0, '-', 'log10', '*', 0.0, 53.0, 10.0, '/', '-', 'abs', '+',
             5.0, '-'
         ]))
Beispiel #7
0
 def test36(self):
     self.assertEqual(
         math.sin(-math.cos(-math.sin(3.0) - math.cos(
             -math.sin(-3.0 * 5.0) - math.sin(math.cos(math.log10(43.0)))) +
                            math.cos(math.sin(math.sin(34.0 - 2.0**2.0)))) -
                  -math.cos(1.0) - -math.cos(0.0)**3.0),
         calc([
             0.0, 0.0, 3.0, 'sin', '-', 0.0, 0.0, 3.0, 5.0, '*', '-', 'sin',
             '-', 43.0, 'log10', 'cos', 'sin', '-', 'cos', '-', 34.0, 2.0,
             2.0, '^', '-', 'sin', 'sin', 'cos', '+', 'cos', '-', 1.0,
             'cos', '+', 0.0, 3.0, '^', 'cos', '+', 'sin'
         ]))
Beispiel #8
0
 def test17(self):
     self.assertEqual(abs(-5.0), calc([0.0, 5.0, '-', 'abs']))
Beispiel #9
0
 def test16(self):
     self.assertEqual(2.0 * math.sin(math.pi / 2.0),
                      calc([2.0, 'pi', 2.0, '/', 'sin', '*']))
Beispiel #10
0
 def test15(self):
     self.assertEqual(
         math.sin(math.pi / 2.0) * 111 * 6,
         calc(['pi', 2.0, '/', 'sin', 111.0, '*', 6.0, '*']))
Beispiel #11
0
 def test14(self):
     self.assertEqual(math.log10(100.0), calc([100.0, 'log10']))
Beispiel #12
0
 def test91(self):
     self.assertEqual((1.0 + 13.0), calc([1.0, 13.0, '+']))
Beispiel #13
0
 def test22(self):
     self.assertEqual(
         1.0 + 2.0 * 3.0 == 1.0 + 2.0 * 3.0,
         calc([1.0, 2.0, 3.0, '*', '+', 1.0, 2.0, 3.0, '*', '+', '==']))
Beispiel #14
0
 def test20(self):
     self.assertEqual(100.0 / 4.0 / 3.0, calc([100.0, 4.0, '/', 3.0, '/']))
Beispiel #15
0
 def test10(self):
     self.assertEqual(100.0 / 3.0 % 2.0**2.0,
                      calc([100.0, 3.0, '/', 2.0, 2.0, '^', '%']))
Beispiel #16
0
 def test4(self):
     self.assertRaises(ValueError, lambda: calc([1.0, 2.0, 3.0, 'pow']))
Beispiel #17
0
 def test2(self):
     self.assertRaises(ValueError, lambda: calc([1.0, 2.0, 3.0, 'sin']))
Beispiel #18
0
 def test9(self):
     self.assertEqual(100.0 / 3.0**2.0, calc([100.0, 3.0, 2.0, '^', '/']))
Beispiel #19
0
 def test94(self):
     self.assertEqual(-(-(-1.0)), calc([0.0, 0.0, 0.0, 1.0, '-', '-', '-']))
Beispiel #20
0
 def test93(self):
     self.assertEqual(((1.0)), calc([1.0]))
Beispiel #21
0
 def test92(self):
     self.assertEqual(-1.0 - (-1.0),
                      calc([0.0, 1.0, '-', 0.0, 1.0, '-', '-']))
Beispiel #22
0
 def test18(self):
     self.assertEqual(round(123.456789), calc([123.456789, 'round']))
Beispiel #23
0
 def test19(self):
     self.assertEqual(102.0 % 12.0 % 7.0, calc([102.0, 12.0, '%', 7.0,
                                                '%']))
Beispiel #24
0
 def test1(self):
     self.assertEqual(-13.0, calc([0.0, 13.0, '-']))
Beispiel #25
0
 def test21(self):
     self.assertEqual(2.0**3.0**4.0, calc([2.0, 3.0, 4.0, '^', '^']))
Beispiel #26
0
 def test13(self):
     self.assertEqual(math.sin(math.pi / 2.0), calc(['pi', 2.0, '/',
                                                     'sin']))
Beispiel #27
0
 def test23(self):
     self.assertEqual(math.e**5.0 >= math.e**5.0 + 1.0,
                      calc(['e', 5.0, '^', 'e', 5.0, '^', 1.0, '+', '>=']))
Beispiel #28
0
 def test90(self):
     self.assertEqual(1.0 * (13.0), calc([1.0, 13.0, '*']))
Beispiel #29
0
 def test11(self):
     self.assertEqual(math.pi + math.e, calc(['pi', 'e', '+']))
Beispiel #30
0
 def test12(self):
     self.assertEqual(math.log(math.e), calc(['e', 'log']))