aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-15 17:44:37 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-15 17:44:37 +0000
commit30ed82e7724093bb3c2015a818c28c3592134bba (patch)
tree5445b9e26d9ee173fa3735007f3e2b42791d2ec5 /spec/ruby/library
parentf941bdf263dcc16ea4e6b4576341882b89567c0b (diff)
downloadruby-30ed82e7724093bb3c2015a818c28c3592134bba.tar.gz
Update to ruby/spec@595645f
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/date/shared/valid_jd.rb4
-rw-r--r--spec/ruby/library/matrix/build_spec.rb2
-rw-r--r--spec/ruby/library/set/case_compare_spec.rb15
-rw-r--r--spec/ruby/library/set/inspect_spec.rb15
-rw-r--r--spec/ruby/library/set/shared/include.rb22
-rw-r--r--spec/ruby/library/set/shared/inspect.rb15
-rw-r--r--spec/ruby/library/set/to_s_spec.rb13
-rw-r--r--spec/ruby/library/socket/udpsocket/new_spec.rb6
-rw-r--r--spec/ruby/library/stringio/pos_spec.rb2
9 files changed, 75 insertions, 19 deletions
diff --git a/spec/ruby/library/date/shared/valid_jd.rb b/spec/ruby/library/date/shared/valid_jd.rb
index d8a35992b3..bd71f5abba 100644
--- a/spec/ruby/library/date/shared/valid_jd.rb
+++ b/spec/ruby/library/date/shared/valid_jd.rb
@@ -1,8 +1,8 @@
describe :date_valid_jd?, shared: true do
it "returns true if passed any value other than nil" do
Date.send(@method, -100).should be_true
- Date.send(@method, :number).should be_true
- Date.send(@method, Rational(1,2)).should be_true
+ Date.send(@method, :number).should be_true
+ Date.send(@method, Rational(1,2)).should be_true
end
it "returns false if passed nil" do
diff --git a/spec/ruby/library/matrix/build_spec.rb b/spec/ruby/library/matrix/build_spec.rb
index 29fd72206f..4f80ed2b99 100644
--- a/spec/ruby/library/matrix/build_spec.rb
+++ b/spec/ruby/library/matrix/build_spec.rb
@@ -24,7 +24,7 @@ describe "Matrix.build" do
it "returns an Enumerator is no block is given" do
enum = Matrix.build(2, 1)
- enum.should be_an_instance_of(Enumerator)
+ enum.should be_an_instance_of(Enumerator)
enum.each{1}.should == Matrix[[1], [1]]
end
diff --git a/spec/ruby/library/set/case_compare_spec.rb b/spec/ruby/library/set/case_compare_spec.rb
new file mode 100644
index 0000000000..f47e4e20c2
--- /dev/null
+++ b/spec/ruby/library/set/case_compare_spec.rb
@@ -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
+
diff --git a/spec/ruby/library/set/inspect_spec.rb b/spec/ruby/library/set/inspect_spec.rb
index 8a6c565c2e..ef91b11645 100644
--- a/spec/ruby/library/set/inspect_spec.rb
+++ b/spec/ruby/library/set/inspect_spec.rb
@@ -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
diff --git a/spec/ruby/library/set/shared/include.rb b/spec/ruby/library/set/shared/include.rb
index d41f8f4102..b4d95cde24 100644
--- a/spec/ruby/library/set/shared/include.rb
+++ b/spec/ruby/library/set/shared/include.rb
@@ -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
diff --git a/spec/ruby/library/set/shared/inspect.rb b/spec/ruby/library/set/shared/inspect.rb
new file mode 100644
index 0000000000..69fbdd12f6
--- /dev/null
+++ b/spec/ruby/library/set/shared/inspect.rb
@@ -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
diff --git a/spec/ruby/library/set/to_s_spec.rb b/spec/ruby/library/set/to_s_spec.rb
new file mode 100644
index 0000000000..f4c361f74f
--- /dev/null
+++ b/spec/ruby/library/set/to_s_spec.rb
@@ -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
diff --git a/spec/ruby/library/socket/udpsocket/new_spec.rb b/spec/ruby/library/socket/udpsocket/new_spec.rb
index 5a2e4e1f31..f13e605959 100644
--- a/spec/ruby/library/socket/udpsocket/new_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/new_spec.rb
@@ -26,7 +26,9 @@ describe 'UDPSocket.new' do
@socket.should be_an_instance_of(UDPSocket)
end
- it 'raises Errno::EAFNOSUPPORT if unsupported family passed' do
- lambda { UDPSocket.new(-1) }.should raise_error(Errno::EAFNOSUPPORT)
+ it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT if unsupported family passed' do
+ lambda { UDPSocket.new(-1) }.should raise_error(SystemCallError) { |e|
+ [Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should include(e.class)
+ }
end
end
diff --git a/spec/ruby/library/stringio/pos_spec.rb b/spec/ruby/library/stringio/pos_spec.rb
index 59d0a43f12..d5f3c3ab95 100644
--- a/spec/ruby/library/stringio/pos_spec.rb
+++ b/spec/ruby/library/stringio/pos_spec.rb
@@ -17,7 +17,7 @@ describe "StringIO#pos=" do
end
it "raises an EINVAL if given a negative argument" do
- lambda { @io.pos = -10 }.should raise_error(Errno::EINVAL)
+ lambda { @io.pos = -10 }.should raise_error(Errno::EINVAL)
end
it "updates the current byte offset after reaching EOF" do