Commits

Alex Gaynor committed 0981805

Added signature tests for slicing.

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_numarray.py

         return self.get_concrete().descr_len(space)
 
     def descr_getitem(self, space, w_idx):
-        # TODO: indexation by tuples
+        # TODO: indexing by tuples
         start, stop, step, slice_length = space.decode_index4(w_idx, self.find_size())
         if step == 0:
             # Single index
             # Slice
             res = SingleDimSlice(start, stop, step, slice_length, self, self.signature.transition(SingleDimSlice.static_signature))
             return space.wrap(res)
-            
 
     @unwrap_spec(item=int, value=float)
     def descr_setitem(self, space, item, value):
 
     def descr_len(self, space):
         return space.wrap(self.find_size())
-        
+
     def calc_index(self, item):
         raise NotImplementedError
 

pypy/module/micronumpy/test/test_base.py

         assert v2.signature is v3.signature
         v4 = ar.descr_add(space, ar)
         assert v1.signature is v4.signature
+
+    def test_slice_signature(self, space):
+        ar = SingleDimArray(10)
+        v1 = ar.descr_getitem(space, space.wrap(slice(1, 5, 1)))
+        v2 = ar.descr_getitem(space, space.wrap(slice(4, 6, 1)))
+        assert v1.signature is v2.signature
+
+        v3 = ar.descr_add(space, v1)
+        v4 = ar.descr_add(space, v2)
+        assert v3.signature is v4.signature