<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -32,7 +32,7 @@ describe &quot;Kernel#sleep&quot; do
     end    
     lock.receive.should == :ready
     # wait until the thread has gone to sleep
-    Thread.pass until t.status == &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     t.run
     t.value.should == 5
   end</diff>
      <filename>core/kernel/sleep_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ describe &quot;Thread.critical=&quot; do
 
   it &quot;does not change status of other existing threads&quot; do
     t = ThreadSpecs.create_critical_thread { ScratchPad.record Thread.main.status }
-    Thread.pass while t.status != false
+    Thread.pass while t.status and t.status != false
     ScratchPad.recorded.should == &quot;run&quot;
   end
 
@@ -71,20 +71,20 @@ describe &quot;Thread.critical=&quot; do
 
   it &quot;defers exit&quot; do
     critical_thread = ThreadSpecs.create_and_kill_critical_thread()
-    Thread.pass while critical_thread.status != false
+    Thread.pass while critical_thread.status
     ScratchPad.recorded.should == &quot;status=aborting&quot;
   end
 
   it &quot;defers exit until Thread.pass&quot; do
     critical_thread = ThreadSpecs.create_and_kill_critical_thread(true)
-    Thread.pass while critical_thread.status != false
+    Thread.pass while critical_thread.status
     ScratchPad.recorded.should == nil
   end
 
   not_compliant_on(:ironruby) do # requires green threads so that another thread can be scheduled when the critical thread is killed
     it &quot;is not reset if the critical thread is killed&quot; do
       critical_thread = ThreadSpecs.create_and_kill_critical_thread(true)
-      Thread.pass while critical_thread.status != false
+      Thread.pass while critical_thread.status
       Thread.critical.should == true
 
       Thread.critical = false</diff>
      <filename>core/thread/critical_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -57,7 +57,7 @@ module ThreadSpecs
   
   def self.status_of_running_thread
     t = running_thread
-    Thread.pass while t.alive? &amp;&amp; t.status != &quot;run&quot;
+    Thread.pass while t.status and t.status != &quot;run&quot;
     status = Status.new t
     t.kill
     t.join
@@ -72,7 +72,7 @@ module ThreadSpecs
   
   def self.status_of_sleeping_thread
     t = sleeping_thread
-    Thread.pass until t.status == 'sleep'
+    Thread.pass while t.status and t.status != 'sleep'
     status = Status.new t
     t.run
     t.join
@@ -83,7 +83,7 @@ module ThreadSpecs
     m = Mutex.new
     m.lock
     t = Thread.new { m.lock }
-    Thread.pass until t.status == 'sleep'
+    Thread.pass while t.status and t.status != 'sleep'
     status = Status.new t
     m.unlock
     t.join
@@ -103,7 +103,7 @@ module ThreadSpecs
   
   def self.status_of_killed_thread
     t = Thread.new { sleep }
-    Thread.pass until t.status == 'sleep'
+    Thread.pass while t.status and t.status != 'sleep'
     t.kill
     t.join
     Status.new t
@@ -127,7 +127,7 @@ module ThreadSpecs
   
   def self.status_of_dying_sleeping_thread
     t = dying_thread_ensures { Thread.stop; }           
-    Thread.pass until t.status == 'sleep'
+    Thread.pass while t.status and t.status != 'sleep'
     status = Status.new t
     t.wakeup
     t.join
@@ -165,10 +165,10 @@ module ThreadSpecs
   end
   
   def self.wakeup_dying_sleeping_thread(kill_method_name=:kill)
-    thread = ThreadSpecs.dying_thread_ensures(kill_method_name) { yield }
-    Thread.pass until thread.status == &quot;sleep&quot;
-    thread.wakeup
-    thread.join
+    t = ThreadSpecs.dying_thread_ensures(kill_method_name) { yield }
+    Thread.pass while t.status and t.status != 'sleep'
+    t.wakeup
+    t.join
   end
   
   def self.critical_is_reset
@@ -225,7 +225,7 @@ module ThreadSpecs
     critical_thread[:thread_specs] = 101
     if isThreadSleep or isThreadStop
       # Thread#wakeup calls are not queued up. So we need to ensure that the thread is sleeping before calling wakeup
-      Thread.pass while critical_thread.status != &quot;sleep&quot;
+      Thread.pass while critical_thread.status and critical_thread.status != &quot;sleep&quot;
       critical_thread.wakeup
     end
   end
@@ -240,12 +240,12 @@ module ThreadSpecs
     @@after_first_sleep = false
     
     critical_thread = Thread.new do
