Author: Armin Rigo <[email protected]>
Branch:
Changeset: r58557:3c48814f0da0
Date: 2012-10-29 09:36 +0100
http://bitbucket.org/pypy/pypy/changeset/3c48814f0da0/
Log: merge heads
diff --git a/pypy/module/micronumpy/interp_boxes.py
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -275,14 +275,6 @@
arr.storage[i] = arg[i]
return W_StringBox(arr, 0, arr.dtype)
- # Running entire test suite needs this function to succeed,
- # running single test_stringarray succeeds without it.
- # With convert_to() test_ztranslation fails since
- # W_CharacterBox is not a W_GenericBox.
- # Why is it needed for multiple tests?
- #def convert_to(self, dtype):
- # xxx
-
class W_UnicodeBox(W_CharacterBox):
def descr__new__unicode_box(space, w_subtype, w_arg):
from pypy.module.micronumpy.interp_dtype import new_unicode_dtype
diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -119,6 +119,17 @@
self.size = size or len(digits)
self.sign = sign
+ # __eq__ and __ne__ method exist for testingl only, they are not RPython!
+ def __eq__(self, other):
+ # NOT_RPYTHON
+ if not isinstance(other, rbigint):
+ return NotImplemented
+ return self.eq(other)
+
+ def __ne__(self, other):
+ # NOT_RPYTHON
+ return not (self == other)
+
def digit(self, x):
"""Return the x'th digit, as an int."""
return self._digits[x]
diff --git a/pypy/rlib/test/test_rbigint.py b/pypy/rlib/test/test_rbigint.py
--- a/pypy/rlib/test/test_rbigint.py
+++ b/pypy/rlib/test/test_rbigint.py
@@ -1,14 +1,19 @@
from __future__ import division
+
+import operator
+import sys
+from random import random, randint, sample
+
import py
-import operator, sys, array
-from random import random, randint, sample
-from pypy.rlib.rbigint import rbigint, SHIFT, MASK, KARATSUBA_CUTOFF
-from pypy.rlib.rbigint import _store_digit, _mask_digit
-from pypy.rlib.rfloat import NAN
+
from pypy.rlib import rbigint as lobj
from pypy.rlib.rarithmetic import r_uint, r_longlong, r_ulonglong, intmask
+from pypy.rlib.rbigint import (rbigint, SHIFT, MASK, KARATSUBA_CUTOFF,
+ _store_digit, _mask_digit)
+from pypy.rlib.rfloat import NAN
from pypy.rpython.test.test_llinterp import interpret
+
class TestRLong(object):
def test_simple(self):
for op1 in [-2, -1, 0, 1, 2, 50]:
@@ -112,6 +117,17 @@
rl = rbigint.fromint(sys.maxint).add(rbigint.fromint(42))
assert rl.touint() == result
+ def test_eq_ne_operators(self):
+ a1 = rbigint.fromint(12)
+ a2 = rbigint.fromint(12)
+ a3 = rbigint.fromint(123)
+
+ assert a1 == a2
+ assert a1 != a3
+ assert not (a1 != a2)
+ assert not (a1 == a3)
+
+
def gen_signs(l):
for s in l:
if s == 0:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit