Commits

Antonio Cuni committed 39209f0

make sure to set .autoreds and .numreds even when the reds are given as class attributes

Comments (0)

Files changed (2)

             self.reds = []
             self.numreds = None # see warmspot.autodetect_jit_markers_redvars
             assert confirm_enter_jit is None, 'cannot use automatic reds if confirm_enter_jit is given'
-        elif reds is not None:
+        else:
+            if reds is not None:
+                self.reds = reds
             self.autoreds = False
-            self.reds = reds
-            self.numreds = len(reds)
+            self.numreds = len(self.reds)
         if not hasattr(self, 'greens') or not hasattr(self, 'reds'):
             raise AttributeError("no 'greens' or 'reds' supplied")
         if virtualizables is not None:

pypy/rlib/test/test_jit.py

     #
     py.test.raises(AssertionError, "JitDriver(greens=['foo'], reds='auto', confirm_enter_jit='something')")
 
+def test_jitdriver_numreds():
+    driver = JitDriver(greens=['foo'], reds=['a', 'b'])
+    assert driver.reds == ['a', 'b']
+    assert driver.numreds == 2
+    #
+    class MyJitDriver(JitDriver):
+        greens = ['foo']
+        reds = ['a', 'b']
+    driver = MyJitDriver()
+    assert driver.reds == ['a', 'b']
+    assert driver.numreds == 2
+
 def test_jitdriver_clone():
     def foo():
         pass