-      Thread.pass while Thread.main.status != &quot;sleep&quot;
+      Thread.pass while Thread.main.status and Thread.main.status != &quot;sleep&quot;
       critical_thread1()
       Thread.main.wakeup
       yield
       Thread.pass while @@after_first_sleep != true # Need to ensure that the next statement does not see the first sleep itself
-      Thread.pass while Thread.main.status != &quot;sleep&quot;
+      Thread.pass while Thread.main.status and Thread.main.status != &quot;sleep&quot;
       critical_thread2(isThreadStop)
       Thread.main.wakeup
     end</diff>
      <filename>core/thread/fixtures/classes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,7 @@ describe &quot;Thread#raise on a sleeping thread&quot; do
   before :each do
     ScratchPad.clear
     @thr = ThreadSpecs.sleeping_thread
-    Thread.pass while (@thr.alive? &amp;&amp; @thr.status != &quot;sleep&quot;)
+    Thread.pass while @thr.status and @thr.status != &quot;sleep&quot;
   end
 
   after :each do
@@ -59,7 +59,7 @@ describe &quot;Thread#raise on a sleeping thread&quot; do
       end
     end
 
-    Thread.pass while t.status != &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     t.raise
     lambda {t.value}.should raise_error(ZeroDivisionError)
     t.kill
@@ -70,7 +70,7 @@ describe &quot;Thread#raise on a running thread&quot; do
   before :each do
     ScratchPad.clear
     @thr = ThreadSpecs.running_thread
-    Thread.pass while (@thr.alive? &amp;&amp; @thr.status != &quot;run&quot;)
+    Thread.pass while @thr.status and @thr.status != &quot;run&quot;
   end
   
   after :each do</diff>
      <filename>core/thread/raise_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ describe :thread_exit, :shared =&gt; true do
       sleep
       ScratchPad.record :after_sleep
     end
-    Thread.pass while sleeping_thread.status != &quot;sleep&quot;
+    Thread.pass while sleeping_thread.status and sleeping_thread.status != &quot;sleep&quot;
     sleeping_thread.send(@method)
     sleeping_thread.join
     ScratchPad.recorded.should == nil
@@ -43,12 +43,12 @@ describe :thread_exit, :shared =&gt; true do
         sleep
       ensure
         ScratchPad &lt;&lt; :outer_ensure_clause
-        Thread.pass until inner.status == &quot;sleep&quot;
+        Thread.pass while inner.status and inner.status != &quot;sleep&quot;
         inner.send(@method)
         inner.join
       end
     end
-    Thread.pass until outer.status == &quot;sleep&quot;
+    Thread.pass while outer.status and outer.status != &quot;sleep&quot;
     outer.send(@method)
     outer.join
     ScratchPad.recorded.should include(:inner_ensure_clause)
@@ -77,7 +77,7 @@ describe :thread_exit, :shared =&gt; true do
   
   it &quot;killing dying sleeping thread wakes up thread&quot; do
     t = ThreadSpecs.dying_thread_ensures { Thread.stop; ScratchPad.record :after_stop }
-    Thread.pass until t.status == &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     t.send(@method)
     t.join
     ScratchPad.recorded.should == :after_stop
@@ -157,7 +157,7 @@ describe :thread_exit, :shared =&gt; true do
   it &quot;does not deadlock when called from within the thread while being joined from without&quot; do
     100.times do
       t = Thread.new { Thread.stop; Thread.current.send(@method) }
-      Thread.pass until t.status == &quot;sleep&quot;
+      Thread.pass while t.status and t.status != &quot;sleep&quot;
       t.wakeup.should == t
       t.join.should == t
     end</diff>
      <filename>core/thread/shared/exit.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,12 +21,12 @@ describe :thread_wakeup, :shared =&gt; true do
 
     exit_loop = true
     
-    Thread.pass while t.status != &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     after_sleep1.should == false # t should be blocked on the first sleep
     t.send(@method)
 
     Thread.pass while after_sleep1 != true
-    Thread.pass while t.status != &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     after_sleep2.should == false # t should be blocked on the second sleep
     t.send(@method)
     Thread.pass while after_sleep2 != true</diff>
      <filename>core/thread/shared/wakeup.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/fixtures/classes'
 describe &quot;Thread.stop&quot; do
   it &quot;causes the current thread to sleep indefinitely&quot; do
     t = Thread.new { Thread.stop; 5 }
-    Thread.pass until t.status == 'sleep'
+    Thread.pass while t.status and t.status != 'sleep'
     t.status.should == 'sleep'
     t.run
     t.value.should == 5
@@ -12,7 +12,7 @@ describe &quot;Thread.stop&quot; do
 
   it &quot;resets Thread.critical to false&quot; do
     t = Thread.new { Thread.critical = true; Thread.stop }
-    Thread.pass until t.status == 'sleep'
+    Thread.pass while t.status and t.status != 'sleep'
     Thread.critical.should == false
     t.run
     t.join</diff>
      <filename>core/thread/stop_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,8 +16,8 @@ describe &quot;ThreadGroup#list&quot; do
     tg.add(th2)    
     (tg.list &amp; [th1, th2]).should include(th1, th2)
 
-    Thread.pass until th1.status == 'sleep' || !th1.alive?
-    Thread.pass until th2.status == 'sleep' || !th2.alive?
+    Thread.pass while th1.status and th1.status != 'sleep'
+    Thread.pass while th2.status and th2.status != 'sleep'
     th1.run; th1.join
     th2.run; th2.join
   end</diff>
      <filename>core/threadgroup/list_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ describe &quot;ConditionVariable#broadcast&quot; do
     end
 
     # ensures that th grabs m before current thread
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     m.synchronize { cv.broadcast }.should == cv
 </diff>
      <filename>library/conditionvariable/broadcast_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ describe &quot;ConditionVariable#signal&quot; do
     end
 
     # ensures that th grabs m before current thread
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     m.synchronize { cv.signal }.should == cv
 </diff>
      <filename>library/conditionvariable/signal_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@ describe &quot;ConditionVariable#wait&quot; do
     end
 
     # ensures that th grabs m before current thread
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     m.synchronize { cv.signal }
     th.join</diff>
      <filename>library/conditionvariable/wait_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,7 @@ describe &quot;Mutex#lock&quot; do
       v = 1
     end
 
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     v.should == 0
     m.unlock</diff>
      <filename>library/mutex/lock_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,7 @@ describe &quot;Mutex#locked?&quot; do
       m2.lock
     end
 
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     m1.locked?.should be_true
     m2.unlock # release th</diff>
      <filename>library/mutex/locked_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@ describe &quot;Mutex#synchronize&quot; do
       end.should raise_error(Exception)
     end
 
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     m1.locked?.should be_true
     m2.unlock</diff>
      <filename>library/mutex/synchronize_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ describe &quot;Mutex#try_lock&quot; do
       m2.lock
     end
 
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     # th owns m1 so try_lock should return false
     m1.try_lock.should be_false</diff>
      <filename>library/mutex/try_lock_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ describe &quot;Mutex#unlock&quot; do
     end
 
     # avoid race on mutex.lock
-    Thread.pass until th.status == &quot;sleep&quot;
+    Thread.pass while th.status and th.status != &quot;sleep&quot;
 
     lambda { mutex.unlock }.should raise_error(ThreadError)
 </diff>
      <filename>library/mutex/unlock_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,7 @@ describe &quot;BasicSocket#recv&quot; do
       data = client.recv(10)
       client.close
     end
-    Thread.pass until t.status == &quot;sleep&quot; or t.status == nil
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     t.status.should_not be_nil
 
     socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
@@ -37,7 +37,7 @@ describe &quot;BasicSocket#recv&quot; do
       data = client.recv(10)    # in-band data (TCP), doesn't receive the flag.
       client.close
     end
-    Thread.pass until t.status == &quot;sleep&quot; or t.status == nil
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     t.status.should_not be_nil
     
     socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)</diff>
      <filename>library/socket/basicsocket/recv_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ describe &quot;BasicSocket#send&quot; do
        data = client.recv(5)
        client.close
      end
-     Thread.pass until t.status == &quot;sleep&quot; or t.status == nil
+     Thread.pass while t.status and t.status != &quot;sleep&quot;
      t.status.should_not be_nil
 
      @socket.send('hello', 0).should == 5
@@ -40,7 +40,7 @@ describe &quot;BasicSocket#send&quot; do
        data = client.recv(6)
        client.close
      end
-     Thread.pass until t.status == &quot;sleep&quot; or t.status == nil
+     Thread.pass while t.status and t.status != &quot;sleep&quot;
      t.status.should_not be_nil
 
      @socket.send('helloU', Socket::MSG_PEEK | Socket::MSG_OOB).should == 6
@@ -57,7 +57,7 @@ describe &quot;BasicSocket#send&quot; do
        data = client.recv(5)
        client.close
      end
-     Thread.pass until t.status == &quot;sleep&quot; or t.status == nil
+     Thread.pass while t.status and t.status != &quot;sleep&quot;
      t.status.should_not be_nil
 
      sockaddr = Socket.pack_sockaddr_in(SocketSpecs.port, &quot;127.0.0.1&quot;)</diff>
      <filename>library/socket/basicsocket/send_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,7 @@ describe &quot;TCPServer#accept&quot; do
       client &lt;&lt; &quot;goodbye&quot;
       client.close
     end
