mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@691755d
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c555bd7f01
commit
52d2636f3e
18 changed files with 134 additions and 26 deletions
|
@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require 'date'
|
||||
|
||||
describe "Date#day" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
it "returns the day" do
|
||||
d = Date.new(2000, 7, 1).day
|
||||
d.should == 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require 'date'
|
||||
|
||||
describe "Date#month" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
it "returns the month" do
|
||||
m = Date.new(2000, 7, 1).month
|
||||
m.should == 7
|
||||
end
|
||||
end
|
||||
|
|
14
spec/ruby/library/date/next_month_spec.rb
Normal file
14
spec/ruby/library/date/next_month_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require 'date'
|
||||
|
||||
describe "Date#next_month" do
|
||||
it "returns the next month" do
|
||||
d = Date.new(2000, 7, 1).next_month
|
||||
d.should == Date.new(2000, 8, 1)
|
||||
end
|
||||
|
||||
it "returns three months later" do
|
||||
d = Date.new(2000, 7, 1).next_month(3)
|
||||
d.should == Date.new(2000, 10, 1)
|
||||
end
|
||||
end
|
14
spec/ruby/library/date/prev_day_spec.rb
Normal file
14
spec/ruby/library/date/prev_day_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require 'date'
|
||||
|
||||
describe "Date#prev_day" do
|
||||
it "returns previous day" do
|
||||
d = Date.new(2000, 7, 2).prev_day
|
||||
d.should == Date.new(2000, 7, 1)
|
||||
end
|
||||
|
||||
it "returns three days ago" do
|
||||
d = Date.new(2000, 7, 4).prev_day(3)
|
||||
d.should == Date.new(2000, 7, 1)
|
||||
end
|
||||
end
|
14
spec/ruby/library/date/prev_month_spec.rb
Normal file
14
spec/ruby/library/date/prev_month_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require 'date'
|
||||
|
||||
describe "Date#prev_month" do
|
||||
it "returns previous month" do
|
||||
d = Date.new(2000, 9, 1).prev_month
|
||||
d.should == Date.new(2000, 8, 1)
|
||||
end
|
||||
|
||||
it "returns three months ago" do
|
||||
d = Date.new(2000, 10, 1).prev_month(3)
|
||||
d.should == Date.new(2000, 7, 1)
|
||||
end
|
||||
end
|
|
@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|||
require 'date'
|
||||
|
||||
describe "Date#year" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
it "returns the year" do
|
||||
y = Date.new(2000, 7, 1).year
|
||||
y.should == 2000
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ with_feature :fiber_library do
|
|||
# We can always transfer to the root Fiber; it will never die
|
||||
5.times do
|
||||
root.transfer.should be_nil
|
||||
root.alive?.should_not be_false #Workaround for bug #1547
|
||||
root.alive?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -19,39 +19,31 @@ with_feature :fiber_library do
|
|||
this = Fiber.current
|
||||
this.should be_an_instance_of(Fiber)
|
||||
this.should == fiber
|
||||
this.alive?.should_not be_false # Workaround for bug #1547
|
||||
this.alive?.should be_true
|
||||
end
|
||||
fiber.resume
|
||||
end
|
||||
|
||||
it "returns the current Fiber when called from a Fiber that transferred to another" do
|
||||
|
||||
states = []
|
||||
fiber = Fiber.new do
|
||||
states << :fiber
|
||||
this = Fiber.current
|
||||
this.should be_an_instance_of(Fiber)
|
||||
this.should === fiber
|
||||
this.alive?.should_not be_false # Workaround for bug #1547
|
||||
this.should == fiber
|
||||
this.alive?.should be_true
|
||||
end
|
||||
|
||||
fiber2 = Fiber.new do
|
||||
states << :fiber2
|
||||
fiber.transfer
|
||||
this = Fiber.current
|
||||
this.should be_an_instance_of(Fiber)
|
||||
this.should === fiber2
|
||||
this.alive?.should_not be_false # Workaround for bug #1547
|
||||
flunk
|
||||
end
|
||||
|
||||
fiber3 = Fiber.new do
|
||||
states << :fiber3
|
||||
fiber2.transfer
|
||||
this = Fiber.current
|
||||
this.should be_an_instance_of(Fiber)
|
||||
this.should === fiber3
|
||||
this.alive?.should_not be_false # Workaround for bug #1547
|
||||
fiber2.transfer
|
||||
flunk
|
||||
end
|
||||
|
||||
fiber3.resume
|
||||
|
|
|
@ -7,9 +7,15 @@ describe "SortedSet#add" do
|
|||
|
||||
it "takes only values which responds <=>" do
|
||||
obj = mock('no_comparison_operator')
|
||||
obj.should_receive(:respond_to?).with(:<=>).and_return(false)
|
||||
obj.stub!(:respond_to?).with(:<=>).and_return(false)
|
||||
lambda { SortedSet["hello"].add(obj) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises on incompatible <=> comparison" do
|
||||
# Use #to_a here as elements are sorted only when needed.
|
||||
# Therefore the <=> incompatibility is only noticed on sorting.
|
||||
lambda { SortedSet['1', '2'].add(3).to_a }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "SortedSet#add?" do
|
||||
|
|
|
@ -21,4 +21,10 @@ describe "SortedSet#initialize" do
|
|||
s.should include(4)
|
||||
s.should include(9)
|
||||
end
|
||||
|
||||
it "raises on incompatible <=> comparison" do
|
||||
# Use #to_a here as elements are sorted only when needed.
|
||||
# Therefore the <=> incompatibility is only noticed on sorting.
|
||||
lambda { SortedSet.new(['00', nil]).to_a }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,16 @@ require File.expand_path('../../../../spec_helper', __FILE__)
|
|||
require 'set'
|
||||
|
||||
describe "SortedSet#to_a" do
|
||||
it "returns an array containing elements of self" do
|
||||
SortedSet[1, 2, 3].to_a.sort.should == [1, 2, 3]
|
||||
it "returns an array containing elements" do
|
||||
set = SortedSet.new [1, 2, 3]
|
||||
set.to_a.should == [1, 2, 3]
|
||||
end
|
||||
|
||||
it "returns a sorted array containing elements" do
|
||||
set = SortedSet[2, 3, 1]
|
||||
set.to_a.should == [1, 2, 3]
|
||||
|
||||
set = SortedSet.new [5, 6, 4, 4]
|
||||
set.to_a.should == [4, 5, 6]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue