def test_settop(self): i = W_Int(1) i2 = W_Int(2) self.frame.push(i) self.frame.settop(i2) i3 = self.frame.peek() self.assertEquals(self.frame.stacktop, 1) self.assertIs(i2, i3)
def IDIV(self, _): w_y = self.pop() w_x = self.peek() y = w_y.to_int() if y == 0: raise W_ValueError('divide by zero', w_x, 'idiv()').wrap() self.settop(W_Int(w_x.to_int() * y))
def test_int_ctor(self): i = W_Int(5) self.assertEquals(i.to_int(), 5) self.assertEquals(i.to_string(), '5')
def test_peek(self): i = W_Int(1) self.frame.push(i) i2 = self.frame.peek() self.assertEquals(self.frame.stacktop, 1) self.assertIs(i, i2)
def test_push(self): i = W_Int(1) self.frame.push(i) self.assertEquals(self.frame.stacktop, 1)
def INT(self, ival): self.push(W_Int(ival))
def IMUL(self, _): w_y = self.pop() w_x = self.peek() self.settop(W_Int(w_x.to_int() * w_y.to_int()))
def ISUB(self, _): w_y = self.pop() w_x = self.peek() self.settop(W_Int(w_x.to_int() - w_y.to_int()))
def IADD(self, _): w_y = self.pop() w_x = self.peek() self.settop(W_Int(w_x.to_int() + w_y.to_int()))