1. Pypy
  2. Untitled project
  3. pypy

Commits

mattip  committed 280aa45 Merge

merge default into branch

  • Participants
  • Parent commits 7bfd471, 0856e88
  • Branches numpypy.float16

Comments (0)

Files changed (3)

File pypy/module/micronumpy/interp_boxes.py

View file
             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

File pypy/rlib/rbigint.py

View file
         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]

File pypy/rlib/test/test_rbigint.py

View file
 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]:
         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: