Exemplo n.º 1
0
    def test_dneg(self):
        stack = IntrptEvalStack()
        stack.push(PyVMValue.pydouble(10))
        stack.push(PyVMValue.pydouble(20))
        self.assertEqual(stack.size(), 2)

        stack.dneg()
        self.assertEqual(stack.size(), 2)

        val = stack.pop()
        self.assertPyVMDouble(val, -20)
        self.assertEqual(stack.size(), 1)
Exemplo n.º 2
0
    def test_drem(self):
        stack = IntrptEvalStack()
        stack.push(PyVMValue.pydouble(5))
        stack.push(PyVMValue.pydouble(3))
        self.assertEqual(stack.size(), 2)

        stack.drem()
        self.assertEqual(stack.size(), 1)

        val = stack.pop()
        self.assertPyVMDouble(val, 2)
        self.assertEqual(stack.size(), 0)

        stack.push(PyVMValue.pydouble(3))
        stack.push(PyVMValue.pydouble(5))
        self.assertEqual(stack.size(), 2)

        stack.drem()
        self.assertEqual(stack.size(), 1)

        val = stack.pop()
        self.assertPyVMDouble(val, 3)
        self.assertEqual(stack.size(), 0)
Exemplo n.º 3
0
 def dload(self, index: int):
     p1: PyVMValue = self.args[index].clone()
     p2: PyVMValue = self.args[index + 1].clone()
     return PyVMValue.pydouble((p1.value << 8) + p2.value)
Exemplo n.º 4
0
 def assertPyVMDouble(self, actual: PyVMValue, expected: float) -> None:
     self.assertValue(actual, PyVMValue.pydouble(expected))