-    Thread.pass until t.status == &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
     
     socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
     socket.write('hello')
@@ -33,7 +33,7 @@ describe &quot;TCPServer#accept&quot; do
   it &quot;can be interrupted by Thread#kill&quot; do
     t = Thread.new { @server.accept }
 
-    Thread.pass until t.status == &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
 
     # kill thread, ensure it dies in a reasonable amount of time
     t.kill
@@ -49,7 +49,7 @@ describe &quot;TCPServer#accept&quot; do
   it &quot;can be interrupted by Thread#raise&quot; do
     t = Thread.new { @server.accept }
 
-    Thread.pass until t.status == &quot;sleep&quot;
+    Thread.pass while t.status and t.status != &quot;sleep&quot;
 
     # raise in thread, ensure the raise happens
     ex = Exception.new</diff>
      <filename>library/socket/tcpserver/accept_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,7 @@ describe :tcpsocket_new, :shared =&gt; true do
       server.accept
       server.close
     end
-    Thread.pass until thread.status == 'sleep' or thread.status == nil
+    Thread.pass while thread.status and thread.status != 'sleep'
     thread.status.should_not be_nil
     lambda {
       sock = TCPSocket.new(@hostname, SocketSpecs.port)
@@ -34,7 +34,7 @@ describe :tcpsocket_new, :shared =&gt; true do
       server.accept
       server.close
     end
-    Thread.pass until thread.status == 'sleep' or thread.status == nil
+    Thread.pass while thread.status and thread.status != 'sleep'
     thread.status.should_not be_nil
     sock = TCPSocket.new('127.0.0.1', SocketSpecs.port)
     sock.addr[0].should == &quot;AF_INET&quot;</diff>
      <filename>library/socket/tcpsocket/shared/new.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,11 @@
 require File.dirname(__FILE__) + '/../../../spec_helper'
 require File.dirname(__FILE__) + '/../fixtures/classes'
 
-describe &quot;UNIXSocket#recvfrom&quot; do
+describe &quot;UNIXServer#recvfrom&quot; do
 
   platform_is_not :windows do
     before :each do
+      FileUtils.rm(SocketSpecs.socket_path, :force =&gt; true)
       @path = SocketSpecs.socket_path
 
       @server = UNIXServer.open(@path)</diff>
      <filename>library/socket/unixserver/accept_nonblock_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ platform_is_not :windows do
       t = Thread.new {
         server.accept
       }
-      Thread.pass until t.status == &quot;sleep&quot;
+      Thread.pass while t.status and t.status != &quot;sleep&quot;
 
       # kill thread, ensure it dies in a reasonable amount of time
       t.kill
@@ -51,7 +51,7 @@ platform_is_not :windows do
       t = Thread.new {
         server.accept
       }
-      Thread.pass until t.status == &quot;sleep&quot;
+      Thread.pass while t.status and t.status != &quot;sleep&quot;
 
       # raise in thread, ensure the raise happens
       ex = Exception.new</diff>
      <filename>library/socket/unixserver/accept_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e4a5124b63a93fb6181c5a87fa678a059d6c8d7a</id>
    </parent>
  </parents>
  <author>
    <name>Brian Ford</name>
    <email>bford@engineyard.com</email>
  </author>
  <url>http://github.com/rubyspec/rubyspec/commit/26b33df3b2440a2d4f3fee4a44f6df9de3fb8aab</url>
  <id>26b33df3b2440a2d4f3fee4a44f6df9de3fb8aab</id>
  <committed-date>2009-04-27T21:20:08-07:00</committed-date>
  <authored-date>2009-04-27T21:20:04-07:00</authored-date>
  <message>Fixed specs passing until a thread is asleep.

According to ri Thread#status, the following values may be returned:

  &quot;run&quot;
  &quot;aborting&quot;
  &quot;sleep&quot;
  false
  nil

where false is returned if a thread exits normally and nil if a thread
exits with an exception. Thread#alive? returns true if a thread's
status is &quot;run&quot; or &quot;sleep&quot;.

In the specs, to pass until a thread is asleep, the following is required:

  Thread.pass while t.status and t.status != 'sleep'

If the thread exits normally or with exception before this code runs,
it will not loop infinitely like it would if the following is used:

  Thread.pass until t.status == 'sleep'

Note that the following is not a substitute for the proper way above:

  Thread.pass until t.status == 'sleep' || !t.alive?

since t.alive? would return false for an aborting thread.</message>
  <tree>0e22d3f14b5a1942b2c214077c1b9fc1469ff74d</tree>
  <committer>
    <name>Brian Ford</name>
    <email>bford@engineyard.com</email>
  </committer>
</commit>
