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
|
@ -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