[pypy-commit] pypy default: Add clear() and copy() actions

rlamy pypy.commits at gmail.com
Mon Feb 29 11:07:37 EST 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: 
Changeset: r82614:b212924f1c8d
Date: 2016-02-29 16:06 +0000
http://bitbucket.org/pypy/pypy/changeset/b212924f1c8d/

Log:	Add clear() and copy() actions

diff --git a/rpython/rtyper/test/test_rdict.py b/rpython/rtyper/test/test_rdict.py
--- a/rpython/rtyper/test/test_rdict.py
+++ b/rpython/rtyper/test/test_rdict.py
@@ -1304,6 +1304,15 @@
         del state.reference[self.key]
         assert not rdict.ll_contains(state.l_dict, ll_key)
 
+class CopyDict(Action):
+    def execute(self, state):
+        state.l_dict = rdict.ll_copy(state.l_dict)
+
+class ClearDict(Action):
+    def execute(self, state):
+        rdict.ll_clear(state.l_dict)
+        state.reference.clear()
+
 class CompleteCheck(Action):
     def execute(self, state):
         assert state.l_dict.num_items == len(state.reference)
@@ -1333,7 +1342,13 @@
         self.reference = {}
 
     def steps(self):
-        return (st_setitem | st_delitem(self.reference) | just(CompleteCheck())) if self.reference else (st_setitem | just(CompleteCheck()))
+        global_actions = [CopyDict(), ClearDict(), CompleteCheck()]
+        if self.reference:
+            return (
+                st_setitem | st_delitem(self.reference) |
+                sampled_from(global_actions))
+        else:
+            return (st_setitem | sampled_from(global_actions))
 
     def execute_step(self, action):
         action.execute(self)


More information about the pypy-commit mailing list