def test_neg(self): method = self.pyklass.get_method("neg:(I)I") self.assertEqual(method.signature, '(I)I') self.assertEqual(method.num_params, 1) # pass function body vars. result = self.intrptr.execute(method, IntrptVars([ PyVMValue.pyint(5), ])) self.assertPyVMInt(result, -5)
def test_inc2(self): method = self.pyklass.get_method("inc2:(D)D") self.assertEqual(method.signature, "(D)D") self.assertEqual(method.num_params, 1) result = self.intrptr.execute( method, IntrptVars([ PyVMValue.pyint(0), PyVMValue.pyint(5), ])) self.assertPyVMDouble(result, 6)
def test_mul(self): method = self.pyklass.get_method("mul:(II)I") self.assertEqual(method.signature, '(II)I') self.assertEqual(method.num_params, 2) # pass function body vars. result = self.intrptr.execute( method, IntrptVars([ PyVMValue.pyint(2), PyVMValue.pyint(3), ])) self.assertPyVMInt(result, 6)
def test_two(self): method = self.pyklass.get_method("two:(II)I") self.assertEqual(method.signature, '(II)I') self.assertEqual(method.num_params, 2) # pass function body vars. result = self.intrptr.execute( method, IntrptVars(args=[ PyVMValue.pyint(1), PyVMValue.pyint(3), ])) self.assertPyVMInt(result, 4) # pass other vars. result = self.intrptr.execute( method, IntrptVars(args=[ PyVMValue.pyint(100), PyVMValue.pyint(300), ])) self.assertPyVMInt(result, 400)
def test_div(self): method = self.pyklass.get_method("div:(DD)D") self.assertEqual(method.signature, "(DD)D") self.assertEqual(method.num_params, 2) result = self.intrptr.execute( method, IntrptVars([ PyVMValue.pyint(0), PyVMValue.pyint(3), PyVMValue.pyint(0), PyVMValue.pyint(2), ])) self.assertPyVMDouble(result, 1)