Commits

Lars Wassermann  committed 8f1a3b5

greened tests

  • Participants
  • Parent commits b992548

Comments (0)

Files changed (3)

File spyvm/model.py

     def getword(self, n):
         # if n < 0:
         #     import pdb; pdb.set_trace()
-        assert n >= 0
+        assert self.size() > n >= 0
         if self.words is not None:
             return self.words[n]
         else:
         return w_result
 
     def getword(self, n):
-        assert n >= 0
+        assert self.size() > n >= 0
         # if self._realsize > n:
         return self._real_depth_buffer[n]
         # else:

File spyvm/shadow.py

     def copy_loop(self):
         space = self.space
         no_skew_mask = ~self.skew_mask
-        for i in xrange(1, self.h+1):
+        for i in xrange(1, self.h + 1):
             if self.halftone_bits:
                 halftone_word = self.halftone_bits[self.dy % len(self.halftone_bits)]
                 self.dy = self.dy + self.v_dir
             for word in xrange(1, self.n_words + 1):
                 if self.source_form is not None:
                     prev_word = prev_word & self.skew_mask
-                    if (self.source_index < 0 
+                    if (self.source_index < 0
                         or self.source_index >= self.source_bits.size()):
                         this_word = self.source_bits.getword(0)
                     else:
     _attrs_ = ["w_bits", "width", "height", "depth", "offset_x", "offset_y"]
 
     def sync_cache(self):
+        if self.size() < 5:
+            w_self = self.w_self()
+            assert isinstance(w_self, model.W_PointersObject)
+            w_self._shadow = None
+            raise error.PrimitiveFailedError
         self.w_bits = self.fetch(0)
         if not (isinstance(self.w_bits, model.W_WordsObject) or isinstance(self.w_bits, model.W_DisplayBitmap)):
             w_self = self.w_self()

File spyvm/test/test_primitives.py

             assert argcount == 0
             raise CallCopyBitsSimulation
 
+    def sync_cache_mock(self):
+        raise CallCopyBitsSimulation
+
     interp, w_frame, argument_count = mock([mock_bitblt], None)
     if interp.image is None:
         interp.image = Image()
 
     try:
         monkeypatch.setattr(w_frame._shadow, "_sendSelfSelector", perform_mock)
+        monkeypatch.setattr(shadow.BitBltShadow, "sync_cache", sync_cache_mock)
         with py.test.raises(CallCopyBitsSimulation):
             prim_table[primitives.BITBLT_COPY_BITS](interp, w_frame.as_context_get_shadow(space), argument_count-1)
     finally: