[pypy-svn] r54896 - in pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk: . test

tverwaes at codespeak.net tverwaes at codespeak.net
Sun May 18 17:40:29 CEST 2008


Author: tverwaes
Date: Sun May 18 17:40:29 2008
New Revision: 54896

Modified:
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_wrapper.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/wrapper.py
Log:
(cfbolz, tverwaes) implementing the wait, signal test + bugfix


Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_wrapper.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_wrapper.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_wrapper.py	Sun May 18 17:40:29 2008
@@ -210,3 +210,25 @@
         assert wrapper.scheduler().active_process() is process.w_self
 
         py.test.raises(FatalError, semaphore.wait, interp)
+
+    def test_semaphore_wait_signal(self):
+        semaphore = new_semaphore()
+        interp, process, old_process = self.make_processes(4, 2, objtable.w_false, objtable.w_true)
+
+        semaphore.wait(interp)
+        assert wrapper.scheduler().active_process() is process.w_self
+        semaphore.signal(interp)
+        assert wrapper.scheduler().active_process() is process.w_self
+        process_list = wrapper.scheduler().get_process_list(old_process.priority())
+        assert process_list.remove_first_link_of_list() is old_process.w_self
+
+        process.write(2, utility.wrap_int(1))        
+        old_process.resume(interp)
+        assert wrapper.scheduler().active_process() is old_process.w_self        
+        semaphore.wait(interp)
+        assert wrapper.scheduler().active_process() is process.w_self
+        semaphore.signal(interp)
+        assert wrapper.scheduler().active_process() is old_process.w_self        
+
+        process_list = wrapper.scheduler().get_process_list(process.priority())
+        assert process_list.first_link() is process.w_self

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/wrapper.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/wrapper.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/wrapper.py	Sun May 18 17:40:29 2008
@@ -156,7 +156,7 @@
             w_value = utility.wrap_int(utility.unwrap_int(w_value) + 1)
             self.store_excess_signals(w_value)
         else:
-            self.remove_first_link_of_list().resume(interp)
+            ProcessWrapper(self.remove_first_link_of_list()).resume(interp)
 
     def wait(self, interp):
         excess = utility.unwrap_int(self.excess_signals())



More information about the Pypy-commit mailing list