ruby-changes:59939
From: Nobuyoshi <ko1@a...>
Date: Thu, 6 Feb 2020 20:57:43 +0900 (JST)
Subject: [ruby-changes:59939] 739fdb7ff0 (master): [ruby/spec] Don't care about return values
https://git.ruby-lang.org/ruby.git/commit/?id=739fdb7ff0 From 739fdb7ff0767ae4a666ca83f61e807c0c6c7115 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 6 Feb 2020 15:42:01 +0900 Subject: [ruby/spec] Don't care about return values RDoc says nothing about them. Added an example that ConditionVariable#wait can be woken up by ConditionVariable#signal, instead. diff --git a/spec/ruby/library/conditionvariable/broadcast_spec.rb b/spec/ruby/library/conditionvariable/broadcast_spec.rb index 1dccdf4..d88159d 100644 --- a/spec/ruby/library/conditionvariable/broadcast_spec.rb +++ b/spec/ruby/library/conditionvariable/broadcast_spec.rb @@ -2,33 +2,6 @@ require_relative '../../spec_helper' https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/conditionvariable/broadcast_spec.rb#L2 require 'thread' describe "ConditionVariable#broadcast" do - it "returns self if nothing to broadcast to" do - cv = ConditionVariable.new - cv.broadcast.should == cv - end - - it "returns self if something is waiting for a broadcast" do - m = Mutex.new - cv = ConditionVariable.new - in_synchronize = false - - th = Thread.new do - m.synchronize do - in_synchronize = true - cv.wait(m) - end - end - - # wait for m to acquire the mutex - Thread.pass until in_synchronize - # wait until th is sleeping (ie waiting) - Thread.pass until th.stop? - - m.synchronize { cv.broadcast }.should == cv - - th.join - end - it "releases all threads waiting in line for this resource" do m = Mutex.new cv = ConditionVariable.new diff --git a/spec/ruby/library/conditionvariable/signal_spec.rb b/spec/ruby/library/conditionvariable/signal_spec.rb index bcab421..11e4909 100644 --- a/spec/ruby/library/conditionvariable/signal_spec.rb +++ b/spec/ruby/library/conditionvariable/signal_spec.rb @@ -2,33 +2,6 @@ require_relative '../../spec_helper' https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/conditionvariable/signal_spec.rb#L2 require 'thread' describe "ConditionVariable#signal" do - it "returns self if nothing to signal" do - cv = ConditionVariable.new - cv.signal.should == cv - end - - it "returns self if something is waiting for a signal" do - m = Mutex.new - cv = ConditionVariable.new - in_synchronize = false - - th = Thread.new do - m.synchronize do - in_synchronize = true - cv.wait(m) - end - end - - # wait for m to acquire the mutex - Thread.pass until in_synchronize - # wait until th is sleeping (ie waiting) - Thread.pass until th.stop? - - m.synchronize { cv.signal }.should == cv - - th.join - end - it "releases the first thread waiting in line for this resource" do m = Mutex.new cv = ConditionVariable.new diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb index b6cd12e..b545c6c 100644 --- a/spec/ruby/library/conditionvariable/wait_spec.rb +++ b/spec/ruby/library/conditionvariable/wait_spec.rb @@ -11,7 +11,7 @@ describe "ConditionVariable#wait" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/conditionvariable/wait_spec.rb#L11 cv.wait(o, 1234) end - it "returns self" do + it "can be woken up by ConditionVariable#signal" do m = Mutex.new cv = ConditionVariable.new in_synchronize = false @@ -19,8 +19,9 @@ describe "ConditionVariable#wait" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/conditionvariable/wait_spec.rb#L19 th = Thread.new do m.synchronize do in_synchronize = true - cv.wait(m).should == cv + cv.wait(m) end + :success end # wait for m to acquire the mutex @@ -29,7 +30,7 @@ describe "ConditionVariable#wait" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/conditionvariable/wait_spec.rb#L30 Thread.pass until th.stop? m.synchronize { cv.signal } - th.join + th.value.should == :success end it "can be interrupted by Thread#run" do -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/