def int_BINARY_ADD(f, oparg, next_instr): w_2 = f.popvalue() w_1 = f.popvalue() if (type(w_1) is intobject.W_IntObject and type(w_2) is intobject.W_IntObject): try: w_result = intobject.add__Int_Int(f.space, w_1, w_2) except FailedToImplement: w_result = f.space.add(w_1, w_2) else: w_result = f.space.add(w_1, w_2) f.pushvalue(w_result)
def test_add(self): x = 1 y = 2 f1 = iobj.W_IntObject(x) f2 = iobj.W_IntObject(y) result = iobj.add__Int_Int(self.space, f1, f2) assert result.intval == x+y x = sys.maxint y = 1 f1 = iobj.W_IntObject(x) f2 = iobj.W_IntObject(y) assert self.space.w_OverflowError == ( self._unwrap_nonimpl(iobj.add__Int_Int, self.space, f1, f2))
def BINARY_ADD(f, oparg, *ignored): from pypy.objspace.std.intobject import \ W_IntObject, add__Int_Int w_2 = f.popvalue() w_1 = f.popvalue() if type(w_1) is W_IntObject and type(w_2) is W_IntObject: try: w_result = add__Int_Int(f.space, w_1, w_2) except FailedToImplement: w_result = f.space.add(w_1, w_2) else: w_result = f.space.add(w_1, w_2) f.pushvalue(w_result)
def test_add(self): x = 1 y = 2 f1 = iobj.W_IntObject(x) f2 = iobj.W_IntObject(y) result = iobj.add__Int_Int(self.space, f1, f2) assert result.intval == x + y x = sys.maxint y = 1 f1 = iobj.W_IntObject(x) f2 = iobj.W_IntObject(y) assert self.space.w_OverflowError == (self._unwrap_nonimpl( iobj.add__Int_Int, self.space, f1, f2))