mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@595645f
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f941bdf263
commit
30ed82e772
39 changed files with 1078 additions and 105 deletions
15
spec/ruby/library/set/case_compare_spec.rb
Normal file
15
spec/ruby/library/set/case_compare_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/include', __FILE__)
|
||||
require 'set'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Set#===" do
|
||||
it_behaves_like :set_include, :===
|
||||
|
||||
it "is an alias for include?" do
|
||||
set = Set.new
|
||||
set.method(:===).should == set.method(:include?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +1,7 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/inspect', __FILE__)
|
||||
require 'set'
|
||||
|
||||
describe "Set#inspect" do
|
||||
it "returns a String representation of self" do
|
||||
Set[].inspect.should be_kind_of(String)
|
||||
Set[nil, false, true].inspect.should be_kind_of(String)
|
||||
Set[1, 2, 3].inspect.should be_kind_of(String)
|
||||
Set["1", "2", "3"].inspect.should be_kind_of(String)
|
||||
Set[:a, "b", Set[?c]].inspect.should be_kind_of(String)
|
||||
end
|
||||
|
||||
it "correctly handles self-references" do
|
||||
(set = Set[]) << set
|
||||
set.inspect.should be_kind_of(String)
|
||||
set.inspect.should include("#<Set: {...}>")
|
||||
end
|
||||
it_behaves_like :set_inspect, :inspect
|
||||
end
|
||||
|
|
|
@ -4,4 +4,26 @@ describe :set_include, shared: true do
|
|||
set.send(@method, :a).should be_true
|
||||
set.send(@method, :e).should be_false
|
||||
end
|
||||
|
||||
describe "member equality" do
|
||||
it "is checked using both #hash and #eql?" do
|
||||
obj = Object.new
|
||||
obj_another = Object.new
|
||||
|
||||
def obj.hash; 42 end
|
||||
def obj_another.hash; 42 end
|
||||
def obj_another.eql?(o) hash == o.hash end
|
||||
|
||||
set = Set["a", "b", "c", obj]
|
||||
set.send(@method, obj_another).should == true
|
||||
end
|
||||
|
||||
it "is not checked using #==" do
|
||||
obj = Object.new
|
||||
set = Set["a", "b", "c"]
|
||||
|
||||
obj.should_not_receive(:==)
|
||||
set.send(@method, obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
15
spec/ruby/library/set/shared/inspect.rb
Normal file
15
spec/ruby/library/set/shared/inspect.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
describe "set_inspect", shared: true do
|
||||
it "returns a String representation of self" do
|
||||
Set[].send(@method).should be_kind_of(String)
|
||||
Set[nil, false, true].send(@method).should be_kind_of(String)
|
||||
Set[1, 2, 3].send(@method).should be_kind_of(String)
|
||||
Set["1", "2", "3"].send(@method).should be_kind_of(String)
|
||||
Set[:a, "b", Set[?c]].send(@method).should be_kind_of(String)
|
||||
end
|
||||
|
||||
it "correctly handles self-references" do
|
||||
(set = Set[]) << set
|
||||
set.send(@method).should be_kind_of(String)
|
||||
set.send(@method).should include("#<Set: {...}>")
|
||||
end
|
||||
end
|
13
spec/ruby/library/set/to_s_spec.rb
Normal file
13
spec/ruby/library/set/to_s_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../shared/inspect', __FILE__)
|
||||
require 'set'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Set#to_s" do
|
||||
it_behaves_like :set_inspect, :to_s
|
||||
|
||||
it "is an alias of inspect" do
|
||||
set = Set.new
|
||||
set.method(:to_s).should == set.method(:inspect)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue