Пример #1
0
 def test_subtract_1_1(self):
     """Test subtract with 1 - 1"""
     MNE.run_interpreter_from_python("00100000010010000001017", True)
     self.assertAlmostEqual(MNE.stack[0], 0.0)
Пример #2
0
 def test_read_float_failure(self):
     """Test read float "cheeseburger" """
     MNE.run_interpreter_from_python("003", True, True, ["cheeseburger"])
     self.assertAlmostEqual(MNE.stack, [0.0])
Пример #3
0
 def test_read_string_hello_world(self):
     """Test read string "Hello, world!" """
     MNE.run_interpreter_from_python("004", True, True, ["Hello, world!"])
     self.assertAlmostEqual(MNE.stack, [33., 100., 108., 114., 111., 119., \
                            32., 44., 111., 108., 108., 101., 72., 1.])
Пример #4
0
 def test_pop_stack_underflow(self):
     """Test that stack underflow due to popping is handled safely"""
     MNE.run_interpreter_from_python("020", True)
Пример #5
0
 def test_read_float_3_14159(self):
     """Test read float "3.14159" """
     MNE.run_interpreter_from_python("003", True, True, ["3.14159"])
     self.assertAlmostEqual(MNE.stack, [3.14159, 1.0])
Пример #6
0
 def test_duplicate(self):
     """Test duplicate"""
     MNE.run_interpreter_from_python("00100000010210010000002021021", True)
     self.assertEqual(MNE.stack, [1.0, 1.0, 2.0, 2.0, 2.0])
Пример #7
0
 def test_push_float_1e_minus_99(self):
     """Test push float 1e-99"""
     MNE.run_interpreter_from_python("0021990000001", True)
     self.assertAlmostEqual(MNE.stack[0] * 1e99, 1.0)
Пример #8
0
 def test_multiply_1_1_1_1(self):
     """Test multiply with 1.1 * 1.1"""
     MNE.run_interpreter_from_python("00210100000110021010000011018", True)
     self.assertAlmostEqual(MNE.stack[0], 1.21)
Пример #9
0
 def test_divide_16_2(self):
     """Test divide with 16 / 2"""
     MNE.run_interpreter_from_python("00100000020010000016019", True)
     self.assertAlmostEqual(MNE.stack[0], 8.0)
Пример #10
0
 def test_multiply_1e99_1e_minus_99(self):
     """Test multiply with 1e99 * 1e-99"""
     MNE.run_interpreter_from_python("00219900000010020990000001018", True)
     self.assertAlmostEqual(MNE.stack[0], 1.0)
Пример #11
0
 def test_push_float_minus_0_123456(self):
     """Test push float -0.123456"""
     MNE.run_interpreter_from_python("0021061123456", True)
     self.assertAlmostEqual(MNE.stack, [-.123456])
Пример #12
0
 def test_multiply_minus_1_1(self):
     """Test multiply with -1 * 1"""
     MNE.run_interpreter_from_python("00100000010011000001018", True)
     self.assertAlmostEqual(MNE.stack[0], -1.0)
Пример #13
0
 def test_subtract_3_14159_minus_0_14159(self):
     """Test subtract with 3.14159 - 0.14159"""
     MNE.run_interpreter_from_python("00210500141590021050314159017", True)
     self.assertAlmostEqual(MNE.stack[0], 3.0)
Пример #14
0
 def test_subtract_1e99_1e_minus_99(self):
     """Test subtract with 1e99 - 1e-99"""
     MNE.run_interpreter_from_python("00219900000010020990000001017", True)
     self.assertAlmostEqual(MNE.stack[0], 1e99)
Пример #15
0
 def test_remainder_13_3_2_99(self):
     """Test remainder with 13.3 % 2.99"""
     MNE.run_interpreter_from_python("00210200002990021010000133022", True)
     self.assertAlmostEqual(MNE.stack[0], 1.0)
Пример #16
0
 def test_divide_3_14159_minus_3_14159(self):
     """Test divide with 3.14159 / -3.14159"""
     MNE.run_interpreter_from_python("00210513141590021050314159019", True)
     self.assertAlmostEqual(MNE.stack[0], -1.0)
Пример #17
0
 def test_pop(self):
     """Test pop"""
     MNE.run_interpreter_from_python("00100000010010000002020020", True)
     self.assertEqual(MNE.stack, [])
Пример #18
0
 def test_divide_1_1e_minus_99(self):
     """Test divide with 1 / 1e-99"""
     MNE.run_interpreter_from_python("00219900000010010000001019", True)
     self.assertAlmostEqual(MNE.stack[0], 1e99)
Пример #19
0
 def test_push_float_100(self):
     """Test push float 10000e-2"""
     MNE.run_interpreter_from_python("0021020010000", True)
     self.assertAlmostEqual(MNE.stack, [100.0])
Пример #20
0
 def test_divide_1_21_1_1(self):
     """Test divide with 1.21 / 1.1"""
     MNE.run_interpreter_from_python("00210100000110021020000121019", True)
     self.assertAlmostEqual(MNE.stack[0], 1.1)
Пример #21
0
 def test_push_pop(self):
     """Test integer push followed by vanilla pop"""
     MNE.run_interpreter_from_python("0010000001020", True)
     self.assertEqual(MNE.stack, [])
Пример #22
0
 def test_divide_indeterminate(self):
     """Test divide zero by zero"""
     MNE.run_interpreter_from_python("00100000000010000000019", True)
     self.assertEqual(MNE.stack, [])
Пример #23
0
 def test_read_float_0(self):
     """Test read float "0" """
     MNE.run_interpreter_from_python("003", True, True, ["0"])
     self.assertAlmostEqual(MNE.stack, [0.0, 1.0])
Пример #24
0
 def test_remainder_5_5(self):
     """Test remainder 5 % 5"""
     MNE.run_interpreter_from_python("00100000050010000005022", True)
     self.assertAlmostEqual(MNE.stack[0], 0.0)
Пример #25
0
 def test_read_float_minus_1e99(self):
     """Test read float "-1e99" """
     MNE.run_interpreter_from_python("003", True, True, ["-1e99"])
     self.assertAlmostEqual(MNE.stack, [-1e99, 1.0])
Пример #26
0
 def test_remainder_undefined(self):
     """Test remainder when undefined"""
     MNE.run_interpreter_from_python("00100000000010000005022", True)
     self.assertEqual(MNE.stack, [])
Пример #27
0
 def test_read_string_empty(self):
     """Test reading an empty string"""
     MNE.run_interpreter_from_python("004", True, True, [""])
     self.assertAlmostEqual(MNE.stack, [1.0])
Пример #28
0
 def test_push_float_123456e99(self):
     """Test push float 123456e99"""
     MNE.run_interpreter_from_python("0020990123456", True)
     self.assertAlmostEqual(MNE.stack, [123456e99])
Пример #29
0
 def test_read_string_unicode(self):
     """Test reading string with a unicode character"""
     MNE.run_interpreter_from_python("004", True, True, ["¯\_(ツ)_/¯"])
     self.assertAlmostEqual(MNE.stack, [175., 47., 95., 41., 12484., 40., \
                                        95., 92., 175., 1.])
Пример #30
0
 def test_add_3_14159_minus_0_14159(self):
     """Test add with 3.14159 + -0.14159"""
     MNE.run_interpreter_from_python("00210503141590021051014159016", True)
     self.assertAlmostEqual(MNE.stack[0], 3.0)