summaryrefslogtreecommitdiff
path: root/spec/ruby/core
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core')
-rw-r--r--spec/ruby/core/argf/close_spec.rb19
-rw-r--r--spec/ruby/core/argf/read_nonblock_spec.rb8
-rw-r--r--spec/ruby/core/argf/readpartial_spec.rb16
-rw-r--r--spec/ruby/core/array/bsearch_index_spec.rb118
-rw-r--r--spec/ruby/core/array/dig_spec.rb96
-rw-r--r--spec/ruby/core/array/flatten_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/j_spec.rb306
-rw-r--r--spec/ruby/core/array/shared/delete_if.rb24
-rw-r--r--spec/ruby/core/array/shared/inspect.rb21
-rw-r--r--spec/ruby/core/comparable/equal_value_spec.rb37
-rw-r--r--spec/ruby/core/dir/close_spec.rb20
-rw-r--r--spec/ruby/core/dir/shared/glob.rb9
-rw-r--r--spec/ruby/core/enumerable/chunk_spec.rb33
-rw-r--r--spec/ruby/core/enumerable/chunk_while_spec.rb60
-rw-r--r--spec/ruby/core/enumerable/grep_v_spec.rb56
-rw-r--r--spec/ruby/core/enumerable/slice_before_spec.rb31
-rw-r--r--spec/ruby/core/enumerator/lazy/grep_v_spec.rb118
-rw-r--r--spec/ruby/core/enumerator/lazy/uniq_spec.rb6
-rw-r--r--spec/ruby/core/exception/backtrace_locations_spec.rb39
-rw-r--r--spec/ruby/core/exception/fixtures/common.rb10
-rw-r--r--spec/ruby/core/exception/full_message_spec.rb38
-rw-r--r--spec/ruby/core/exception/name_spec.rb36
-rw-r--r--spec/ruby/core/exception/receiver_spec.rb90
-rw-r--r--spec/ruby/core/file/mkfifo_spec.rb72
-rw-r--r--spec/ruby/core/file/open_spec.rb64
-rw-r--r--spec/ruby/core/file/shared/unlink.rb16
-rw-r--r--spec/ruby/core/file/stat/ino_spec.rb18
-rw-r--r--spec/ruby/core/hash/compare_by_identity_spec.rb2
-rw-r--r--spec/ruby/core/hash/dig_spec.rb106
-rw-r--r--spec/ruby/core/hash/fetch_values_spec.rb38
-rw-r--r--spec/ruby/core/hash/fixtures/classes.rb7
-rw-r--r--spec/ruby/core/hash/gt_spec.rb60
-rw-r--r--spec/ruby/core/hash/gte_spec.rb60
-rw-r--r--spec/ruby/core/hash/initialize_spec.rb23
-rw-r--r--spec/ruby/core/hash/lt_spec.rb60
-rw-r--r--spec/ruby/core/hash/lte_spec.rb60
-rw-r--r--spec/ruby/core/hash/shared/to_s.rb21
-rw-r--r--spec/ruby/core/hash/to_proc_spec.rb118
-rw-r--r--spec/ruby/core/io/binread_spec.rb6
-rw-r--r--spec/ruby/core/io/close_on_exec_spec.rb24
-rw-r--r--spec/ruby/core/io/close_read_spec.rb32
-rw-r--r--spec/ruby/core/io/close_spec.rb15
-rw-r--r--spec/ruby/core/io/close_write_spec.rb32
-rw-r--r--spec/ruby/core/io/each_codepoint_spec.rb6
-rw-r--r--spec/ruby/core/io/read_nonblock_spec.rb24
-rw-r--r--spec/ruby/core/io/write_nonblock_spec.rb10
-rw-r--r--spec/ruby/core/kernel/define_singleton_method_spec.rb18
-rw-r--r--spec/ruby/core/kernel/loop_spec.rb16
-rw-r--r--spec/ruby/core/kernel/require_relative_spec.rb42
-rw-r--r--spec/ruby/core/kernel/shared/require.rb16
-rw-r--r--spec/ruby/core/main/using_spec.rb215
-rw-r--r--spec/ruby/core/module/autoload_spec.rb77
-rw-r--r--spec/ruby/core/module/define_method_spec.rb20
-rw-r--r--spec/ruby/core/module/deprecate_constant_spec.rb74
-rw-r--r--spec/ruby/core/module/prepend_spec.rb10
-rw-r--r--spec/ruby/core/module/private_spec.rb58
-rw-r--r--spec/ruby/core/numeric/negative_spec.rb56
-rw-r--r--spec/ruby/core/numeric/positive_spec.rb56
-rw-r--r--spec/ruby/core/objectspace/each_object_spec.rb21
-rw-r--r--spec/ruby/core/process/status/exitstatus_spec.rb14
-rw-r--r--spec/ruby/core/process/status/termsig_spec.rb12
-rw-r--r--spec/ruby/core/random/urandom_spec.rb2
-rw-r--r--spec/ruby/core/signal/signame_spec.rb12
-rw-r--r--spec/ruby/core/string/crypt_spec.rb6
-rw-r--r--spec/ruby/core/string/new_spec.rb10
-rw-r--r--spec/ruby/core/string/shared/each_line.rb23
-rw-r--r--spec/ruby/core/string/uminus_spec.rb64
-rw-r--r--spec/ruby/core/string/unpack/j_spec.rb414
-rw-r--r--spec/ruby/core/string/uplus_spec.rb30
-rw-r--r--spec/ruby/core/struct/dig_spec.rb62
-rw-r--r--spec/ruby/core/thread/name_spec.rb102
-rw-r--r--spec/ruby/core/time/at_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/disable_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/enable_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/new_spec.rb2
75 files changed, 1686 insertions, 1827 deletions
diff --git a/spec/ruby/core/argf/close_spec.rb b/spec/ruby/core/argf/close_spec.rb
index 0fc9a1894a..56faf30664 100644
--- a/spec/ruby/core/argf/close_spec.rb
+++ b/spec/ruby/core/argf/close_spec.rb
@@ -20,21 +20,10 @@ describe "ARGF.close" do
end
end
- ruby_version_is ""..."2.3" do
- it "raises an IOError if called on a closed stream" do
- argf [@file1_name] do
- lambda { @argf.close }.should_not raise_error
- lambda { @argf.close }.should raise_error(IOError)
- end
- end
- end
-
- ruby_version_is "2.3" do
- it "doesn't raise an IOError if called on a closed stream" do
- argf [@file1_name] do
- lambda { @argf.close }.should_not raise_error
- lambda { @argf.close }.should_not raise_error
- end
+ it "doesn't raise an IOError if called on a closed stream" do
+ argf [@file1_name] do
+ lambda { @argf.close }.should_not raise_error
+ lambda { @argf.close }.should_not raise_error
end
end
end
diff --git a/spec/ruby/core/argf/read_nonblock_spec.rb b/spec/ruby/core/argf/read_nonblock_spec.rb
index 51201421a5..466264119f 100644
--- a/spec/ruby/core/argf/read_nonblock_spec.rb
+++ b/spec/ruby/core/argf/read_nonblock_spec.rb
@@ -70,11 +70,9 @@ platform_is_not :windows do
end
end
- ruby_version_is "2.3" do
- it 'returns :wait_readable when the :exception is set to false' do
- argf ['-'] do
- @argf.read_nonblock(4, nil, exception: false).should == :wait_readable
- end
+ it 'returns :wait_readable when the :exception is set to false' do
+ argf ['-'] do
+ @argf.read_nonblock(4, nil, exception: false).should == :wait_readable
end
end
end
diff --git a/spec/ruby/core/argf/readpartial_spec.rb b/spec/ruby/core/argf/readpartial_spec.rb
index 70b0312261..4e697683dc 100644
--- a/spec/ruby/core/argf/readpartial_spec.rb
+++ b/spec/ruby/core/argf/readpartial_spec.rb
@@ -54,15 +54,13 @@ describe "ARGF.readpartial" do
end
end
- ruby_version_is "2.3" do
- it "raises an EOFError if the exception was raised while reading the last file" do
- argf [@file1_name, @file2_name] do
- @argf.readpartial(@file1.size)
- @argf.readpartial(1)
- @argf.readpartial(@file2.size)
- lambda { @argf.readpartial(1) }.should raise_error(EOFError)
- lambda { @argf.readpartial(1) }.should raise_error(EOFError)
- end
+ it "raises an EOFError if the exception was raised while reading the last file" do
+ argf [@file1_name, @file2_name] do
+ @argf.readpartial(@file1.size)
+ @argf.readpartial(1)
+ @argf.readpartial(@file2.size)
+ lambda { @argf.readpartial(1) }.should raise_error(EOFError)
+ lambda { @argf.readpartial(1) }.should raise_error(EOFError)
end
end
diff --git a/spec/ruby/core/array/bsearch_index_spec.rb b/spec/ruby/core/array/bsearch_index_spec.rb
index 49c9d9ea34..a075d06ed3 100644
--- a/spec/ruby/core/array/bsearch_index_spec.rb
+++ b/spec/ruby/core/array/bsearch_index_spec.rb
@@ -1,86 +1,84 @@
require_relative '../../spec_helper'
require_relative '../enumerable/shared/enumeratorized'
-ruby_version_is "2.3" do
- describe "Array#bsearch_index" do
- context "when not passed a block" do
- before :each do
- @enum = [1, 2, 42, 100, 666].bsearch_index
- end
+describe "Array#bsearch_index" do
+ context "when not passed a block" do
+ before :each do
+ @enum = [1, 2, 42, 100, 666].bsearch_index
+ end
- it "returns an Enumerator" do
- @enum.should be_an_instance_of(Enumerator)
- end
+ it "returns an Enumerator" do
+ @enum.should be_an_instance_of(Enumerator)
+ end
- it "returns an Enumerator with unknown size" do
- @enum.size.should be_nil
- end
+ it "returns an Enumerator with unknown size" do
+ @enum.size.should be_nil
+ end
- it "returns index of element when block condition is satisfied" do
- @enum.each { |x| x >= 33 }.should == 2
- end
+ it "returns index of element when block condition is satisfied" do
+ @enum.each { |x| x >= 33 }.should == 2
end
+ end
+
+ it "raises a TypeError when block returns a String" do
+ lambda { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError)
+ end
- it "raises a TypeError when block returns a String" do
- lambda { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError)
+ it "returns nil when block is empty" do
+ [1, 2, 3].bsearch_index {}.should be_nil
+ end
+
+ context "minimum mode" do
+ before :each do
+ @array = [0, 4, 7, 10, 12]
end
- it "returns nil when block is empty" do
- [1, 2, 3].bsearch_index {}.should be_nil
+ it "returns index of first element which satisfies the block" do
+ @array.bsearch_index { |x| x >= 4 }.should == 1
+ @array.bsearch_index { |x| x >= 6 }.should == 2
+ @array.bsearch_index { |x| x >= -1 }.should == 0
end
- context "minimum mode" do
- before :each do
- @array = [0, 4, 7, 10, 12]
- end
+ it "returns nil when block condition is never satisfied" do
+ @array.bsearch_index { false }.should be_nil
+ @array.bsearch_index { |x| x >= 100 }.should be_nil
+ end
+ end
- it "returns index of first element which satisfies the block" do
- @array.bsearch_index { |x| x >= 4 }.should == 1
- @array.bsearch_index { |x| x >= 6 }.should == 2
- @array.bsearch_index { |x| x >= -1 }.should == 0
- end
+ context "find any mode" do
+ before :each do
+ @array = [0, 4, 7, 10, 12]
+ end
- it "returns nil when block condition is never satisfied" do
- @array.bsearch_index { false }.should be_nil
- @array.bsearch_index { |x| x >= 100 }.should be_nil
- end
+ it "returns the index of any matched elements where element is between 4 <= x < 8" do
+ [1, 2].should include(@array.bsearch_index { |x| 1 - x / 4 })
end
- context "find any mode" do
- before :each do
- @array = [0, 4, 7, 10, 12]
- end
+ it "returns the index of any matched elements where element is between 8 <= x < 10" do
+ @array.bsearch_index { |x| 4 - x / 2 }.should be_nil
+ end
- it "returns the index of any matched elements where element is between 4 <= x < 8" do
- [1, 2].should include(@array.bsearch_index { |x| 1 - x / 4 })
- end
+ it "returns nil when block never returns 0" do
+ @array.bsearch_index { |x| 1 }.should be_nil
+ @array.bsearch_index { |x| -1 }.should be_nil
+ end
- it "returns the index of any matched elements where element is between 8 <= x < 10" do
- @array.bsearch_index { |x| 4 - x / 2 }.should be_nil
- end
+ it "returns the middle element when block always returns zero" do
+ @array.bsearch_index { |x| 0 }.should == 2
+ end
- it "returns nil when block never returns 0" do
- @array.bsearch_index { |x| 1 }.should be_nil
- @array.bsearch_index { |x| -1 }.should be_nil
+ context "magnitude does not effect the result" do
+ it "returns the index of any matched elements where element is between 4n <= xn < 8n" do
+ [1, 2].should include(@array.bsearch_index { |x| (1 - x / 4) * (2**100) })
end
- it "returns the middle element when block always returns zero" do
- @array.bsearch_index { |x| 0 }.should == 2
+ it "returns nil when block never returns 0" do
+ @array.bsearch_index { |x| 1 * (2**100) }.should be_nil
+ @array.bsearch_index { |x| (-1) * (2**100) }.should be_nil
end
- context "magnitude does not effect the result" do
- it "returns the index of any matched elements where element is between 4n <= xn < 8n" do
- [1, 2].should include(@array.bsearch_index { |x| (1 - x / 4) * (2**100) })
- end
-
- it "returns nil when block never returns 0" do
- @array.bsearch_index { |x| 1 * (2**100) }.should be_nil
- @array.bsearch_index { |x| (-1) * (2**100) }.should be_nil
- end
-
- it "handles values from Bignum#coerce" do
- [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first })
- end
+ it "handles values from Bignum#coerce" do
+ [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first })
end
end
end
diff --git a/spec/ruby/core/array/dig_spec.rb b/spec/ruby/core/array/dig_spec.rb
index 0a47eb0b13..1ace4893ee 100644
--- a/spec/ruby/core/array/dig_spec.rb
+++ b/spec/ruby/core/array/dig_spec.rb
@@ -1,54 +1,52 @@
require_relative '../../spec_helper'
-ruby_version_is '2.3' do
- describe "Array#dig" do
-
- it "returns #at with one arg" do
- ['a'].dig(0).should == 'a'
- ['a'].dig(1).should be_nil
- end
-
- it "recurses array elements" do
- a = [ [ 1, [2, '3'] ] ]
- a.dig(0, 0).should == 1
- a.dig(0, 1, 1).should == '3'
- a.dig(0, -1, 0).should == 2
- end
-
- it "returns the nested value specified if the sequence includes a key" do
- a = [42, { foo: :bar }]
- a.dig(1, :foo).should == :bar
- end
-
- it "raises a TypeError for a non-numeric index" do
- lambda {
- ['a'].dig(:first)
- }.should raise_error(TypeError)
- end
-
- it "raises a TypeError if any intermediate step does not respond to #dig" do
- a = [1, 2]
- lambda {
- a.dig(0, 1)
- }.should raise_error(TypeError)
- end
-
- it "raises an ArgumentError if no arguments provided" do
- lambda {
- [10].dig()
- }.should raise_error(ArgumentError)
- end
-
- it "returns nil if any intermediate step is nil" do
- a = [[1, [2, 3]]]
- a.dig(1, 2, 3).should == nil
- end
-
- it "calls #dig on the result of #at with the remaining arguments" do
- h = [[nil, [nil, nil, 42]]]
- h[0].should_receive(:dig).with(1, 2).and_return(42)
- h.dig(0, 1, 2).should == 42
- end
+describe "Array#dig" do
+ it "returns #at with one arg" do
+ ['a'].dig(0).should == 'a'
+ ['a'].dig(1).should be_nil
end
+
+ it "recurses array elements" do
+ a = [ [ 1, [2, '3'] ] ]
+ a.dig(0, 0).should == 1
+ a.dig(0, 1, 1).should == '3'
+ a.dig(0, -1, 0).should == 2
+ end
+
+ it "returns the nested value specified if the sequence includes a key" do
+ a = [42, { foo: :bar }]
+ a.dig(1, :foo).should == :bar
+ end
+
+ it "raises a TypeError for a non-numeric index" do
+ lambda {
+ ['a'].dig(:first)
+ }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError if any intermediate step does not respond to #dig" do
+ a = [1, 2]
+ lambda {
+ a.dig(0, 1)
+ }.should raise_error(TypeError)
+ end
+
+ it "raises an ArgumentError if no arguments provided" do
+ lambda {
+ [10].dig()
+ }.should raise_error(ArgumentError)
+ end
+
+ it "returns nil if any intermediate step is nil" do
+ a = [[1, [2, 3]]]
+ a.dig(1, 2, 3).should == nil
+ end
+
+ it "calls #dig on the result of #at with the remaining arguments" do
+ h = [[nil, [nil, nil, 42]]]
+ h[0].should_receive(:dig).with(1, 2).and_return(42)
+ h.dig(0, 1, 2).should == 42
+ end
+
end
diff --git a/spec/ruby/core/array/flatten_spec.rb b/spec/ruby/core/array/flatten_spec.rb
index a274a01d89..1b7361552a 100644
--- a/spec/ruby/core/array/flatten_spec.rb
+++ b/spec/ruby/core/array/flatten_spec.rb
@@ -69,12 +69,10 @@ describe "Array#flatten" do
[1, z, 6].flatten.should == [1, 2, 3, 4, 5, 6]
end
- ruby_version_is "2.3" do
- it "does not call #to_ary on elements beyond the given level" do
- obj = mock("1")
- obj.should_not_receive(:to_ary)
- [[obj]].flatten(1)
- end
+ it "does not call #to_ary on elements beyond the given level" do
+ obj = mock("1")
+ obj.should_not_receive(:to_ary)
+ [[obj]].flatten(1)
end
it "returns subclass instance for Array subclasses" do
diff --git a/spec/ruby/core/array/pack/j_spec.rb b/spec/ruby/core/array/pack/j_spec.rb
index 3a38ef6db7..7b62d5efdf 100644
--- a/spec/ruby/core/array/pack/j_spec.rb
+++ b/spec/ruby/core/array/pack/j_spec.rb
@@ -4,216 +4,214 @@ require_relative 'shared/basic'
require_relative 'shared/numeric_basic'
require_relative 'shared/integer'
-ruby_version_is '2.3' do
- platform_is pointer_size: 64 do
- describe "Array#pack with format 'J'" do
- it_behaves_like :array_pack_basic, 'J'
- it_behaves_like :array_pack_basic_non_float, 'J'
- it_behaves_like :array_pack_arguments, 'J'
- it_behaves_like :array_pack_numeric_basic, 'J'
- it_behaves_like :array_pack_integer, 'J'
- end
-
- describe "Array#pack with format 'j'" do
- it_behaves_like :array_pack_basic, 'j'
- it_behaves_like :array_pack_basic_non_float, 'j'
- it_behaves_like :array_pack_arguments, 'j'
- it_behaves_like :array_pack_numeric_basic, 'j'
- it_behaves_like :array_pack_integer, 'j'
- end
+platform_is pointer_size: 64 do
+ describe "Array#pack with format 'J'" do
+ it_behaves_like :array_pack_basic, 'J'
+ it_behaves_like :array_pack_basic_non_float, 'J'
+ it_behaves_like :array_pack_arguments, 'J'
+ it_behaves_like :array_pack_numeric_basic, 'J'
+ it_behaves_like :array_pack_integer, 'J'
+ end
- little_endian do
- describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_le, 'J_'
- end
+ describe "Array#pack with format 'j'" do
+ it_behaves_like :array_pack_basic, 'j'
+ it_behaves_like :array_pack_basic_non_float, 'j'
+ it_behaves_like :array_pack_arguments, 'j'
+ it_behaves_like :array_pack_numeric_basic, 'j'
+ it_behaves_like :array_pack_integer, 'j'
+ end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_le, 'J!'
- end
+ little_endian do
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_le, 'J_'
end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_le, 'j_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_le, 'j!'
- end
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_le, 'J!'
end
end
- big_endian do
- describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_be, 'J_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_be, 'J!'
- end
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_le, 'j_'
end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_64bit_be, 'j_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :array_pack_64bit_be, 'j!'
- end
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_le, 'j!'
end
end
+ end
+ big_endian do
describe "Array#pack with format 'J'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_64bit_le, 'J<_'
- it_behaves_like :array_pack_64bit_le, 'J_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_64bit_le, 'J<!'
- it_behaves_like :array_pack_64bit_le, 'J!<'
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_be, 'J_'
end
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_64bit_be, 'J>_'
- it_behaves_like :array_pack_64bit_be, 'J_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_64bit_be, 'J>!'
- it_behaves_like :array_pack_64bit_be, 'J!>'
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_be, 'J!'
end
end
describe "Array#pack with format 'j'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_64bit_le, 'j<_'
- it_behaves_like :array_pack_64bit_le, 'j_<'
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_64bit_be, 'j_'
end
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_64bit_le, 'j<!'
- it_behaves_like :array_pack_64bit_le, 'j!<'
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_64bit_be, 'j!'
end
+ end
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_64bit_be, 'j>_'
- it_behaves_like :array_pack_64bit_be, 'j_>'
- end
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_64bit_le, 'J<_'
+ it_behaves_like :array_pack_64bit_le, 'J_<'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_64bit_be, 'j>!'
- it_behaves_like :array_pack_64bit_be, 'j!>'
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_64bit_le, 'J<!'
+ it_behaves_like :array_pack_64bit_le, 'J!<'
end
- end
- platform_is pointer_size: 32 do
- describe "Array#pack with format 'J'" do
- it_behaves_like :array_pack_basic, 'J'
- it_behaves_like :array_pack_basic_non_float, 'J'
- it_behaves_like :array_pack_arguments, 'J'
- it_behaves_like :array_pack_numeric_basic, 'J'
- it_behaves_like :array_pack_integer, 'J'
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_64bit_be, 'J>_'
+ it_behaves_like :array_pack_64bit_be, 'J_>'
end
- describe "Array#pack with format 'j'" do
- it_behaves_like :array_pack_basic, 'j'
- it_behaves_like :array_pack_basic_non_float, 'j'
- it_behaves_like :array_pack_arguments, 'j'
- it_behaves_like :array_pack_numeric_basic, 'j'
- it_behaves_like :array_pack_integer, 'j'
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_64bit_be, 'J>!'
+ it_behaves_like :array_pack_64bit_be, 'J!>'
end
+ end
- big_endian do
- describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_be, 'J_'
- end
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_64bit_le, 'j<_'
+ it_behaves_like :array_pack_64bit_le, 'j_<'
+ end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_be, 'J!'
- end
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_64bit_le, 'j<!'
+ it_behaves_like :array_pack_64bit_le, 'j!<'
+ end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_be, 'j_'
- end
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_64bit_be, 'j>_'
+ it_behaves_like :array_pack_64bit_be, 'j_>'
+ end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_be, 'j!'
- end
- end
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_64bit_be, 'j>!'
+ it_behaves_like :array_pack_64bit_be, 'j!>'
end
+ end
+end
- little_endian do
- describe "Array#pack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_le, 'J_'
- end
+platform_is pointer_size: 32 do
+ describe "Array#pack with format 'J'" do
+ it_behaves_like :array_pack_basic, 'J'
+ it_behaves_like :array_pack_basic_non_float, 'J'
+ it_behaves_like :array_pack_arguments, 'J'
+ it_behaves_like :array_pack_numeric_basic, 'J'
+ it_behaves_like :array_pack_integer, 'J'
+ end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_le, 'J!'
- end
- end
+ describe "Array#pack with format 'j'" do
+ it_behaves_like :array_pack_basic, 'j'
+ it_behaves_like :array_pack_basic_non_float, 'j'
+ it_behaves_like :array_pack_arguments, 'j'
+ it_behaves_like :array_pack_numeric_basic, 'j'
+ it_behaves_like :array_pack_integer, 'j'
+ end
- describe "Array#pack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :array_pack_32bit_le, 'j_'
- end
+ big_endian do
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_be, 'J_'
+ end
- describe "with modifier '!'" do
- it_behaves_like :array_pack_32bit_le, 'j!'
- end
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_be, 'J!'
end
end
- describe "Array#pack with format 'J'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_32bit_le, 'J<_'
- it_behaves_like :array_pack_32bit_le, 'J_<'
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_be, 'j_'
end
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_32bit_le, 'J<!'
- it_behaves_like :array_pack_32bit_le, 'J!<'
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_be, 'j!'
end
+ end
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_32bit_be, 'J>_'
- it_behaves_like :array_pack_32bit_be, 'J_>'
+ little_endian do
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_le, 'J_'
end
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_32bit_be, 'J>!'
- it_behaves_like :array_pack_32bit_be, 'J!>'
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_le, 'J!'
end
end
describe "Array#pack with format 'j'" do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_32bit_le, 'j<_'
- it_behaves_like :array_pack_32bit_le, 'j_<'
+ describe "with modifier '_'" do
+ it_behaves_like :array_pack_32bit_le, 'j_'
end
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_32bit_le, 'j<!'
- it_behaves_like :array_pack_32bit_le, 'j!<'
+ describe "with modifier '!'" do
+ it_behaves_like :array_pack_32bit_le, 'j!'
end
+ end
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_32bit_be, 'j>_'
- it_behaves_like :array_pack_32bit_be, 'j_>'
- end
+ describe "Array#pack with format 'J'" do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_32bit_le, 'J<_'
+ it_behaves_like :array_pack_32bit_le, 'J_<'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_32bit_be, 'j>!'
- it_behaves_like :array_pack_32bit_be, 'j!>'
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_32bit_le, 'J<!'
+ it_behaves_like :array_pack_32bit_le, 'J!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_32bit_be, 'J>_'
+ it_behaves_like :array_pack_32bit_be, 'J_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_32bit_be, 'J>!'
+ it_behaves_like :array_pack_32bit_be, 'J!>'
+ end
+ end
+
+ describe "Array#pack with format 'j'" do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_32bit_le, 'j<_'
+ it_behaves_like :array_pack_32bit_le, 'j_<'
+ end
+
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_32bit_le, 'j<!'
+ it_behaves_like :array_pack_32bit_le, 'j!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_32bit_be, 'j>_'
+ it_behaves_like :array_pack_32bit_be, 'j_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_32bit_be, 'j>!'
+ it_behaves_like :array_pack_32bit_be, 'j!>'
end
end
end
diff --git a/spec/ruby/core/array/shared/delete_if.rb b/spec/ruby/core/array/shared/delete_if.rb
index a9fb57e0d9..a3fdcf4fac 100644
--- a/spec/ruby/core/array/shared/delete_if.rb
+++ b/spec/ruby/core/array/shared/delete_if.rb
@@ -3,25 +3,11 @@ describe :delete_if, shared: true do
@object = [1,2,3]
end
- ruby_version_is "2.3" do
- it "updates the receiver after all blocks" do
- @object.send(@method) do |e|
- @object.length.should == 3
- true
- end
- @object.length.should == 0
- end
- end
-
- ruby_version_is ""..."2.3" do
- it "updates the receiver after each true block" do
- count = 0
- @object.send(@method) do |e|
- @object.length.should == (3 - count)
- count += 1
- true
- end
- @object.length.should == 0
+ it "updates the receiver after all blocks" do
+ @object.send(@method) do |e|
+ @object.length.should == 3
+ true
end
+ @object.length.should == 0
end
end
diff --git a/spec/ruby/core/array/shared/inspect.rb b/spec/ruby/core/array/shared/inspect.rb
index 0cf5035b37..1bcc9f9ca8 100644
--- a/spec/ruby/core/array/shared/inspect.rb
+++ b/spec/ruby/core/array/shared/inspect.rb
@@ -121,24 +121,11 @@ describe :array_inspect, shared: true do
array.send(@method).encoding.name.should == "US-ASCII"
end
- ruby_version_is ''...'2.3' do
- it "raises if inspected result is not default external encoding" do
- utf_16be = mock("utf_16be")
- utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
-
- lambda {
- [utf_16be].send(@method)
- }.should raise_error(Encoding::CompatibilityError)
- end
- end
-
- ruby_version_is '2.3' do
- it "does not raise if inspected result is not default external encoding" do
- utf_16be = mock("utf_16be")
- utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
+ it "does not raise if inspected result is not default external encoding" do
+ utf_16be = mock("utf_16be")
+ utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
- [utf_16be].send(@method).should == '["utf_16be \u3042"]'
- end
+ [utf_16be].send(@method).should == '["utf_16be \u3042"]'
end
end
end
diff --git a/spec/ruby/core/comparable/equal_value_spec.rb b/spec/ruby/core/comparable/equal_value_spec.rb
index 24d9fec2fb..53c83aa2d3 100644
--- a/spec/ruby/core/comparable/equal_value_spec.rb
+++ b/spec/ruby/core/comparable/equal_value_spec.rb
@@ -48,16 +48,8 @@ describe "Comparable#==" do
a.should_receive(:<=>).once.and_return("abc")
end
- ruby_version_is ""..."2.3" do
- it "returns false" do
- (a == b).should be_false
- end
- end
-
- ruby_version_is "2.3" do
- it "raises an ArgumentError" do
- lambda { (a == b) }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError" do
+ lambda { (a == b) }.should raise_error(ArgumentError)
end
end
@@ -67,17 +59,8 @@ describe "Comparable#==" do
a.should_receive(:<=>).once.and_raise(StandardError)
end
- ruby_version_is ""..."2.3" do
- # Behaviour confirmed by MRI test suite
- it "returns false" do
- (a == b).should be_false
- end
- end
-
- ruby_version_is "2.3" do
- it "lets it go through" do
- lambda { (a == b) }.should raise_error(StandardError)
- end
+ it "lets it go through" do
+ lambda { (a == b) }.should raise_error(StandardError)
end
end
@@ -87,16 +70,8 @@ describe "Comparable#==" do
a.should_receive(:<=>).once.and_raise(TypeError)
end
- ruby_version_is ""..."2.3" do
- it "returns false" do
- (a == b).should be_false
- end
- end
-
- ruby_version_is "2.3" do
- it "lets it go through" do
- lambda { (a == b) }.should raise_error(TypeError)
- end
+ it "lets it go through" do
+ lambda { (a == b) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/dir/close_spec.rb b/spec/ruby/core/dir/close_spec.rb
index 1cf1f1d029..64d87140ae 100644
--- a/spec/ruby/core/dir/close_spec.rb
+++ b/spec/ruby/core/dir/close_spec.rb
@@ -1,9 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/common'
-ruby_version_is ''...'2.3' do
- require_relative 'shared/closed'
-end
-
describe "Dir#close" do
before :all do
DirSpecs.create_mock_dirs
@@ -13,17 +9,11 @@ describe "Dir#close" do
DirSpecs.delete_mock_dirs
end
- ruby_version_is ''...'2.3' do
- it_behaves_like :dir_closed, :close
- end
-
- ruby_version_is '2.3' do
- it "does not raise an IOError even if the Dir instance is closed" do
- dir = Dir.open DirSpecs.mock_dir
+ it "does not raise an IOError even if the Dir instance is closed" do
+ dir = Dir.open DirSpecs.mock_dir
+ dir.close
+ lambda {
dir.close
- lambda {
- dir.close
- }.should_not raise_error(IOError)
- end
+ }.should_not raise_error(IOError)
end
end
diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb
index 2fe22ac6c3..88ceb82c50 100644
--- a/spec/ruby/core/dir/shared/glob.rb
+++ b/spec/ruby/core/dir/shared/glob.rb
@@ -32,6 +32,15 @@ describe :dir_glob, shared: true do
end
end
+ ruby_version_is "2.6" do
+ it "splits the string on \\0 if there is only one string given and warns" do
+ -> {
+ Dir.send(@method, "file_o*\0file_t*").should ==
+ %w!file_one.ext file_two.ext!
+ }.should complain(/warning: use glob patterns list instead of nul-separated patterns/)
+ end
+ end
+
it "matches non-dotfiles with '*'" do
expected = %w[
brace
diff --git a/spec/ruby/core/enumerable/chunk_spec.rb b/spec/ruby/core/enumerable/chunk_spec.rb
index 9215d97fef..34fa651b33 100644
--- a/spec/ruby/core/enumerable/chunk_spec.rb
+++ b/spec/ruby/core/enumerable/chunk_spec.rb
@@ -62,34 +62,11 @@ describe "Enumerable#chunk" do
lambda { e.chunk { |x| :_arbitrary }.to_a }.should raise_error(RuntimeError)
end
- ruby_version_is ""..."2.3" do
- describe "with [initial_state]" do
- it "yields an element and an object value-equal but not identical to the object passed to #chunk" do
- e = EnumerableSpecs::Numerous.new(1)
- value = "value"
-
- e.chunk(value) do |x, v|
- x.should == 1
- v.should == value
- v.should_not equal(value)
- end.to_a
- end
-
- it "does not yield the object passed to #chunk if it is nil" do
- e = EnumerableSpecs::Numerous.new(1)
- e.chunk(nil) { |*x| ScratchPad << x }.to_a
- ScratchPad.recorded.should == [[1]]
- end
- end
- end
-
- ruby_version_is "2.3" do
- it "does not accept arguments" do
- e = EnumerableSpecs::Numerous.new(1, 2, 3)
- lambda {
- e.chunk(1) {}
- }.should raise_error(ArgumentError)
- end
+ it "does not accept arguments" do
+ e = EnumerableSpecs::Numerous.new(1, 2, 3)
+ lambda {
+ e.chunk(1) {}
+ }.should raise_error(ArgumentError)
end
it 'returned Enumerator size returns nil' do
diff --git a/spec/ruby/core/enumerable/chunk_while_spec.rb b/spec/ruby/core/enumerable/chunk_while_spec.rb
index 29645da1fe..88d6d2983f 100644
--- a/spec/ruby/core/enumerable/chunk_while_spec.rb
+++ b/spec/ruby/core/enumerable/chunk_while_spec.rb
@@ -1,44 +1,42 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "2.3" do
- describe "Enumerable#chunk_while" do
- before :each do
- ary = [10, 9, 7, 6, 4, 3, 2, 1]
- @enum = EnumerableSpecs::Numerous.new(*ary)
- @result = @enum.chunk_while { |i, j| i - 1 == j }
- @enum_length = ary.length
- end
+describe "Enumerable#chunk_while" do
+ before :each do
+ ary = [10, 9, 7, 6, 4, 3, 2, 1]
+ @enum = EnumerableSpecs::Numerous.new(*ary)
+ @result = @enum.chunk_while { |i, j| i - 1 == j }
+ @enum_length = ary.length
+ end
- context "when given a block" do
- it "returns an enumerator" do
- @result.should be_an_instance_of(Enumerator)
- end
+ context "when given a block" do
+ it "returns an enumerator" do
+ @result.should be_an_instance_of(Enumerator)
+ end
- it "splits chunks between adjacent elements i and j where the block returns false" do
- @result.to_a.should == [[10, 9], [7, 6], [4, 3, 2, 1]]
- end
+ it "splits chunks between adjacent elements i and j where the block returns false" do
+ @result.to_a.should == [[10, 9], [7, 6], [4, 3, 2, 1]]
+ end
- it "calls the block for length of the receiver enumerable minus one times" do
- times_called = 0
- @enum.chunk_while do |i, j|
- times_called += 1
- i - 1 == j
- end.to_a
- times_called.should == (@enum_length - 1)
- end
+ it "calls the block for length of the receiver enumerable minus one times" do
+ times_called = 0
+ @enum.chunk_while do |i, j|
+ times_called += 1
+ i - 1 == j
+ end.to_a
+ times_called.should == (@enum_length - 1)
end
+ end
- context "when not given a block" do
- it "raises an ArgumentError" do
- lambda { @enum.chunk_while }.should raise_error(ArgumentError)
- end
+ context "when not given a block" do
+ it "raises an ArgumentError" do
+ lambda { @enum.chunk_while }.should raise_error(ArgumentError)
end
+ end
- context "on a single-element array" do
- it "ignores the block and returns an enumerator that yields [element]" do
- [1].chunk_while {|x| x.even?}.to_a.should == [[1]]
- end
+ context "on a single-element array" do
+ it "ignores the block and returns an enumerator that yields [element]" do
+ [1].chunk_while {|x| x.even?}.to_a.should == [[1]]
end
end
end
diff --git a/spec/ruby/core/enumerable/grep_v_spec.rb b/spec/ruby/core/enumerable/grep_v_spec.rb
index 8d8bc28d5e..2268005dee 100644
--- a/spec/ruby/core/enumerable/grep_v_spec.rb
+++ b/spec/ruby/core/enumerable/grep_v_spec.rb
@@ -1,43 +1,41 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "2.3" do
- describe "Enumerable#grep_v" do
- before :each do
- @numerous = EnumerableSpecs::Numerous.new(*(0..9).to_a)
- def (@odd_matcher = BasicObject.new).===(obj)
- obj.odd?
- end
+describe "Enumerable#grep_v" do
+ before :each do
+ @numerous = EnumerableSpecs::Numerous.new(*(0..9).to_a)
+ def (@odd_matcher = BasicObject.new).===(obj)
+ obj.odd?
end
+ end
- describe "without block" do
- it "returns an Array of matched elements" do
- @numerous.grep_v(@odd_matcher).should == [0, 2, 4, 6, 8]
- end
+ describe "without block" do
+ it "returns an Array of matched elements" do
+ @numerous.grep_v(@odd_matcher).should == [0, 2, 4, 6, 8]
+ end
- it "compares pattern with gathered array when yielded with multiple arguments" do
- (unmatcher = Object.new).stub!(:===).and_return(false)
- EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher).should == EnumerableSpecs::YieldsMixed2.gathered_yields
- end
+ it "compares pattern with gathered array when yielded with multiple arguments" do
+ (unmatcher = Object.new).stub!(:===).and_return(false)
+ EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher).should == EnumerableSpecs::YieldsMixed2.gathered_yields
+ end
- it "raises an ArgumentError when not given a pattern" do
- -> { @numerous.grep_v }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError when not given a pattern" do
+ -> { @numerous.grep_v }.should raise_error(ArgumentError)
end
+ end
- describe "with block" do
- it "returns an Array of matched elements that mapped by the block" do
- @numerous.grep_v(@odd_matcher) { |n| n * 2 }.should == [0, 4, 8, 12, 16]
- end
+ describe "with block" do
+ it "returns an Array of matched elements that mapped by the block" do
+ @numerous.grep_v(@odd_matcher) { |n| n * 2 }.should == [0, 4, 8, 12, 16]
+ end
- it "calls the block with gathered array when yielded with multiple arguments" do
- (unmatcher = Object.new).stub!(:===).and_return(false)
- EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher){ |e| e }.should == EnumerableSpecs::YieldsMixed2.gathered_yields
- end
+ it "calls the block with gathered array when yielded with multiple arguments" do
+ (unmatcher = Object.new).stub!(:===).and_return(false)
+ EnumerableSpecs::YieldsMixed2.new.grep_v(unmatcher){ |e| e }.should == EnumerableSpecs::YieldsMixed2.gathered_yields
+ end
- it "raises an ArgumentError when not given a pattern" do
- -> { @numerous.grep_v { |e| e } }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError when not given a pattern" do
+ -> { @numerous.grep_v { |e| e } }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/core/enumerable/slice_before_spec.rb b/spec/ruby/core/enumerable/slice_before_spec.rb
index 932d06072a..ad730be245 100644
--- a/spec/ruby/core/enumerable/slice_before_spec.rb
+++ b/spec/ruby/core/enumerable/slice_before_spec.rb
@@ -40,33 +40,10 @@ describe "Enumerable#slice_before" do
end
end
- ruby_version_is ""..."2.3" do
- describe "and an argument" do
- it "calls the block with a copy of that argument" do
- arg = [:foo]
- first = nil
- e = @enum.slice_before(arg) do |i, init|
- init.should == arg
- init.should_not equal(arg)
- first = init
- i == 6 || i == 2
- end
- e.should be_an_instance_of(Enumerator)
- e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]]
- e = @enum.slice_before(arg) do |i, init|
- init.should_not equal(first)
- end
- e.to_a
- end
- end
- end
-
- ruby_version_is "2.3" do
- it "does not accept arguments" do
- lambda {
- @enum.slice_before(1) {}
- }.should raise_error(ArgumentError)
- end
+ it "does not accept arguments" do
+ lambda {
+ @enum.slice_before(1) {}
+ }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/enumerator/lazy/grep_v_spec.rb b/spec/ruby/core/enumerator/lazy/grep_v_spec.rb
index 79f8760055..a0ec819505 100644
--- a/spec/ruby/core/enumerator/lazy/grep_v_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/grep_v_spec.rb
@@ -1,86 +1,84 @@
require_relative '../../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "2.3" do
- describe "Enumerator::Lazy#grep_v" do
- before(:each) do
- @yieldsmixed = EnumeratorLazySpecs::YieldsMixed.new.to_enum.lazy
- @eventsmixed = EnumeratorLazySpecs::EventsMixed.new.to_enum.lazy
- ScratchPad.record []
- end
+describe "Enumerator::Lazy#grep_v" do
+ before(:each) do
+ @yieldsmixed = EnumeratorLazySpecs::YieldsMixed.new.to_enum.lazy
+ @eventsmixed = EnumeratorLazySpecs::EventsMixed.new.to_enum.lazy
+ ScratchPad.record []
+ end
- after(:each) do
- ScratchPad.clear
- end
+ after(:each) do
+ ScratchPad.clear
+ end
+
+ it "requires an argument" do
+ Enumerator::Lazy.instance_method(:grep_v).arity.should == 1
+ end
+
+ it "returns a new instance of Enumerator::Lazy" do
+ ret = @yieldsmixed.grep_v(Object) {}
+ ret.should be_an_instance_of(Enumerator::Lazy)
+ ret.should_not equal(@yieldsmixed)
- it "requires an argument" do
- Enumerator::Lazy.instance_method(:grep_v).arity.should == 1
+ ret = @yieldsmixed.grep_v(Object)
+ ret.should be_an_instance_of(Enumerator::Lazy)
+ ret.should_not equal(@yieldsmixed)
+ end
+
+ it "sets #size to nil" do
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object) {}.size.should == nil
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).size.should == nil
+ end
+
+ describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
+ it "stops after specified times when not given a block" do
+ (0..Float::INFINITY).lazy.grep_v(3..5).first(3).should == [0, 1, 2]
+
+ @eventsmixed.grep_v(Symbol).first(1)
+ ScratchPad.recorded.should == [:before_yield]
end
- it "returns a new instance of Enumerator::Lazy" do
- ret = @yieldsmixed.grep_v(Object) {}
- ret.should be_an_instance_of(Enumerator::Lazy)
- ret.should_not equal(@yieldsmixed)
+ it "stops after specified times when given a block" do
+ (0..Float::INFINITY).lazy.grep_v(4..8, &:succ).first(3).should == [1, 2, 3]
- ret = @yieldsmixed.grep_v(Object)
- ret.should be_an_instance_of(Enumerator::Lazy)
- ret.should_not equal(@yieldsmixed)
+ @eventsmixed.grep_v(Symbol) {}.first(1)
+ ScratchPad.recorded.should == [:before_yield]
end
+ end
+
+ it "calls the block with a gathered array when yield with multiple arguments" do
+ yields = []
+ @yieldsmixed.grep_v(Array) { |v| yields << v }.force
+ yields.should == EnumeratorLazySpecs::YieldsMixed.gathered_non_array_yields
+ @yieldsmixed.grep_v(Array).force.should == yields
+ end
+
+ describe "on a nested Lazy" do
it "sets #size to nil" do
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object) {}.size.should == nil
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).size.should == nil
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object) {}.size.should == nil
+ Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object).size.should == nil
end
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
it "stops after specified times when not given a block" do
- (0..Float::INFINITY).lazy.grep_v(3..5).first(3).should == [0, 1, 2]
+ (0..Float::INFINITY).lazy.grep_v(3..5).grep_v(6..10).first(3).should == [0, 1, 2]
- @eventsmixed.grep_v(Symbol).first(1)
+ @eventsmixed.grep_v(Symbol).grep_v(String).first(1)
ScratchPad.recorded.should == [:before_yield]
end
it "stops after specified times when given a block" do
- (0..Float::INFINITY).lazy.grep_v(4..8, &:succ).first(3).should == [1, 2, 3]
+ (0..Float::INFINITY).lazy
+ .grep_v(1..2) { |n| n > 3 ? n : false }
+ .grep_v(false) { |n| n.even? ? n : false }
+ .first(3)
+ .should == [4, false, 6]
- @eventsmixed.grep_v(Symbol) {}.first(1)
+ @eventsmixed.grep_v(Symbol) {}.grep_v(String) {}.first(1)
ScratchPad.recorded.should == [:before_yield]
end
end
-
- it "calls the block with a gathered array when yield with multiple arguments" do
- yields = []
- @yieldsmixed.grep_v(Array) { |v| yields << v }.force
- yields.should == EnumeratorLazySpecs::YieldsMixed.gathered_non_array_yields
-
- @yieldsmixed.grep_v(Array).force.should == yields
- end
-
- describe "on a nested Lazy" do
- it "sets #size to nil" do
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object) {}.size.should == nil
- Enumerator::Lazy.new(Object.new, 100) {}.grep_v(Object).grep_v(Object).size.should == nil
- end
-
- describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
- it "stops after specified times when not given a block" do
- (0..Float::INFINITY).lazy.grep_v(3..5).grep_v(6..10).first(3).should == [0, 1, 2]
-
- @eventsmixed.grep_v(Symbol).grep_v(String).first(1)
- ScratchPad.recorded.should == [:before_yield]
- end
-
- it "stops after specified times when given a block" do
- (0..Float::INFINITY).lazy
- .grep_v(1..2) { |n| n > 3 ? n : false }
- .grep_v(false) { |n| n.even? ? n : false }
- .first(3)
- .should == [4, false, 6]
-
- @eventsmixed.grep_v(Symbol) {}.grep_v(String) {}.first(1)
- ScratchPad.recorded.should == [:before_yield]
- end
- end
- end
end
end
diff --git a/spec/ruby/core/enumerator/lazy/uniq_spec.rb b/spec/ruby/core/enumerator/lazy/uniq_spec.rb
index 3c9acdc453..fea2bec637 100644
--- a/spec/ruby/core/enumerator/lazy/uniq_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/uniq_spec.rb
@@ -13,7 +13,7 @@ ruby_version_is '2.4' do
@lazy.force.should == [0, 1]
end
- ruby_bug "#14495", "2.4"..."2.5.1" do
+ ruby_bug "#14495", "2.4"..."2.5.2" do
it 'return same value after rewind' do
@lazy.force.should == [0, 1]
@lazy.force.should == [0, 1]
@@ -35,7 +35,7 @@ ruby_version_is '2.4' do
@lazy.force.should == [0, 1]
end
- ruby_bug "#14495", "2.4"..."2.5.1" do
+ ruby_bug "#14495", "2.4"..."2.5.2" do
it 'return same value after rewind' do
@lazy.force.should == [0, 1]
@lazy.force.should == [0, 1]
@@ -60,7 +60,7 @@ ruby_version_is '2.4' do
@lazy = enum.lazy
end
- ruby_bug "#14495", "2.4"..."2.5.1" do
+ ruby_bug "#14495", "2.4"..."2.5.2" do
it 'return same value after rewind' do
enum = @lazy.uniq { |_, label| label.downcase }
enum.force.should == [[0, 'foo'], [2, 'bar']]
diff --git a/spec/ruby/core/exception/backtrace_locations_spec.rb b/spec/ruby/core/exception/backtrace_locations_spec.rb
new file mode 100644
index 0000000000..86eb9d3413
--- /dev/null
+++ b/spec/ruby/core/exception/backtrace_locations_spec.rb
@@ -0,0 +1,39 @@
+require_relative '../../spec_helper'
+require_relative 'fixtures/common'
+
+describe "Exception#backtrace_locations" do
+ before :each do
+ @backtrace = ExceptionSpecs::Backtrace.backtrace_locations
+ end
+
+ it "returns nil if no backtrace was set" do
+ Exception.new.backtrace_locations.should be_nil
+ end
+
+ it "returns an Array" do
+ @backtrace.should be_an_instance_of(Array)
+ end
+
+ it "sets each element to a Thread::Backtrace::Location" do
+ @backtrace.each {|l| l.should be_an_instance_of(Thread::Backtrace::Location)}
+ end
+
+ it "produces a backtrace for an exception captured using $!" do
+ exception = begin
+ raise
+ rescue RuntimeError
+ $!
+ end
+
+ exception.backtrace_locations.first.path.should =~ /backtrace_locations_spec/
+ end
+
+ it "returns an Array that can be updated" do
+ begin
+ raise
+ rescue RuntimeError => e
+ e.backtrace_locations.unshift "backtrace first"
+ e.backtrace_locations[0].should == "backtrace first"
+ end
+ end
+end
diff --git a/spec/ruby/core/exception/fixtures/common.rb b/spec/ruby/core/exception/fixtures/common.rb
index e1ba102197..9ddabace11 100644
--- a/spec/ruby/core/exception/fixtures/common.rb
+++ b/spec/ruby/core/exception/fixtures/common.rb
@@ -4,11 +4,19 @@ module ExceptionSpecs
class Backtrace
def self.backtrace
begin
- raise # Do not move this line or update backtrace_spec.rb
+ raise # If you move this line, update backtrace_spec.rb
rescue RuntimeError => e
e.backtrace
end
end
+
+ def self.backtrace_locations
+ begin
+ raise
+ rescue RuntimeError => e
+ e.backtrace_locations
+ end
+ end
end
class UnExceptional < Exception
diff --git a/spec/ruby/core/exception/full_message_spec.rb b/spec/ruby/core/exception/full_message_spec.rb
new file mode 100644
index 0000000000..f56282d67b
--- /dev/null
+++ b/spec/ruby/core/exception/full_message_spec.rb
@@ -0,0 +1,38 @@
+require_relative '../../spec_helper'
+
+ruby_version_is "2.5" do
+ describe "Exception#full_message" do
+ it "returns formatted string of exception using the same format that is used to print an uncaught exceptions to stderr" do
+ e = RuntimeError.new("Some runtime error")
+ e.set_backtrace(["a.rb:1", "b.rb:2"])
+
+ full_message = e.full_message
+ full_message.should include "RuntimeError"
+ full_message.should include "Some runtime error"
+ full_message.should include "a.rb:1"
+ full_message.should include "b.rb:2"
+ end
+
+ ruby_version_is "2.5.1" do
+ it "supports :highlight option and adds escape sequences to highlight some strings" do
+ e = RuntimeError.new("Some runtime error")
+
+ full_message = e.full_message(highlight: true, order: :bottom)
+ full_message.should include "\e[1mTraceback\e[m (most recent call last)"
+ full_message.should include "\e[1mSome runtime error (\e[1;4mRuntimeError\e[m\e[1m)"
+
+ full_message = e.full_message(highlight: false, order: :bottom)
+ full_message.should include "Traceback (most recent call last)"
+ full_message.should include "Some runtime error (RuntimeError)"
+ end
+
+ it "supports :order option and places the error message and the backtrace at the top or the bottom" do
+ e = RuntimeError.new("Some runtime error")
+ e.set_backtrace(["a.rb:1", "b.rb:2"])
+
+ e.full_message(order: :top, highlight: false).should =~ /a.rb:1.*b.rb:2/m
+ e.full_message(order: :bottom, highlight: false).should =~ /b.rb:2.*a.rb:1/m
+ end
+ end
+ end
+end
diff --git a/spec/ruby/core/exception/name_spec.rb b/spec/ruby/core/exception/name_spec.rb
index 5380432ddf..d1def51f24 100644
--- a/spec/ruby/core/exception/name_spec.rb
+++ b/spec/ruby/core/exception/name_spec.rb
@@ -27,35 +27,19 @@ describe "NameError#name" do
}.should raise_error(NameError) { |e| e.name.should == :@@doesnt_exist }
end
- ruby_version_is ""..."2.3" do
- it "always returns a symbol when a NameError is raised from #instance_variable_get" do
- -> {
- Object.new.instance_variable_get("invalid_ivar_name")
- }.should raise_error(NameError) { |e| e.name.should == :invalid_ivar_name }
- end
+ it "returns the first argument passed to the method when a NameError is raised from #instance_variable_get" do
+ invalid_ivar_name = "invalid_ivar_name"
- it "always returns a symbol when a NameError is raised from #class_variable_get" do
- -> {
- Object.class_variable_get("invalid_cvar_name")
- }.should raise_error(NameError) { |e| e.name.should == :invalid_cvar_name }
- end
+ -> {
+ Object.new.instance_variable_get(invalid_ivar_name)
+ }.should raise_error(NameError) {|e| e.name.should equal(invalid_ivar_name) }
end
- ruby_version_is "2.3" do
- it "returns the first argument passed to the method when a NameError is raised from #instance_variable_get" do
- invalid_ivar_name = "invalid_ivar_name"
-
- -> {
- Object.new.instance_variable_get(invalid_ivar_name)
- }.should raise_error(NameError) {|e| e.name.should equal(invalid_ivar_name) }
- end
-
- it "returns the first argument passed to the method when a NameError is raised from #class_variable_get" do
- invalid_cvar_name = "invalid_cvar_name"
+ it "returns the first argument passed to the method when a NameError is raised from #class_variable_get" do
+ invalid_cvar_name = "invalid_cvar_name"
- -> {
- Object.class_variable_get(invalid_cvar_name)
- }.should raise_error(NameError) {|e| e.name.should equal(invalid_cvar_name) }
- end
+ -> {
+ Object.class_variable_get(invalid_cvar_name)
+ }.should raise_error(NameError) {|e| e.name.should equal(invalid_cvar_name) }
end
end
diff --git a/spec/ruby/core/exception/receiver_spec.rb b/spec/ruby/core/exception/receiver_spec.rb
index c5fca7d73a..7c57d63c3e 100644
--- a/spec/ruby/core/exception/receiver_spec.rb
+++ b/spec/ruby/core/exception/receiver_spec.rb
@@ -1,62 +1,60 @@
require_relative '../../spec_helper'
require_relative 'fixtures/common'
-ruby_version_is "2.3" do
- describe "NameError#receiver" do
- class ::ReceiverClass
- def call_undefined_class_variable; @@doesnt_exist end
- end
+describe "NameError#receiver" do
+ class ::ReceiverClass
+ def call_undefined_class_variable; @@doesnt_exist end
+ end
- it "returns the object that raised the exception" do
- receiver = Object.new
+ it "returns the object that raised the exception" do
+ receiver = Object.new
- -> {
- receiver.doesnt_exist
- }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
- end
+ -> {
+ receiver.doesnt_exist
+ }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
+ end
- it "returns the Object class when an undefined constant is called without namespace" do
- -> {
- DoesntExist
- }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
- end
+ it "returns the Object class when an undefined constant is called without namespace" do
+ -> {
+ DoesntExist
+ }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
+ end
- it "returns a class when an undefined constant is called" do
- -> {
- NameErrorSpecs::ReceiverClass::DoesntExist
- }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
- end
+ it "returns a class when an undefined constant is called" do
+ -> {
+ NameErrorSpecs::ReceiverClass::DoesntExist
+ }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
+ end
- it "returns the Object class when an undefined class variable is called" do
+ it "returns the Object class when an undefined class variable is called" do
+ -> {
-> {
- -> {
- @@doesnt_exist
- }.should complain(/class variable access from toplevel/)
- }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
- end
+ @@doesnt_exist
+ }.should complain(/class variable access from toplevel/)
+ }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
+ end
- it "returns a class when an undefined class variable is called in a subclass' namespace" do
- -> {
- NameErrorSpecs::ReceiverClass.new.call_undefined_class_variable
- }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
- end
+ it "returns a class when an undefined class variable is called in a subclass' namespace" do
+ -> {
+ NameErrorSpecs::ReceiverClass.new.call_undefined_class_variable
+ }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) }
+ end
- it "returns the receiver when raised from #instance_variable_get" do
- receiver = Object.new
+ it "returns the receiver when raised from #instance_variable_get" do
+ receiver = Object.new
- -> {
- receiver.instance_variable_get("invalid_ivar_name")
- }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
- end
+ -> {
+ receiver.instance_variable_get("invalid_ivar_name")
+ }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) }
+ end
- it "returns the receiver when raised from #class_variable_get" do
- -> {
- Object.class_variable_get("invalid_cvar_name")
- }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
- end
+ it "returns the receiver when raised from #class_variable_get" do
+ -> {
+ Object.class_variable_get("invalid_cvar_name")
+ }.should raise_error(NameError) {|e| e.receiver.should equal(Object) }
+ end
- it "raises an ArgumentError when the receiver is none" do
- -> { NameError.new.receiver }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError when the receiver is none" do
+ -> { NameError.new.receiver }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/file/mkfifo_spec.rb b/spec/ruby/core/file/mkfifo_spec.rb
index f8842418af..a6db87a12e 100644
--- a/spec/ruby/core/file/mkfifo_spec.rb
+++ b/spec/ruby/core/file/mkfifo_spec.rb
@@ -1,53 +1,51 @@
require_relative '../../spec_helper'
-ruby_version_is "2.3" do
- describe "File.mkfifo" do
- platform_is_not :windows do
- before do
- @path = tmp('fifo')
- end
+describe "File.mkfifo" do
+ platform_is_not :windows do
+ before do
+ @path = tmp('fifo')
+ end
- after do
- rm_r(@path)
- end
+ after do
+ rm_r(@path)
+ end
- context "when path passed responds to :to_path" do
- it "creates a FIFO file at the path specified" do
- File.mkfifo(@path)
- File.ftype(@path).should == "fifo"
- end
+ context "when path passed responds to :to_path" do
+ it "creates a FIFO file at the path specified" do
+ File.mkfifo(@path)
+ File.ftype(@path).should == "fifo"
end
+ end
- context "when path passed is not a String value" do
- it "raises a TypeError" do
- lambda { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError)
- end
+ context "when path passed is not a String value" do
+ it "raises a TypeError" do
+ lambda { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError)
end
+ end
- context "when path does not exist" do
- it "raises an Errno::ENOENT exception" do
- lambda { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT)
- end
+ context "when path does not exist" do
+ it "raises an Errno::ENOENT exception" do
+ lambda { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT)
end
+ end
- it "creates a FIFO file at the passed path" do
- File.mkfifo(@path.to_s)
- File.ftype(@path).should == "fifo"
- end
+ it "creates a FIFO file at the passed path" do
+ File.mkfifo(@path.to_s)
+ File.ftype(@path).should == "fifo"
+ end
- it "creates a FIFO file with passed mode & ~umask" do
- File.mkfifo(@path, 0755)
- File.stat(@path).mode.should == 010755 & ~File.umask
- end
+ it "creates a FIFO file with passed mode & ~umask" do
+ File.mkfifo(@path, 0755)
+ File.stat(@path).mode.should == 010755 & ~File.umask
+ end
- it "creates a FIFO file with a default mode of 0666 & ~umask" do
- File.mkfifo(@path)
- File.stat(@path).mode.should == 010666 & ~File.umask
- end
+ it "creates a FIFO file with a default mode of 0666 & ~umask" do
+ File.mkfifo(@path)
+ File.stat(@path).mode.should == 010666 & ~File.umask
+ end
- it "returns 0 after creating the FIFO file" do
- File.mkfifo(@path).should == 0
- end
+ it "returns 0 after creating the FIFO file" do
+ File.mkfifo(@path).should == 0
end
end
end
diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb
index b5add5dff4..6ccac75a9a 100644
--- a/spec/ruby/core/file/open_spec.rb
+++ b/spec/ruby/core/file/open_spec.rb
@@ -524,28 +524,26 @@ describe "File.open" do
File.size(@file).should == 0
end
- ruby_version_is "2.3" do
- platform_is :linux do
- guard -> { defined?(File::TMPFILE) } do
- it "creates an unnamed temporary file with File::TMPFILE" do
- dir = tmp("tmpfilespec")
- mkdir_p dir
- begin
+ platform_is :linux do
+ guard -> { defined?(File::TMPFILE) } do
+ it "creates an unnamed temporary file with File::TMPFILE" do
+ dir = tmp("tmpfilespec")
+ mkdir_p dir
+ begin
+ Dir["#{dir}/*"].should == []
+ File.open(dir, "r+", flags: File::TMPFILE) do |io|
+ io.write("ruby")
+ io.flush
+ io.rewind
+ io.read.should == "ruby"
Dir["#{dir}/*"].should == []
- File.open(dir, "r+", flags: File::TMPFILE) do |io|
- io.write("ruby")
- io.flush
- io.rewind
- io.read.should == "ruby"
- Dir["#{dir}/*"].should == []
- end
- rescue Errno::EOPNOTSUPP, Errno::EINVAL
- # EOPNOTSUPP: no support from the filesystem
- # EINVAL: presumably bug in glibc
- 1.should == 1
- ensure
- rm_r dir
end
+ rescue Errno::EOPNOTSUPP, Errno::EINVAL
+ # EOPNOTSUPP: no support from the filesystem
+ # EINVAL: presumably bug in glibc
+ 1.should == 1
+ ensure
+ rm_r dir
end
end
end
@@ -586,22 +584,20 @@ describe "File.open" do
@fh = File.open(@file, options)
end
- ruby_version_is "2.3" do
- it "accepts extra flags as a keyword argument and combine with a string mode" do
- lambda {
- File.open(@file, "w", flags: File::EXCL) { }
- }.should raise_error(Errno::EEXIST)
+ it "accepts extra flags as a keyword argument and combine with a string mode" do
+ lambda {
+ File.open(@file, "w", flags: File::EXCL) { }
+ }.should raise_error(Errno::EEXIST)
- lambda {
- File.open(@file, mode: "w", flags: File::EXCL) { }
- }.should raise_error(Errno::EEXIST)
- end
+ lambda {
+ File.open(@file, mode: "w", flags: File::EXCL) { }
+ }.should raise_error(Errno::EEXIST)
+ end
- it "accepts extra flags as a keyword argument and combine with an integer mode" do
- lambda {
- File.open(@file, File::WRONLY | File::CREAT, flags: File::EXCL) { }
- }.should raise_error(Errno::EEXIST)
- end
+ it "accepts extra flags as a keyword argument and combine with an integer mode" do
+ lambda {
+ File.open(@file, File::WRONLY | File::CREAT, flags: File::EXCL) { }
+ }.should raise_error(Errno::EEXIST)
end
platform_is_not :windows do
diff --git a/spec/ruby/core/file/shared/unlink.rb b/spec/ruby/core/file/shared/unlink.rb
index 7b0413b76b..42b6a77c5d 100644
--- a/spec/ruby/core/file/shared/unlink.rb
+++ b/spec/ruby/core/file/shared/unlink.rb
@@ -48,16 +48,14 @@ describe :file_unlink, shared: true do
File.send(@method, mock_to_path(@file1)).should == 1
end
- ruby_version_is "2.3" do
- platform_is :windows do
- it "allows deleting an open file with File::SHARE_DELETE" do
- path = tmp("share_delete.txt")
- File.open(path, mode: File::CREAT | File::WRONLY | File::BINARY | File::SHARE_DELETE) do |f|
- File.exist?(path).should be_true
- File.send(@method, path)
- end
- File.exist?(path).should be_false
+ platform_is :windows do
+ it "allows deleting an open file with File::SHARE_DELETE" do
+ path = tmp("share_delete.txt")
+ File.open(path, mode: File::CREAT | File::WRONLY | File::BINARY | File::SHARE_DELETE) do |f|
+ File.exist?(path).should be_true
+ File.send(@method, path)
end
+ File.exist?(path).should be_false
end
end
end
diff --git a/spec/ruby/core/file/stat/ino_spec.rb b/spec/ruby/core/file/stat/ino_spec.rb
index 3ae2a7d439..42370aecb7 100644
--- a/spec/ruby/core/file/stat/ino_spec.rb
+++ b/spec/ruby/core/file/stat/ino_spec.rb
@@ -19,20 +19,10 @@ describe "File::Stat#ino" do
end
platform_is :windows do
- ruby_version_is ""..."2.3" do
- it "returns 0" do
- st = File.stat(@file)
- st.ino.should be_kind_of(Integer)
- st.ino.should == 0
- end
- end
-
- ruby_version_is "2.3" do
- it "returns BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low of a File::Stat object" do
- st = File.stat(@file)
- st.ino.should be_kind_of(Integer)
- st.ino.should > 0
- end
+ it "returns BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low of a File::Stat object" do
+ st = File.stat(@file)
+ st.ino.should be_kind_of(Integer)
+ st.ino.should > 0
end
end
end
diff --git a/spec/ruby/core/hash/compare_by_identity_spec.rb b/spec/ruby/core/hash/compare_by_identity_spec.rb
index cf15649739..e463c311be 100644
--- a/spec/ruby/core/hash/compare_by_identity_spec.rb
+++ b/spec/ruby/core/hash/compare_by_identity_spec.rb
@@ -108,7 +108,7 @@ describe "Hash#compare_by_identity" do
@idh.keys.first.should equal foo
end
- ruby_bug "#12855", "2.2.0"..."2.4.1" do
+ ruby_bug "#12855", ""..."2.4.1" do
it "gives different identity for string literals" do
@idh['foo'] = 1
@idh['foo'] = 2
diff --git a/spec/ruby/core/hash/dig_spec.rb b/spec/ruby/core/hash/dig_spec.rb
index 91639f4213..dcba049ac4 100644
--- a/spec/ruby/core/hash/dig_spec.rb
+++ b/spec/ruby/core/hash/dig_spec.rb
@@ -1,68 +1,66 @@
require_relative '../../spec_helper'
-ruby_version_is '2.3' do
- describe "Hash#dig" do
+describe "Hash#dig" do
- it "returns #[] with one arg" do
- h = { 0 => false, a: 1 }
- h.dig(:a).should == 1
- h.dig(0).should be_false
- h.dig(1).should be_nil
- end
+ it "returns #[] with one arg" do
+ h = { 0 => false, a: 1 }
+ h.dig(:a).should == 1
+ h.dig(0).should be_false
+ h.dig(1).should be_nil
+ end
- it "returns the nested value specified by the sequence of keys" do
- h = { foo: { bar: { baz: 1 } } }
- h.dig(:foo, :bar, :baz).should == 1
- h.dig(:foo, :bar, :nope).should be_nil
- h.dig(:foo, :baz).should be_nil
- h.dig(:bar, :baz, :foo).should be_nil
- end
+ it "returns the nested value specified by the sequence of keys" do
+ h = { foo: { bar: { baz: 1 } } }
+ h.dig(:foo, :bar, :baz).should == 1
+ h.dig(:foo, :bar, :nope).should be_nil
+ h.dig(:foo, :baz).should be_nil
+ h.dig(:bar, :baz, :foo).should be_nil
+ end
- it "returns the nested value specified if the sequence includes an index" do
- h = { foo: [1, 2, 3] }
- h.dig(:foo, 2).should == 3
- end
+ it "returns the nested value specified if the sequence includes an index" do
+ h = { foo: [1, 2, 3] }
+ h.dig(:foo, 2).should == 3
+ end
- it "returns nil if any intermediate step is nil" do
- h = { foo: { bar: { baz: 1 } } }
- h.dig(:foo, :zot, :xyz).should == nil
- end
+ it "returns nil if any intermediate step is nil" do
+ h = { foo: { bar: { baz: 1 } } }
+ h.dig(:foo, :zot, :xyz).should == nil
+ end
- it "raises an ArgumentError if no arguments provided" do
- lambda { { the: 'borg' }.dig() }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError if no arguments provided" do
+ lambda { { the: 'borg' }.dig() }.should raise_error(ArgumentError)
+ end
- it "handles type-mixed deep digging" do
- h = {}
- h[:foo] = [ { bar: [ 1 ] }, [ obj = Object.new, 'str' ] ]
- def obj.dig(*args); [ 42 ] end
+ it "handles type-mixed deep digging" do
+ h = {}
+ h[:foo] = [ { bar: [ 1 ] }, [ obj = Object.new, 'str' ] ]
+ def obj.dig(*args); [ 42 ] end
- h.dig(:foo, 0, :bar).should == [ 1 ]
- h.dig(:foo, 0, :bar, 0).should == 1
- h.dig(:foo, 1, 1).should == 'str'
- # MRI does not recurse values returned from `obj.dig`
- h.dig(:foo, 1, 0, 0).should == [ 42 ]
- h.dig(:foo, 1, 0, 0, 10).should == [ 42 ]
- end
+ h.dig(:foo, 0, :bar).should == [ 1 ]
+ h.dig(:foo, 0, :bar, 0).should == 1
+ h.dig(:foo, 1, 1).should == 'str'
+ # MRI does not recurse values returned from `obj.dig`
+ h.dig(:foo, 1, 0, 0).should == [ 42 ]
+ h.dig(:foo, 1, 0, 0, 10).should == [ 42 ]
+ end
- it "raises TypeError if an intermediate element does not respond to #dig" do
- h = {}
- h[:foo] = [ { bar: [ 1 ] }, [ nil, 'str' ] ]
- lambda { h.dig(:foo, 0, :bar, 0, 0) }.should raise_error(TypeError)
- lambda { h.dig(:foo, 1, 1, 0) }.should raise_error(TypeError)
- end
+ it "raises TypeError if an intermediate element does not respond to #dig" do
+ h = {}
+ h[:foo] = [ { bar: [ 1 ] }, [ nil, 'str' ] ]
+ lambda { h.dig(:foo, 0, :bar, 0, 0) }.should raise_error(TypeError)
+ lambda { h.dig(:foo, 1, 1, 0) }.should raise_error(TypeError)
+ end
- it "calls #dig on the result of #[] with the remaining arguments" do
- h = { foo: { bar: { baz: 42 } } }
- h[:foo].should_receive(:dig).with(:bar, :baz).and_return(42)
- h.dig(:foo, :bar, :baz).should == 42
- end
+ it "calls #dig on the result of #[] with the remaining arguments" do
+ h = { foo: { bar: { baz: 42 } } }
+ h[:foo].should_receive(:dig).with(:bar, :baz).and_return(42)
+ h.dig(:foo, :bar, :baz).should == 42
+ end
- it "respects Hash's default" do
- default = {bar: 42}
- h = Hash.new(default)
- h.dig(:foo).should equal default
- h.dig(:foo, :bar).should == 42
- end
+ it "respects Hash's default" do
+ default = {bar: 42}
+ h = Hash.new(default)
+ h.dig(:foo).should equal default
+ h.dig(:foo, :bar).should == 42
end
end
diff --git a/spec/ruby/core/hash/fetch_values_spec.rb b/spec/ruby/core/hash/fetch_values_spec.rb
index 1b093f4aa9..a4af153bf7 100644
--- a/spec/ruby/core/hash/fetch_values_spec.rb
+++ b/spec/ruby/core/hash/fetch_values_spec.rb
@@ -2,32 +2,30 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes'
require_relative '../../shared/hash/key_error'
-ruby_version_is "2.3" do
- describe "Hash#fetch_values" do
- before :each do
- @hash = { a: 1, b: 2, c: 3 }
- end
+describe "Hash#fetch_values" do
+ before :each do
+ @hash = { a: 1, b: 2, c: 3 }
+ end
- describe "with matched keys" do
- it "returns the values for keys" do
- @hash.fetch_values(:a).should == [1]
- @hash.fetch_values(:a, :c).should == [1, 3]
- end
+ describe "with matched keys" do
+ it "returns the values for keys" do
+ @hash.fetch_values(:a).should == [1]
+ @hash.fetch_values(:a, :c).should == [1, 3]
end
+ end
- describe "with unmatched keys" do
- it_behaves_like :key_error, ->(obj, key) { obj.fetch_values(key) }, Hash.new(a: 5)
+ describe "with unmatched keys" do
+ it_behaves_like :key_error, ->(obj, key) { obj.fetch_values(key) }, Hash.new(a: 5)
- it "returns the default value from block" do
- @hash.fetch_values(:z) { |key| "`#{key}' is not found" }.should == ["`z' is not found"]
- @hash.fetch_values(:a, :z) { |key| "`#{key}' is not found" }.should == [1, "`z' is not found"]
- end
+ it "returns the default value from block" do
+ @hash.fetch_values(:z) { |key| "`#{key}' is not found" }.should == ["`z' is not found"]
+ @hash.fetch_values(:a, :z) { |key| "`#{key}' is not found" }.should == [1, "`z' is not found"]
end
+ end
- describe "without keys" do
- it "returns an empty Array" do
- @hash.fetch_values.should == []
- end
+ describe "without keys" do
+ it "returns an empty Array" do
+ @hash.fetch_values.should == []
end
end
end
diff --git a/spec/ruby/core/hash/fixtures/classes.rb b/spec/ruby/core/hash/fixtures/classes.rb
index 3d3df576cf..ae907aaff6 100644
--- a/spec/ruby/core/hash/fixtures/classes.rb
+++ b/spec/ruby/core/hash/fixtures/classes.rb
@@ -17,6 +17,13 @@ module HashSpecs
end
end
+ class SubHashSettingInInitialize < Hash
+ def initialize(*args, &block)
+ self[:foo] = :bar
+ super(*args, &block)
+ end
+ end
+
class DefaultHash < Hash
def default(key)
100
diff --git a/spec/ruby/core/hash/gt_spec.rb b/spec/ruby/core/hash/gt_spec.rb
index 58878e94fc..cd541d4d83 100644
--- a/spec/ruby/core/hash/gt_spec.rb
+++ b/spec/ruby/core/hash/gt_spec.rb
@@ -2,43 +2,41 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison'
require_relative 'shared/greater_than'
-ruby_version_is "2.3" do
- describe "Hash#>" do
- it_behaves_like :hash_comparison, :>
- it_behaves_like :hash_greater_than, :>
+describe "Hash#>" do
+ it_behaves_like :hash_comparison, :>
+ it_behaves_like :hash_greater_than, :>
- it "returns false if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h > h).should be_false
- end
+ it "returns false if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h > h).should be_false
end
+end
- describe "Hash#>" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+describe "Hash#>" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is smaller than argument" do
- (@hash > @bigger).should == false
- (@unrelated > @bigger).should == false
- end
+ it "returns false when receiver size is smaller than argument" do
+ (@hash > @bigger).should == false
+ (@unrelated > @bigger).should == false
+ end
- it "returns false when receiver size is the same as argument" do
- (@hash > @hash).should == false
- (@hash > @unrelated).should == false
- (@unrelated > @hash).should == false
- end
+ it "returns false when receiver size is the same as argument" do
+ (@hash > @hash).should == false
+ (@hash > @unrelated).should == false
+ (@unrelated > @hash).should == false
+ end
- it "returns true when argument is a subset of receiver" do
- (@bigger > @hash).should == true
- end
+ it "returns true when argument is a subset of receiver" do
+ (@bigger > @hash).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash > @similar).should == false
- (@similar > @hash).should == false
- end
+ it "returns false when keys match but values don't" do
+ (@hash > @similar).should == false
+ (@similar > @hash).should == false
end
end
diff --git a/spec/ruby/core/hash/gte_spec.rb b/spec/ruby/core/hash/gte_spec.rb
index bbb86edc7d..99b89e7217 100644
--- a/spec/ruby/core/hash/gte_spec.rb
+++ b/spec/ruby/core/hash/gte_spec.rb
@@ -2,43 +2,41 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison'
require_relative 'shared/greater_than'
-ruby_version_is "2.3" do
- describe "Hash#>=" do
- it_behaves_like :hash_comparison, :>=
- it_behaves_like :hash_greater_than, :>=
+describe "Hash#>=" do
+ it_behaves_like :hash_comparison, :>=
+ it_behaves_like :hash_greater_than, :>=
- it "returns true if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h >= h).should be_true
- end
+ it "returns true if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h >= h).should be_true
end
+end
- describe "Hash#>=" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+describe "Hash#>=" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is smaller than argument" do
- (@hash >= @bigger).should == false
- (@unrelated >= @bigger).should == false
- end
+ it "returns false when receiver size is smaller than argument" do
+ (@hash >= @bigger).should == false
+ (@unrelated >= @bigger).should == false
+ end
- it "returns false when argument is not a subset or not equals to receiver" do
- (@hash >= @unrelated).should == false
- (@unrelated >= @hash).should == false
- end
+ it "returns false when argument is not a subset or not equals to receiver" do
+ (@hash >= @unrelated).should == false
+ (@unrelated >= @hash).should == false
+ end
- it "returns true when argument is a subset of receiver or equals to receiver" do
- (@bigger >= @hash).should == true
- (@hash >= @hash).should == true
- end
+ it "returns true when argument is a subset of receiver or equals to receiver" do
+ (@bigger >= @hash).should == true
+ (@hash >= @hash).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash >= @similar).should == false
- (@similar >= @hash).should == false
- end
+ it "returns false when keys match but values don't" do
+ (@hash >= @similar).should == false
+ (@similar >= @hash).should == false
end
end
diff --git a/spec/ruby/core/hash/initialize_spec.rb b/spec/ruby/core/hash/initialize_spec.rb
index ed7163db48..344571631a 100644
--- a/spec/ruby/core/hash/initialize_spec.rb
+++ b/spec/ruby/core/hash/initialize_spec.rb
@@ -9,16 +9,37 @@ describe "Hash#initialize" do
it "can be used to reset default_proc" do
h = { "foo" => 1, "bar" => 2 }
h.default_proc.should == nil
- h.instance_eval { initialize { |_, k| k * 2 } }
+ h.send(:initialize) { |_, k| k * 2 }
h.default_proc.should_not == nil
h["a"].should == "aa"
end
+ it "can be used to reset the default value" do
+ h = {}
+ h.default = 42
+ h.default.should == 42
+ h.send(:initialize, 1)
+ h.default.should == 1
+ h.send(:initialize)
+ h.default.should == nil
+ end
+
it "receives the arguments passed to Hash#new" do
HashSpecs::NewHash.new(:one, :two)[0].should == :one
HashSpecs::NewHash.new(:one, :two)[1].should == :two
end
+ it "does not change the storage, only the default value or proc" do
+ h = HashSpecs::SubHashSettingInInitialize.new
+ h.to_a.should == [[:foo, :bar]]
+
+ h = HashSpecs::SubHashSettingInInitialize.new(:default)
+ h.to_a.should == [[:foo, :bar]]
+
+ h = HashSpecs::SubHashSettingInInitialize.new { :default_block }
+ h.to_a.should == [[:foo, :bar]]
+ end
+
it "returns self" do
h = Hash.new
h.send(:initialize).should equal(h)
diff --git a/spec/ruby/core/hash/lt_spec.rb b/spec/ruby/core/hash/lt_spec.rb
index 88f1120e86..2219615880 100644
--- a/spec/ruby/core/hash/lt_spec.rb
+++ b/spec/ruby/core/hash/lt_spec.rb
@@ -2,43 +2,41 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison'
require_relative 'shared/less_than'
-ruby_version_is "2.3" do
- describe "Hash#<" do
- it_behaves_like :hash_comparison, :<
- it_behaves_like :hash_less_than, :<
+describe "Hash#<" do
+ it_behaves_like :hash_comparison, :<
+ it_behaves_like :hash_less_than, :<
- it "returns false if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h < h).should be_false
- end
+ it "returns false if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h < h).should be_false
end
+end
- describe "Hash#<" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+describe "Hash#<" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is larger than argument" do
- (@bigger < @hash).should == false
- (@bigger < @unrelated).should == false
- end
+ it "returns false when receiver size is larger than argument" do
+ (@bigger < @hash).should == false
+ (@bigger < @unrelated).should == false
+ end
- it "returns false when receiver size is the same as argument" do
- (@hash < @hash).should == false
- (@hash < @unrelated).should == false
- (@unrelated < @hash).should == false
- end
+ it "returns false when receiver size is the same as argument" do
+ (@hash < @hash).should == false
+ (@hash < @unrelated).should == false
+ (@unrelated < @hash).should == false
+ end
- it "returns true when receiver is a subset of argument" do
- (@hash < @bigger).should == true
- end
+ it "returns true when receiver is a subset of argument" do
+ (@hash < @bigger).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash < @similar).should == false
- (@similar < @hash).should == false
- end
+ it "returns false when keys match but values don't" do
+ (@hash < @similar).should == false
+ (@similar < @hash).should == false
end
end
diff --git a/spec/ruby/core/hash/lte_spec.rb b/spec/ruby/core/hash/lte_spec.rb
index 1463c263d0..a166e5bca4 100644
--- a/spec/ruby/core/hash/lte_spec.rb
+++ b/spec/ruby/core/hash/lte_spec.rb
@@ -2,43 +2,41 @@ require_relative '../../spec_helper'
require_relative 'shared/comparison'
require_relative 'shared/less_than'
-ruby_version_is "2.3" do
- describe "Hash#<=" do
- it_behaves_like :hash_comparison, :<=
- it_behaves_like :hash_less_than, :<=
+describe "Hash#<=" do
+ it_behaves_like :hash_comparison, :<=
+ it_behaves_like :hash_less_than, :<=
- it "returns true if both hashes are identical" do
- h = { a: 1, b: 2 }
- (h <= h).should be_true
- end
+ it "returns true if both hashes are identical" do
+ h = { a: 1, b: 2 }
+ (h <= h).should be_true
end
+end
- describe "Hash#<=" do
- before :each do
- @hash = {a:1, b:2}
- @bigger = {a:1, b:2, c:3}
- @unrelated = {c:3, d:4}
- @similar = {a:2, b:3}
- end
+describe "Hash#<=" do
+ before :each do
+ @hash = {a:1, b:2}
+ @bigger = {a:1, b:2, c:3}
+ @unrelated = {c:3, d:4}
+ @similar = {a:2, b:3}
+ end
- it "returns false when receiver size is larger than argument" do
- (@bigger <= @hash).should == false
- (@bigger <= @unrelated).should == false
- end
+ it "returns false when receiver size is larger than argument" do
+ (@bigger <= @hash).should == false
+ (@bigger <= @unrelated).should == false
+ end
- it "returns false when receiver size is the same as argument" do
- (@hash <= @unrelated).should == false
- (@unrelated <= @hash).should == false
- end
+ it "returns false when receiver size is the same as argument" do
+ (@hash <= @unrelated).should == false
+ (@unrelated <= @hash).should == false
+ end
- it "returns true when receiver is a subset of argument or equals to argument" do
- (@hash <= @bigger).should == true
- (@hash <= @hash).should == true
- end
+ it "returns true when receiver is a subset of argument or equals to argument" do
+ (@hash <= @bigger).should == true
+ (@hash <= @hash).should == true
+ end
- it "returns false when keys match but values don't" do
- (@hash <= @similar).should == false
- (@similar <= @hash).should == false
- end
+ it "returns false when keys match but values don't" do
+ (@hash <= @similar).should == false
+ (@similar <= @hash).should == false
end
end
diff --git a/spec/ruby/core/hash/shared/to_s.rb b/spec/ruby/core/hash/shared/to_s.rb
index 32c86f9d33..88333e0f42 100644
--- a/spec/ruby/core/hash/shared/to_s.rb
+++ b/spec/ruby/core/hash/shared/to_s.rb
@@ -87,23 +87,10 @@ describe :hash_to_s, shared: true do
{ nil => nil }.untrust.send(@method).untrusted?.should be_true
end
- ruby_version_is ''...'2.3' do
- it "raises if inspected result is not default external encoding" do
- utf_16be = mock("utf_16be")
- utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
-
- lambda {
- {a: utf_16be}.send(@method)
- }.should raise_error(Encoding::CompatibilityError)
- end
- end
+ it "does not raise if inspected result is not default external encoding" do
+ utf_16be = mock("utf_16be")
+ utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
- ruby_version_is '2.3' do
- it "does not raise if inspected result is not default external encoding" do
- utf_16be = mock("utf_16be")
- utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
-
- {a: utf_16be}.send(@method).should == '{:a=>"utf_16be \u3042"}'
- end
+ {a: utf_16be}.send(@method).should == '{:a=>"utf_16be \u3042"}'
end
end
diff --git a/spec/ruby/core/hash/to_proc_spec.rb b/spec/ruby/core/hash/to_proc_spec.rb
index 3dc6a91459..ca55604043 100644
--- a/spec/ruby/core/hash/to_proc_spec.rb
+++ b/spec/ruby/core/hash/to_proc_spec.rb
@@ -1,89 +1,87 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "2.3" do
- describe "Hash#to_proc" do
+describe "Hash#to_proc" do
+ before :each do
+ @key = Object.new
+ @value = Object.new
+ @hash = { @key => @value }
+ @default = Object.new
+ @unstored = Object.new
+ end
+
+ it "returns an instance of Proc" do
+ @hash.to_proc.should be_an_instance_of Proc
+ end
+
+ describe "the returned proc" do
before :each do
- @key = Object.new
- @value = Object.new
- @hash = { @key => @value }
- @default = Object.new
- @unstored = Object.new
+ @proc = @hash.to_proc
end
- it "returns an instance of Proc" do
- @hash.to_proc.should be_an_instance_of Proc
+ it "is not a lambda" do
+ @proc.lambda?.should == false
end
- describe "the returned proc" do
- before :each do
- @proc = @hash.to_proc
- end
-
- it "is not a lambda" do
- @proc.lambda?.should == false
- end
+ it "raises ArgumentError if not passed exactly one argument" do
+ lambda {
+ @proc.call
+ }.should raise_error(ArgumentError)
- it "raises ArgumentError if not passed exactly one argument" do
- lambda {
- @proc.call
- }.should raise_error(ArgumentError)
+ lambda {
+ @proc.call 1, 2
+ }.should raise_error(ArgumentError)
+ end
- lambda {
- @proc.call 1, 2
- }.should raise_error(ArgumentError)
+ context "with a stored key" do
+ it "returns the paired value" do
+ @proc.call(@key).should equal(@value)
end
+ end
- context "with a stored key" do
- it "returns the paired value" do
- @proc.call(@key).should equal(@value)
- end
+ context "passed as a block" do
+ it "retrieves the hash's values" do
+ [@key].map(&@proc)[0].should equal(@value)
end
- context "passed as a block" do
- it "retrieves the hash's values" do
- [@key].map(&@proc)[0].should equal(@value)
- end
-
- context "to instance_exec" do
- it "always retrieves the original hash's values" do
- hash = {foo: 1, bar: 2}
- proc = hash.to_proc
+ context "to instance_exec" do
+ it "always retrieves the original hash's values" do
+ hash = {foo: 1, bar: 2}
+ proc = hash.to_proc
- hash.instance_exec(:foo, &proc).should == 1
+ hash.instance_exec(:foo, &proc).should == 1
- hash2 = {quux: 1}
- hash2.instance_exec(:foo, &proc).should == 1
- end
+ hash2 = {quux: 1}
+ hash2.instance_exec(:foo, &proc).should == 1
end
end
+ end
- context "with no stored key" do
- it "returns nil" do
- @proc.call(@unstored).should be_nil
- end
-
- context "when the hash has a default value" do
- before :each do
- @hash.default = @default
- end
+ context "with no stored key" do
+ it "returns nil" do
+ @proc.call(@unstored).should be_nil
+ end
- it "returns the default value" do
- @proc.call(@unstored).should equal(@default)
- end
+ context "when the hash has a default value" do
+ before :each do
+ @hash.default = @default
end
- context "when the hash has a default proc" do
- it "returns an evaluated value from the default proc" do
- @hash.default_proc = -> hash, called_with { [hash.keys, called_with] }
- @proc.call(@unstored).should == [[@key], @unstored]
- end
+ it "returns the default value" do
+ @proc.call(@unstored).should equal(@default)
end
end
- it "raises an ArgumentError when calling #call on the Proc with no arguments" do
- lambda { @hash.to_proc.call }.should raise_error(ArgumentError)
+ context "when the hash has a default proc" do
+ it "returns an evaluated value from the default proc" do
+ @hash.default_proc = -> hash, called_with { [hash.keys, called_with] }
+ @proc.call(@unstored).should == [[@key], @unstored]
+ end
end
end
+
+ it "raises an ArgumentError when calling #call on the Proc with no arguments" do
+ lambda { @hash.to_proc.call }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/core/io/binread_spec.rb b/spec/ruby/core/io/binread_spec.rb
index b7ab8e7fbc..5e936ac6ba 100644
--- a/spec/ruby/core/io/binread_spec.rb
+++ b/spec/ruby/core/io/binread_spec.rb
@@ -41,9 +41,7 @@ describe "IO.binread" do
lambda { IO.binread @fname, -1 }.should raise_error(ArgumentError)
end
- ruby_version_is "2.3" do # MRI leaks the fd on older versions
- it "raises an Errno::EINVAL when not passed a valid offset" do
- lambda { IO.binread @fname, 0, -1 }.should raise_error(Errno::EINVAL)
- end
+ it "raises an Errno::EINVAL when not passed a valid offset" do
+ lambda { IO.binread @fname, 0, -1 }.should raise_error(Errno::EINVAL)
end
end
diff --git a/spec/ruby/core/io/close_on_exec_spec.rb b/spec/ruby/core/io/close_on_exec_spec.rb
index 53546e6bb6..d6ba3c3cef 100644
--- a/spec/ruby/core/io/close_on_exec_spec.rb
+++ b/spec/ruby/core/io/close_on_exec_spec.rb
@@ -11,17 +11,7 @@ describe "IO#close_on_exec=" do
rm_r @name
end
- guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
- it "returns false from #respond_to?" do
- @io.respond_to?(:close_on_exec=).should be_false
- end
-
- it "raises a NotImplementedError when called" do
- lambda { @io.close_on_exec = true }.should raise_error(NotImplementedError)
- end
- end
-
- guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
+ guard -> { platform_is_not :windows } do
it "sets the close-on-exec flag if true" do
@io.close_on_exec = true
@io.close_on_exec?.should == true
@@ -72,17 +62,7 @@ describe "IO#close_on_exec?" do
rm_r @name
end
- guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
- it "returns false from #respond_to?" do
- @io.respond_to?(:close_on_exec?).should be_false
- end
-
- it "raises a NotImplementedError when called" do
- lambda { @io.close_on_exec? }.should raise_error(NotImplementedError)
- end
- end
-
- guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
+ guard -> { platform_is_not :windows } do
it "returns true by default" do
@io.close_on_exec?.should == true
end
diff --git a/spec/ruby/core/io/close_read_spec.rb b/spec/ruby/core/io/close_read_spec.rb
index f928808c9b..9783cb252a 100644
--- a/spec/ruby/core/io/close_read_spec.rb
+++ b/spec/ruby/core/io/close_read_spec.rb
@@ -19,20 +19,10 @@ describe "IO#close_read" do
lambda { @io.read }.should raise_error(IOError)
end
- ruby_version_is ''...'2.3' do
- it "raises an IOError on subsequent invocations" do
- @io.close_read
-
- lambda { @io.close_read }.should raise_error(IOError)
- end
- end
-
- ruby_version_is '2.3' do
- it "does nothing on subsequent invocations" do
- @io.close_read
+ it "does nothing on subsequent invocations" do
+ @io.close_read
- @io.close_read.should be_nil
- end
+ @io.close_read.should be_nil
end
it "allows subsequent invocation of close" do
@@ -62,19 +52,9 @@ describe "IO#close_read" do
io.closed?.should == true
end
- ruby_version_is ''...'2.3' do
- it "raises IOError on closed stream" do
- @io.close
+ it "does nothing on closed stream" do
+ @io.close
- lambda { @io.close_read }.should raise_error(IOError)
- end
- end
-
- ruby_version_is '2.3' do
- it "does nothing on closed stream" do
- @io.close
-
- @io.close_read.should be_nil
- end
+ @io.close_read.should be_nil
end
end
diff --git a/spec/ruby/core/io/close_spec.rb b/spec/ruby/core/io/close_spec.rb
index 7a2b97ac29..b7aa2276d1 100644
--- a/spec/ruby/core/io/close_spec.rb
+++ b/spec/ruby/core/io/close_spec.rb
@@ -38,19 +38,10 @@ describe "IO#close" do
lambda { @io.write "data" }.should_not raise_error(IOError)
end
- ruby_version_is ''...'2.3' do
- it "raises an IOError if closed" do
- @io.close
- lambda { @io.close }.should raise_error(IOError)
- end
- end
-
- ruby_version_is "2.3" do
- it "does nothing if already closed" do
- @io.close
+ it "does nothing if already closed" do
+ @io.close
- @io.close.should be_nil
- end
+ @io.close.should be_nil
end
ruby_version_is '2.5' do
diff --git a/spec/ruby/core/io/close_write_spec.rb b/spec/ruby/core/io/close_write_spec.rb
index c2577536fa..8643659025 100644
--- a/spec/ruby/core/io/close_write_spec.rb
+++ b/spec/ruby/core/io/close_write_spec.rb
@@ -18,20 +18,10 @@ describe "IO#close_write" do
lambda { @io.write "attempt to write" }.should raise_error(IOError)
end
- ruby_version_is ''...'2.3' do
- it "raises an IOError on subsequent invocations" do
- @io.close_write
-
- lambda { @io.close_write }.should raise_error(IOError)
- end
- end
-
- ruby_version_is '2.3' do
- it "does nothing on subsequent invocations" do
- @io.close_write
+ it "does nothing on subsequent invocations" do
+ @io.close_write
- @io.close_write.should be_nil
- end
+ @io.close_write.should be_nil
end
it "allows subsequent invocation of close" do
@@ -66,19 +56,9 @@ describe "IO#close_write" do
@io.read.should == "12345\n"
end
- ruby_version_is ''...'2.3' do
- it "raises IOError on closed stream" do
- @io.close
+ it "does nothing on closed stream" do
+ @io.close
- lambda { @io.close_write }.should raise_error(IOError)
- end
- end
-
- ruby_version_is '2.3' do
- it "does nothing on closed stream" do
- @io.close
-
- @io.close_write.should be_nil
- end
+ @io.close_write.should be_nil
end
end
diff --git a/spec/ruby/core/io/each_codepoint_spec.rb b/spec/ruby/core/io/each_codepoint_spec.rb
index 920aaef07d..19824c38e4 100644
--- a/spec/ruby/core/io/each_codepoint_spec.rb
+++ b/spec/ruby/core/io/each_codepoint_spec.rb
@@ -37,9 +37,7 @@ describe "IO#each_codepoint" do
@io.close if @io
end
- ruby_version_is "2.3" do # earlier versions stay blocked
- it "raises an exception at incomplete character before EOF when conversion takes place" do
- lambda { @io.each_codepoint {} }.should raise_error(ArgumentError)
- end
+ it "raises an exception at incomplete character before EOF when conversion takes place" do
+ lambda { @io.each_codepoint {} }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/io/read_nonblock_spec.rb b/spec/ruby/core/io/read_nonblock_spec.rb
index cfa1e95e7f..e224707e38 100644
--- a/spec/ruby/core/io/read_nonblock_spec.rb
+++ b/spec/ruby/core/io/read_nonblock_spec.rb
@@ -22,23 +22,21 @@ describe "IO#read_nonblock" do
}
end
- ruby_version_is "2.3" do
- context "when exception option is set to false" do
- context "when there is no data" do
- it "returns :wait_readable" do
- @read.read_nonblock(5, exception: false).should == :wait_readable
- end
+ context "when exception option is set to false" do
+ context "when there is no data" do
+ it "returns :wait_readable" do
+ @read.read_nonblock(5, exception: false).should == :wait_readable
end
+ end
- context "when the end is reached" do
- it "returns nil" do
- @write << "hello"
- @write.close
+ context "when the end is reached" do
+ it "returns nil" do
+ @write << "hello"
+ @write.close
- @read.read_nonblock(5)
+ @read.read_nonblock(5)
- @read.read_nonblock(5, exception: false).should be_nil
- end
+ @read.read_nonblock(5, exception: false).should be_nil
end
end
end
diff --git a/spec/ruby/core/io/write_nonblock_spec.rb b/spec/ruby/core/io/write_nonblock_spec.rb
index d493289a2c..b0da9b7e11 100644
--- a/spec/ruby/core/io/write_nonblock_spec.rb
+++ b/spec/ruby/core/io/write_nonblock_spec.rb
@@ -66,12 +66,10 @@ describe 'IO#write_nonblock' do
}
end
- ruby_version_is "2.3" do
- context "when exception option is set to false" do
- it "returns :wait_writable when the operation would block" do
- loop { break if @write.write_nonblock("a" * 10_000, exception: false) == :wait_writable }
- 1.should == 1
- end
+ context "when exception option is set to false" do
+ it "returns :wait_writable when the operation would block" do
+ loop { break if @write.write_nonblock("a" * 10_000, exception: false) == :wait_writable }
+ 1.should == 1
end
end
diff --git a/spec/ruby/core/kernel/define_singleton_method_spec.rb b/spec/ruby/core/kernel/define_singleton_method_spec.rb
index 81c91fd215..c2f2da7c79 100644
--- a/spec/ruby/core/kernel/define_singleton_method_spec.rb
+++ b/spec/ruby/core/kernel/define_singleton_method_spec.rb
@@ -86,16 +86,14 @@ describe "Kernel#define_singleton_method" do
}.should raise_error(ArgumentError)
end
- ruby_version_is "2.3" do
- it "does not use the caller block when no block is given" do
- o = Object.new
- def o.define(name)
- define_singleton_method(name)
- end
-
- lambda {
- o.define(:foo) { raise "not used" }
- }.should raise_error(ArgumentError)
+ it "does not use the caller block when no block is given" do
+ o = Object.new
+ def o.define(name)
+ define_singleton_method(name)
end
+
+ lambda {
+ o.define(:foo) { raise "not used" }
+ }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/kernel/loop_spec.rb b/spec/ruby/core/kernel/loop_spec.rb
index 522919ec41..3386326a13 100644
--- a/spec/ruby/core/kernel/loop_spec.rb
+++ b/spec/ruby/core/kernel/loop_spec.rb
@@ -58,15 +58,13 @@ describe "Kernel.loop" do
lambda{ loop do raise StandardError end }.should raise_error( StandardError )
end
- ruby_version_is "2.3" do
- it "returns StopIteration#result, the result value of a finished iterator" do
- e = Enumerator.new { |y|
- y << 1
- y << 2
- :stopped
- }
- loop { e.next }.should == :stopped
- end
+ it "returns StopIteration#result, the result value of a finished iterator" do
+ e = Enumerator.new { |y|
+ y << 1
+ y << 2
+ :stopped
+ }
+ loop { e.next }.should == :stopped
end
describe "when no block is given" do
diff --git a/spec/ruby/core/kernel/require_relative_spec.rb b/spec/ruby/core/kernel/require_relative_spec.rb
index d8113daf6c..4a2ef87357 100644
--- a/spec/ruby/core/kernel/require_relative_spec.rb
+++ b/spec/ruby/core/kernel/require_relative_spec.rb
@@ -40,6 +40,48 @@ describe "Kernel#require_relative with a relative path" do
ScratchPad.recorded.should == [:loaded]
end
+ describe "in an #instance_eval with a" do
+
+ it "synthetic file base name loads a file base name relative to the working directory" do
+ Dir.chdir @abs_dir do
+ Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "foo.rb").should be_true
+ end
+ ScratchPad.recorded.should == [:loaded]
+ end
+
+ it "synthetic file path loads a relative path relative to the working directory plus the directory of the synthetic path" do
+ Dir.chdir @abs_dir do
+ Object.new.instance_eval("require_relative(File.join('..', #{File.basename(@path).inspect}))", "bar/foo.rb").should be_true
+ end
+ ScratchPad.recorded.should == [:loaded]
+ end
+
+ platform_is_not :windows do
+ it "synthetic relative file path with a Windows path separator specified loads a relative path relative to the working directory" do
+ Dir.chdir @abs_dir do
+ Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "bar\\foo.rb").should be_true
+ end
+ ScratchPad.recorded.should == [:loaded]
+ end
+ end
+
+ it "absolute file path loads a path relative to the absolute path" do
+ Object.new.instance_eval("require_relative(#{@path.inspect})", __FILE__).should be_true
+ ScratchPad.recorded.should == [:loaded]
+ end
+
+ it "absolute file path loads a path relative to the root directory" do
+ root = @abs_path
+ until File.dirname(root) == root
+ root = File.dirname(root)
+ end
+ root_relative = @abs_path[root.size..-1]
+ Object.new.instance_eval("require_relative(#{root_relative.inspect})", "/").should be_true
+ ScratchPad.recorded.should == [:loaded]
+ end
+
+ end
+
it "loads a file defining many methods" do
require_relative("#{@dir}/methods_fixture.rb").should be_true
ScratchPad.recorded.should == [:loaded]
diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb
index bf92b5509c..5e3f98f813 100644
--- a/spec/ruby/core/kernel/shared/require.rb
+++ b/spec/ruby/core/kernel/shared/require.rb
@@ -454,21 +454,7 @@ describe :kernel_require, shared: true do
ScratchPad.recorded.should == []
end
- ruby_version_is "2.2"..."2.3" do
- it "complex, enumerator, rational and unicode_normalize are already required" do
- provided = %w[complex enumerator rational unicode_normalize]
- features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
- provided.each { |feature|
- features.should =~ /\b#{feature}\.(rb|so)$/
- }
-
- code = provided.map { |f| "puts require #{f.inspect}\n" }.join
- required = ruby_exe(code, options: '--disable-gems')
- required.should == "false\n" * provided.size
- end
- end
-
- ruby_version_is "2.3"..."2.5" do
+ ruby_version_is ""..."2.5" do
it "complex, enumerator, rational, thread and unicode_normalize are already required" do
provided = %w[complex enumerator rational thread unicode_normalize]
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
diff --git a/spec/ruby/core/main/using_spec.rb b/spec/ruby/core/main/using_spec.rb
index d043079316..1fb812f5cc 100644
--- a/spec/ruby/core/main/using_spec.rb
+++ b/spec/ruby/core/main/using_spec.rb
@@ -1,135 +1,132 @@
require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
-ruby_version_is "2.0.0" do
- require_relative 'fixtures/classes'
+describe "main.using" do
+ it "requires one Module argument" do
+ lambda do
+ eval('using', TOPLEVEL_BINDING)
+ end.should raise_error(ArgumentError)
- describe "main.using" do
- it "requires one Module argument" do
- lambda do
- eval('using', TOPLEVEL_BINDING)
- end.should raise_error(ArgumentError)
+ lambda do
+ eval('using "foo"', TOPLEVEL_BINDING)
+ end.should raise_error(TypeError)
+ end
- lambda do
- eval('using "foo"', TOPLEVEL_BINDING)
- end.should raise_error(TypeError)
- end
+ it "uses refinements from the given module only in the target file" do
+ require_relative 'fixtures/string_refinement'
+ load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
+ MainSpecs::DATA[:in_module].should == 'foo'
+ MainSpecs::DATA[:toplevel].should == 'foo'
+ lambda do
+ 'hello'.foo
+ end.should raise_error(NoMethodError)
+ end
- it "uses refinements from the given module only in the target file" do
- require_relative 'fixtures/string_refinement'
- load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
- MainSpecs::DATA[:in_module].should == 'foo'
- MainSpecs::DATA[:toplevel].should == 'foo'
- lambda do
- 'hello'.foo
- end.should raise_error(NoMethodError)
- end
+ it "uses refinements from the given module for method calls in the target file" do
+ require_relative 'fixtures/string_refinement'
+ load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
+ lambda do
+ 'hello'.foo
+ end.should raise_error(NoMethodError)
+ MainSpecs.call_foo('hello').should == 'foo'
+ end
- it "uses refinements from the given module for method calls in the target file" do
- require_relative 'fixtures/string_refinement'
- load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
- lambda do
- 'hello'.foo
- end.should raise_error(NoMethodError)
- MainSpecs.call_foo('hello').should == 'foo'
+ it "uses refinements from the given module in the eval string" do
+ cls = MainSpecs::DATA[:cls] = Class.new {def foo; 'foo'; end}
+ MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'bar'; end
+ end
end
+ eval(<<-EOS, TOPLEVEL_BINDING).should == 'bar'
+ using MainSpecs::DATA[:mod]
+ MainSpecs::DATA[:cls].new.foo
+ EOS
+ end
- it "uses refinements from the given module in the eval string" do
- cls = MainSpecs::DATA[:cls] = Class.new {def foo; 'foo'; end}
- MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'bar'; end
- end
+ it "does not affect methods defined before it is called" do
+ cls = Class.new {def foo; 'foo'; end}
+ MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'bar'; end
end
- eval(<<-EOS, TOPLEVEL_BINDING).should == 'bar'
- using MainSpecs::DATA[:mod]
- MainSpecs::DATA[:cls].new.foo
- EOS
end
-
- it "does not affect methods defined before it is called" do
- cls = Class.new {def foo; 'foo'; end}
- MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'bar'; end
- end
+ x = MainSpecs::DATA[:x] = Object.new
+ eval <<-EOS, TOPLEVEL_BINDING
+ x = MainSpecs::DATA[:x]
+ def x.before_using(obj)
+ obj.foo
+ end
+ using MainSpecs::DATA[:mod]
+ def x.after_using(obj)
+ obj.foo
end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- x = MainSpecs::DATA[:x]
- def x.before_using(obj)
- obj.foo
- end
- using MainSpecs::DATA[:mod]
- def x.after_using(obj)
- obj.foo
- end
- EOS
+ EOS
- obj = cls.new
- x.before_using(obj).should == 'foo'
- x.after_using(obj).should == 'bar'
- end
+ obj = cls.new
+ x.before_using(obj).should == 'foo'
+ x.after_using(obj).should == 'bar'
+ end
- it "propagates refinements added to existing modules after it is called" do
- cls = Class.new {def foo; 'foo'; end}
- mod = MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'quux'; end
- end
+ it "propagates refinements added to existing modules after it is called" do
+ cls = Class.new {def foo; 'foo'; end}
+ mod = MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'quux'; end
end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- using MainSpecs::DATA[:mod]
- x = MainSpecs::DATA[:x]
- def x.call_foo(obj)
- obj.foo
- end
- def x.call_bar(obj)
- obj.bar
- end
- EOS
+ end
+ x = MainSpecs::DATA[:x] = Object.new
+ eval <<-EOS, TOPLEVEL_BINDING
+ using MainSpecs::DATA[:mod]
+ x = MainSpecs::DATA[:x]
+ def x.call_foo(obj)
+ obj.foo
+ end
+ def x.call_bar(obj)
+ obj.bar
+ end
+ EOS
- obj = cls.new
- x.call_foo(obj).should == 'quux'
+ obj = cls.new
+ x.call_foo(obj).should == 'quux'
- mod.module_eval do
- refine(cls) do
- def bar; 'quux'; end
- end
+ mod.module_eval do
+ refine(cls) do
+ def bar; 'quux'; end
end
-
- x.call_bar(obj).should == 'quux'
end
- it "does not propagate refinements of new modules added after it is called" do
- cls = Class.new {def foo; 'foo'; end}
- cls2 = Class.new {def bar; 'bar'; end}
- mod = MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'quux'; end
- end
+ x.call_bar(obj).should == 'quux'
+ end
+
+ it "does not propagate refinements of new modules added after it is called" do
+ cls = Class.new {def foo; 'foo'; end}
+ cls2 = Class.new {def bar; 'bar'; end}
+ mod = MainSpecs::DATA[:mod] = Module.new do
+ refine(cls) do
+ def foo; 'quux'; end
end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- using MainSpecs::DATA[:mod]
- x = MainSpecs::DATA[:x]
- def x.call_foo(obj)
- obj.foo
- end
- def x.call_bar(obj)
- obj.bar
- end
- EOS
+ end
+ x = MainSpecs::DATA[:x] = Object.new
+ eval <<-EOS, TOPLEVEL_BINDING
+ using MainSpecs::DATA[:mod]
+ x = MainSpecs::DATA[:x]
+ def x.call_foo(obj)
+ obj.foo
+ end
+ def x.call_bar(obj)
+ obj.bar
+ end
+ EOS
- x.call_foo(cls.new).should == 'quux'
+ x.call_foo(cls.new).should == 'quux'
- mod.module_eval do
- refine(cls2) do
- def bar; 'quux'; end
- end
+ mod.module_eval do
+ refine(cls2) do
+ def bar; 'quux'; end
end
-
- x.call_bar(cls2.new).should == 'bar'
end
+
+ x.call_bar(cls2.new).should == 'bar'
end
end
diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb
index f375ac2450..f355a5968d 100644
--- a/spec/ruby/core/module/autoload_spec.rb
+++ b/spec/ruby/core/module/autoload_spec.rb
@@ -400,52 +400,51 @@ describe "Module#autoload" do
ModuleSpecs::Autoload.send(:remove_const, :Concur)
end
- ruby_bug "#10892", ""..."2.3" do
- it "blocks others threads while doing an autoload" do
- file_path = fixture(__FILE__, "repeated_concurrent_autoload.rb")
- autoload_path = file_path.sub(/\.rb\Z/, '')
- mod_count = 30
- thread_count = 16
-
- mod_names = []
- mod_count.times do |i|
- mod_name = :"Mod#{i}"
- Object.autoload mod_name, autoload_path
- mod_names << mod_name
- end
+ # https://bugs.ruby-lang.org/issues/10892
+ it "blocks others threads while doing an autoload" do
+ file_path = fixture(__FILE__, "repeated_concurrent_autoload.rb")
+ autoload_path = file_path.sub(/\.rb\Z/, '')
+ mod_count = 30
+ thread_count = 16
+
+ mod_names = []
+ mod_count.times do |i|
+ mod_name = :"Mod#{i}"
+ Object.autoload mod_name, autoload_path
+ mod_names << mod_name
+ end
+
+ barrier = ModuleSpecs::CyclicBarrier.new thread_count
+ ScratchPad.record ModuleSpecs::ThreadSafeCounter.new
- barrier = ModuleSpecs::CyclicBarrier.new thread_count
- ScratchPad.record ModuleSpecs::ThreadSafeCounter.new
-
- threads = (1..thread_count).map do
- Thread.new do
- mod_names.each do |mod_name|
- break false unless barrier.enabled?
-
- was_last_one_in = barrier.await # wait for all threads to finish the iteration
- # clean up so we can autoload the same file again
- $LOADED_FEATURES.delete(file_path) if was_last_one_in && $LOADED_FEATURES.include?(file_path)
- barrier.await # get ready for race
-
- begin
- Object.const_get(mod_name).foo
- rescue NoMethodError
- barrier.disable!
- break false
- end
+ threads = (1..thread_count).map do
+ Thread.new do
+ mod_names.each do |mod_name|
+ break false unless barrier.enabled?
+
+ was_last_one_in = barrier.await # wait for all threads to finish the iteration
+ # clean up so we can autoload the same file again
+ $LOADED_FEATURES.delete(file_path) if was_last_one_in && $LOADED_FEATURES.include?(file_path)
+ barrier.await # get ready for race
+
+ begin
+ Object.const_get(mod_name).foo
+ rescue NoMethodError
+ barrier.disable!
+ break false
end
end
end
+ end
- # check that no thread got a NoMethodError because of partially loaded module
- threads.all? {|t| t.value}.should be_true
+ # check that no thread got a NoMethodError because of partially loaded module
+ threads.all? {|t| t.value}.should be_true
- # check that the autoloaded file was evaled exactly once
- ScratchPad.recorded.get.should == mod_count
+ # check that the autoloaded file was evaled exactly once
+ ScratchPad.recorded.get.should == mod_count
- mod_names.each do |mod_name|
- Object.send(:remove_const, mod_name)
- end
+ mod_names.each do |mod_name|
+ Object.send(:remove_const, mod_name)
end
end
diff --git a/spec/ruby/core/module/define_method_spec.rb b/spec/ruby/core/module/define_method_spec.rb
index 957b401415..3f35c051a1 100644
--- a/spec/ruby/core/module/define_method_spec.rb
+++ b/spec/ruby/core/module/define_method_spec.rb
@@ -222,19 +222,17 @@ describe "Module#define_method" do
}.should raise_error(ArgumentError)
end
- ruby_version_is "2.3" do
- it "does not use the caller block when no block is given" do
- o = Object.new
- def o.define(name)
- self.class.class_eval do
- define_method(name)
- end
+ it "does not use the caller block when no block is given" do
+ o = Object.new
+ def o.define(name)
+ self.class.class_eval do
+ define_method(name)
end
-
- lambda {
- o.define(:foo) { raise "not used" }
- }.should raise_error(ArgumentError)
end
+
+ lambda {
+ o.define(:foo) { raise "not used" }
+ }.should raise_error(ArgumentError)
end
it "does not change the arity check style of the original proc" do
diff --git a/spec/ruby/core/module/deprecate_constant_spec.rb b/spec/ruby/core/module/deprecate_constant_spec.rb
index 4564497738..0954a6d8a5 100644
--- a/spec/ruby/core/module/deprecate_constant_spec.rb
+++ b/spec/ruby/core/module/deprecate_constant_spec.rb
@@ -1,52 +1,50 @@
require_relative '../../spec_helper'
-ruby_version_is "2.3" do
- describe "Module#deprecate_constant" do
- before :each do
- @module = Module.new
- @value = :value
- @module::PUBLIC1 = @value
- @module::PUBLIC2 = @value
- @module::PRIVATE = @value
- @module.private_constant :PRIVATE
- @module.deprecate_constant :PRIVATE
- @pattern = /deprecated/
- end
-
- describe "when accessing the deprecated module" do
- it "passes the accessing" do
- @module.deprecate_constant :PUBLIC1
-
- value = nil
- lambda {
- value = @module::PUBLIC1
- }.should complain(@pattern)
- value.should equal(@value)
+describe "Module#deprecate_constant" do
+ before :each do
+ @module = Module.new
+ @value = :value
+ @module::PUBLIC1 = @value
+ @module::PUBLIC2 = @value
+ @module::PRIVATE = @value
+ @module.private_constant :PRIVATE
+ @module.deprecate_constant :PRIVATE
+ @pattern = /deprecated/
+ end
- lambda { @module::PRIVATE }.should raise_error(NameError)
- end
+ describe "when accessing the deprecated module" do
+ it "passes the accessing" do
+ @module.deprecate_constant :PUBLIC1
- it "warns with a message" do
- @module.deprecate_constant :PUBLIC1
+ value = nil
+ lambda {
+ value = @module::PUBLIC1
+ }.should complain(@pattern)
+ value.should equal(@value)
- lambda { @module::PUBLIC1 }.should complain(@pattern)
- lambda { @module.const_get :PRIVATE }.should complain(@pattern)
- end
+ lambda { @module::PRIVATE }.should raise_error(NameError)
end
- it "accepts multiple symbols and strings as constant names" do
- @module.deprecate_constant "PUBLIC1", :PUBLIC2
+ it "warns with a message" do
+ @module.deprecate_constant :PUBLIC1
lambda { @module::PUBLIC1 }.should complain(@pattern)
- lambda { @module::PUBLIC2 }.should complain(@pattern)
+ lambda { @module.const_get :PRIVATE }.should complain(@pattern)
end
+ end
- it "returns self" do
- @module.deprecate_constant(:PUBLIC1).should equal(@module)
- end
+ it "accepts multiple symbols and strings as constant names" do
+ @module.deprecate_constant "PUBLIC1", :PUBLIC2
- it "raises a NameError when given an undefined name" do
- lambda { @module.deprecate_constant :UNDEFINED }.should raise_error(NameError)
- end
+ lambda { @module::PUBLIC1 }.should complain(@pattern)
+ lambda { @module::PUBLIC2 }.should complain(@pattern)
+ end
+
+ it "returns self" do
+ @module.deprecate_constant(:PUBLIC1).should equal(@module)
+ end
+
+ it "raises a NameError when given an undefined name" do
+ lambda { @module.deprecate_constant :UNDEFINED }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/module/prepend_spec.rb b/spec/ruby/core/module/prepend_spec.rb
index 35b31f1fb0..ca80eb360f 100644
--- a/spec/ruby/core/module/prepend_spec.rb
+++ b/spec/ruby/core/module/prepend_spec.rb
@@ -110,12 +110,10 @@ describe "Module#prepend" do
c.instance_method(:alias).owner.should == c
end
- ruby_version_is "2.3" do
- it "reports the class for the owner of a method aliased from the prepended module" do
- m = Module.new { def meth; :m end }
- c = Class.new { prepend(m); alias_method :alias, :meth }
- c.instance_method(:alias).owner.should == c
- end
+ it "reports the class for the owner of a method aliased from the prepended module" do
+ m = Module.new { def meth; :m end }
+ c = Class.new { prepend(m); alias_method :alias, :meth }
+ c.instance_method(:alias).owner.should == c
end
it "sees an instance of a prepended class as kind of the prepended module" do
diff --git a/spec/ruby/core/module/private_spec.rb b/spec/ruby/core/module/private_spec.rb
index bf3e86a333..d476c6f54e 100644
--- a/spec/ruby/core/module/private_spec.rb
+++ b/spec/ruby/core/module/private_spec.rb
@@ -52,46 +52,44 @@ describe "Module#private" do
end.should raise_error(NameError)
end
- ruby_version_is "2.3" do
- ruby_bug "#14604", "2.3"..."2.5.1" do
- it "only makes the method private in the class it is called on" do
- base = Class.new do
- def wrapped
- 1
- end
+ ruby_bug "#14604", ""..."2.5.1" do
+ it "only makes the method private in the class it is called on" do
+ base = Class.new do
+ def wrapped
+ 1
end
+ end
- klass = Class.new(base) do
- def wrapped
- super + 1
- end
- private :wrapped
+ klass = Class.new(base) do
+ def wrapped
+ super + 1
end
-
- base.new.wrapped.should == 1
- lambda do
- klass.new.wrapped
- end.should raise_error(NameError)
+ private :wrapped
end
- it "continues to allow a prepended module method to call super" do
- wrapper = Module.new do
- def wrapped
- super + 1
- end
+ base.new.wrapped.should == 1
+ lambda do
+ klass.new.wrapped
+ end.should raise_error(NameError)
+ end
+
+ it "continues to allow a prepended module method to call super" do
+ wrapper = Module.new do
+ def wrapped
+ super + 1
end
+ end
- klass = Class.new do
- prepend wrapper
+ klass = Class.new do
+ prepend wrapper
- def wrapped
- 1
- end
- private :wrapped
+ def wrapped
+ 1
end
-
- klass.new.wrapped.should == 2
+ private :wrapped
end
+
+ klass.new.wrapped.should == 2
end
end
end
diff --git a/spec/ruby/core/numeric/negative_spec.rb b/spec/ruby/core/numeric/negative_spec.rb
index 28591da696..da464a9094 100644
--- a/spec/ruby/core/numeric/negative_spec.rb
+++ b/spec/ruby/core/numeric/negative_spec.rb
@@ -1,43 +1,41 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "2.3" do
- describe "Numeric#negative?" do
- describe "on positive numbers" do
- it "returns false" do
- 1.negative?.should be_false
- 0.1.negative?.should be_false
- end
+describe "Numeric#negative?" do
+ describe "on positive numbers" do
+ it "returns false" do
+ 1.negative?.should be_false
+ 0.1.negative?.should be_false
end
+ end
- describe "on zero" do
- it "returns false" do
- 0.negative?.should be_false
- 0.0.negative?.should be_false
- end
+ describe "on zero" do
+ it "returns false" do
+ 0.negative?.should be_false
+ 0.0.negative?.should be_false
end
+ end
- describe "on negative numbers" do
- it "returns true" do
- -1.negative?.should be_true
- -0.1.negative?.should be_true
- end
+ describe "on negative numbers" do
+ it "returns true" do
+ -1.negative?.should be_true
+ -0.1.negative?.should be_true
end
end
+end
- describe "Numeric#negative?" do
- before(:each) do
- @obj = NumericSpecs::Subclass.new
- end
+describe "Numeric#negative?" do
+ before(:each) do
+ @obj = NumericSpecs::Subclass.new
+ end
- it "returns true if self is less than 0" do
- @obj.should_receive(:<).with(0).and_return(true)
- @obj.negative?.should == true
- end
+ it "returns true if self is less than 0" do
+ @obj.should_receive(:<).with(0).and_return(true)
+ @obj.negative?.should == true
+ end
- it "returns false if self is greater than 0" do
- @obj.should_receive(:<).with(0).and_return(false)
- @obj.negative?.should == false
- end
+ it "returns false if self is greater than 0" do
+ @obj.should_receive(:<).with(0).and_return(false)
+ @obj.negative?.should == false
end
end
diff --git a/spec/ruby/core/numeric/positive_spec.rb b/spec/ruby/core/numeric/positive_spec.rb
index 65bb0ea79d..8f98fbfa26 100644
--- a/spec/ruby/core/numeric/positive_spec.rb
+++ b/spec/ruby/core/numeric/positive_spec.rb
@@ -1,43 +1,41 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-ruby_version_is "2.3" do
- describe "Numeric#positive?" do
- describe "on positive numbers" do
- it "returns true" do
- 1.positive?.should be_true
- 0.1.positive?.should be_true
- end
+describe "Numeric#positive?" do
+ describe "on positive numbers" do
+ it "returns true" do
+ 1.positive?.should be_true
+ 0.1.positive?.should be_true
end
+ end
- describe "on zero" do
- it "returns false" do
- 0.positive?.should be_false
- 0.0.positive?.should be_false
- end
+ describe "on zero" do
+ it "returns false" do
+ 0.positive?.should be_false
+ 0.0.positive?.should be_false
end
+ end
- describe "on negative numbers" do
- it "returns false" do
- -1.positive?.should be_false
- -0.1.positive?.should be_false
- end
+ describe "on negative numbers" do
+ it "returns false" do
+ -1.positive?.should be_false
+ -0.1.positive?.should be_false
end
end
+end
- describe "Numeric#positive?" do
- before(:each) do
- @obj = NumericSpecs::Subclass.new
- end
+describe "Numeric#positive?" do
+ before(:each) do
+ @obj = NumericSpecs::Subclass.new
+ end
- it "returns true if self is greater than 0" do
- @obj.should_receive(:>).with(0).and_return(true)
- @obj.positive?.should == true
- end
+ it "returns true if self is greater than 0" do
+ @obj.should_receive(:>).with(0).and_return(true)
+ @obj.positive?.should == true
+ end
- it "returns false if self is less than 0" do
- @obj.should_receive(:>).with(0).and_return(false)
- @obj.positive?.should == false
- end
+ it "returns false if self is less than 0" do
+ @obj.should_receive(:>).with(0).and_return(false)
+ @obj.positive?.should == false
end
end
diff --git a/spec/ruby/core/objectspace/each_object_spec.rb b/spec/ruby/core/objectspace/each_object_spec.rb
index 187d2cc3b2..c827867fdc 100644
--- a/spec/ruby/core/objectspace/each_object_spec.rb
+++ b/spec/ruby/core/objectspace/each_object_spec.rb
@@ -184,18 +184,9 @@ describe "ObjectSpace.each_object" do
hidden.should == nil
end
- ruby_version_is ""..."2.3" do
- it "does not walk singleton classes" do
- @sclass.should be_kind_of(@meta)
- ObjectSpace.each_object(@meta).to_a.should_not include(@sclass)
- end
- end
-
- ruby_version_is "2.3" do
- it "walks singleton classes" do
- @sclass.should be_kind_of(@meta)
- ObjectSpace.each_object(@meta).to_a.should include(@sclass)
- end
+ it "walks singleton classes" do
+ @sclass.should be_kind_of(@meta)
+ ObjectSpace.each_object(@meta).to_a.should include(@sclass)
end
end
@@ -211,10 +202,8 @@ describe "ObjectSpace.each_object" do
expected = [ a, b, c, d ]
# singleton classes should be walked only on >= 2.3
- ruby_version_is "2.3" do
- expected << c_sclass
- c_sclass.should be_kind_of(a.singleton_class)
- end
+ expected << c_sclass
+ c_sclass.should be_kind_of(a.singleton_class)
b.extend Enumerable # included modules should not be walked
diff --git a/spec/ruby/core/process/status/exitstatus_spec.rb b/spec/ruby/core/process/status/exitstatus_spec.rb
index 9a0be6a08d..cd46b2081f 100644
--- a/spec/ruby/core/process/status/exitstatus_spec.rb
+++ b/spec/ruby/core/process/status/exitstatus_spec.rb
@@ -1,7 +1,6 @@
require_relative '../../../spec_helper'
describe "Process::Status#exitstatus" do
-
before :each do
ruby_exe("exit(42)")
end
@@ -10,4 +9,17 @@ describe "Process::Status#exitstatus" do
$?.exitstatus.should == 42
end
+ describe "for a child that raised SignalException" do
+ before :each do
+ ruby_exe("raise SignalException, 'SIGTERM'")
+ end
+
+ platform_is_not :windows do
+ # The exitstatus is not set in these cases. See the termsig_spec
+ # for info on where the signal number (SIGTERM) is available.
+ it "returns nil" do
+ $?.exitstatus.should == nil
+ end
+ end
+ end
end
diff --git a/spec/ruby/core/process/status/termsig_spec.rb b/spec/ruby/core/process/status/termsig_spec.rb
index db0765477d..1482d27146 100644
--- a/spec/ruby/core/process/status/termsig_spec.rb
+++ b/spec/ruby/core/process/status/termsig_spec.rb
@@ -13,6 +13,18 @@ describe "Process::Status#termsig" do
end
end
+ describe "for a child that raised SignalException" do
+ before :each do
+ ruby_exe("raise SignalException, 'SIGTERM'")
+ end
+
+ platform_is_not :windows do
+ it "returns the signal" do
+ $?.termsig.should == Signal.list["TERM"]
+ end
+ end
+ end
+
describe "for a child that was sent a signal" do
before :each do
diff --git a/spec/ruby/core/random/urandom_spec.rb b/spec/ruby/core/random/urandom_spec.rb
index a771445c60..e27f83cdcd 100644
--- a/spec/ruby/core/random/urandom_spec.rb
+++ b/spec/ruby/core/random/urandom_spec.rb
@@ -2,7 +2,7 @@
require_relative '../../spec_helper'
require_relative 'shared/urandom'
-ruby_version_is "2.3"..."2.5" do
+ruby_version_is ""..."2.5" do
describe "Random.raw_seed" do
it_behaves_like :random_urandom, :raw_seed
end
diff --git a/spec/ruby/core/signal/signame_spec.rb b/spec/ruby/core/signal/signame_spec.rb
index d94a8592bd..71b69b301a 100644
--- a/spec/ruby/core/signal/signame_spec.rb
+++ b/spec/ruby/core/signal/signame_spec.rb
@@ -5,16 +5,8 @@ describe "Signal.signame" do
Signal.signame(0).should == "EXIT"
end
- ruby_version_is "2.0"..."2.3" do
- it "raises an ArgumentError if the argument is an invalid signal number" do
- lambda { Signal.signame(-1) }.should raise_error(ArgumentError)
- end
- end
-
- ruby_version_is "2.3" do
- it "returns nil if the argument is an invalid signal number" do
- Signal.signame(-1).should == nil
- end
+ it "returns nil if the argument is an invalid signal number" do
+ Signal.signame(-1).should == nil
end
it "raises a TypeError when the passed argument can't be coerced to Integer" do
diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb
index 697dfd5190..01d3830892 100644
--- a/spec/ruby/core/string/crypt_spec.rb
+++ b/spec/ruby/core/string/crypt_spec.rb
@@ -36,10 +36,8 @@ describe "String#crypt" do
lambda { "hello".crypt("a\x00") }.should raise_error(ArgumentError)
end
- ruby_version_is "2.3" do
- it "raises an ArgumentError when the string contains NUL character" do
- lambda { "poison\0null".crypt("aa") }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError when the string contains NUL character" do
+ lambda { "poison\0null".crypt("aa") }.should raise_error(ArgumentError)
end
it "calls #to_str to converts the salt arg to a String" do
diff --git a/spec/ruby/core/string/new_spec.rb b/spec/ruby/core/string/new_spec.rb
index 7d1c361bf8..a65c6da2d1 100644
--- a/spec/ruby/core/string/new_spec.rb
+++ b/spec/ruby/core/string/new_spec.rb
@@ -7,12 +7,10 @@ describe "String.new" do
str.should be_an_instance_of(String)
end
- ruby_version_is "2.3" do
- it "accepts an encoding argument" do
- xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding 'utf-8'
- str = String.new(xA4xA2, encoding: 'euc-jp')
- str.encoding.should == Encoding::EUC_JP
- end
+ it "accepts an encoding argument" do
+ xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding 'utf-8'
+ str = String.new(xA4xA2, encoding: 'euc-jp')
+ str.encoding.should == Encoding::EUC_JP
end
ruby_version_is "2.4" do
diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb
index dee741e270..19cf5e6d78 100644
--- a/spec/ruby/core/string/shared/each_line.rb
+++ b/spec/ruby/core/string/shared/each_line.rb
@@ -51,9 +51,8 @@ describe :string_each_line, shared: true do
end
end
-quarantine! do # Currently fails on Travis
ruby_version_is '2.5' do
- it "yields paragraphs (broken by 2 or more successive newlines) when passed ''" do
+ it "yields paragraphs (broken by 2 or more successive newlines) when passed '' and replaces multiple newlines with only two ones" do
a = []
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n"]
@@ -63,7 +62,6 @@ quarantine! do # Currently fails on Travis
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n", "dog"]
end
end
-end
describe "uses $/" do
before :each do
@@ -136,7 +134,7 @@ end
ruby_version_is '2.4' do
context "when `chomp` keyword argument is passed" do
- it "removes new line characters" do
+ it "removes new line characters when separator is not specified" do
a = []
"hello \nworld\n".send(@method, chomp: true) { |s| a << s }
a.should == ["hello ", "world"]
@@ -145,6 +143,23 @@ end
"hello \r\nworld\r\n".send(@method, chomp: true) { |s| a << s }
a.should == ["hello ", "world"]
end
+
+ it "removes only specified separator" do
+ a = []
+ "hello world".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello", "world"]
+ end
+
+ # https://bugs.ruby-lang.org/issues/14257
+ it "ignores new line characters when separator is specified" do
+ a = []
+ "hello\n world\n".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello\n", "world\n"]
+
+ a = []
+ "hello\r\n world\r\n".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello\r\n", "world\r\n"]
+ end
end
end
end
diff --git a/spec/ruby/core/string/uminus_spec.rb b/spec/ruby/core/string/uminus_spec.rb
index a2b6fad098..f79683cb74 100644
--- a/spec/ruby/core/string/uminus_spec.rb
+++ b/spec/ruby/core/string/uminus_spec.rb
@@ -1,46 +1,44 @@
require_relative '../../spec_helper'
-ruby_version_is "2.3" do
- describe 'String#-@' do
- it 'returns self if the String is frozen' do
- input = 'foo'.freeze
- output = -input
-
- output.equal?(input).should == true
- output.frozen?.should == true
- end
+describe 'String#-@' do
+ it 'returns self if the String is frozen' do
+ input = 'foo'.freeze
+ output = -input
- it 'returns a frozen copy if the String is not frozen' do
- input = 'foo'
- output = -input
+ output.equal?(input).should == true
+ output.frozen?.should == true
+ end
- output.frozen?.should == true
- output.should == 'foo'
- end
+ it 'returns a frozen copy if the String is not frozen' do
+ input = 'foo'
+ output = -input
- ruby_version_is "2.5" do
- it "returns the same object for equal unfrozen strings" do
- origin = "this is a string"
- dynamic = %w(this is a string).join(' ')
+ output.frozen?.should == true
+ output.should == 'foo'
+ end
- origin.should_not equal(dynamic)
- (-origin).should equal(-dynamic)
- end
+ ruby_version_is "2.5" do
+ it "returns the same object for equal unfrozen strings" do
+ origin = "this is a string"
+ dynamic = %w(this is a string).join(' ')
- it "returns the same object when it's called on the same String literal" do
- (-"unfrozen string").should equal(-"unfrozen string")
- (-"unfrozen string").should_not equal(-"another unfrozen string")
- end
+ origin.should_not equal(dynamic)
+ (-origin).should equal(-dynamic)
+ end
+
+ it "returns the same object when it's called on the same String literal" do
+ (-"unfrozen string").should equal(-"unfrozen string")
+ (-"unfrozen string").should_not equal(-"another unfrozen string")
+ end
- it "is an identity function if the string is frozen" do
- dynamic = %w(this string is frozen).join(' ').freeze
+ it "is an identity function if the string is frozen" do
+ dynamic = %w(this string is frozen).join(' ').freeze
- (-dynamic).should equal(dynamic)
+ (-dynamic).should equal(dynamic)
- dynamic.should_not equal("this string is frozen".freeze)
- (-dynamic).should_not equal("this string is frozen".freeze)
- (-dynamic).should_not equal(-"this string is frozen".freeze)
- end
+ dynamic.should_not equal("this string is frozen".freeze)
+ (-dynamic).should_not equal("this string is frozen".freeze)
+ (-dynamic).should_not equal(-"this string is frozen".freeze)
end
end
end
diff --git a/spec/ruby/core/string/unpack/j_spec.rb b/spec/ruby/core/string/unpack/j_spec.rb
index 8f4213bd97..3c2baad642 100644
--- a/spec/ruby/core/string/unpack/j_spec.rb
+++ b/spec/ruby/core/string/unpack/j_spec.rb
@@ -3,272 +3,270 @@ require_relative '../fixtures/classes'
require_relative 'shared/basic'
require_relative 'shared/integer'
-ruby_version_is '2.3' do
- platform_is pointer_size: 64 do
- little_endian do
- describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_le, 'J_'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_le, 'J!'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J!'
- end
+platform_is pointer_size: 64 do
+ little_endian do
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'J_'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J_'
end
- describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_le, 'j_'
- it_behaves_like :string_unpack_64bit_le_signed, 'j_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_le, 'j!'
- it_behaves_like :string_unpack_64bit_le_signed, 'j!'
- end
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'J!'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J!'
end
end
- big_endian do
- describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_be, 'J_'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_be, 'J!'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J!'
- end
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'j_'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j_'
end
- describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_64bit_be, 'j_'
- it_behaves_like :string_unpack_64bit_be_signed, 'j_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_64bit_be, 'j!'
- it_behaves_like :string_unpack_64bit_be_signed, 'j!'
- end
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'j!'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j!'
end
end
+ end
+ big_endian do
describe "String#unpack with format 'J'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_64bit_le, 'J<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J<'
- end
-
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_64bit_be, 'J>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J>'
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'J_'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J_'
end
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_64bit_le, 'J<_'
- it_behaves_like :string_unpack_64bit_le, 'J_<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J<_'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_64bit_le, 'J<!'
- it_behaves_like :string_unpack_64bit_le, 'J!<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J<!'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'J!<'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'J!'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J!'
end
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_64bit_be, 'J>_'
- it_behaves_like :string_unpack_64bit_be, 'J_>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J>_'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J_>'
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'j_'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j_'
end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_64bit_be, 'J>!'
- it_behaves_like :string_unpack_64bit_be, 'J!>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J>!'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'J!>'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'j!'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j!'
end
end
+ end
- describe "String#unpack with format 'j'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_64bit_le, 'j<'
- it_behaves_like :string_unpack_64bit_le_signed, 'j<'
- end
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_64bit_le, 'J<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J<'
+ end
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_64bit_be, 'j>'
- it_behaves_like :string_unpack_64bit_be_signed, 'j>'
- end
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_64bit_be, 'J>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J>'
+ end
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_64bit_le, 'j<_'
- it_behaves_like :string_unpack_64bit_le, 'j_<'
- it_behaves_like :string_unpack_64bit_le_signed, 'j<_'
- it_behaves_like :string_unpack_64bit_le_signed, 'j_<'
- end
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'J<_'
+ it_behaves_like :string_unpack_64bit_le, 'J_<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J<_'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J_<'
+ end
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_64bit_le, 'j<!'
- it_behaves_like :string_unpack_64bit_le, 'j!<'
- it_behaves_like :string_unpack_64bit_le_signed, 'j<!'
- it_behaves_like :string_unpack_64bit_le_signed, 'j!<'
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'J<!'
+ it_behaves_like :string_unpack_64bit_le, 'J!<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J<!'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'J!<'
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_64bit_be, 'j>_'
- it_behaves_like :string_unpack_64bit_be, 'j_>'
- it_behaves_like :string_unpack_64bit_be_signed, 'j>_'
- it_behaves_like :string_unpack_64bit_be_signed, 'j_>'
- end
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'J>_'
+ it_behaves_like :string_unpack_64bit_be, 'J_>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J>_'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J_>'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_64bit_be, 'j>!'
- it_behaves_like :string_unpack_64bit_be, 'j!>'
- it_behaves_like :string_unpack_64bit_be_signed, 'j>!'
- it_behaves_like :string_unpack_64bit_be_signed, 'j!>'
- end
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'J>!'
+ it_behaves_like :string_unpack_64bit_be, 'J!>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J>!'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'J!>'
end
end
- platform_is pointer_size: 32 do
- little_endian do
- describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_le, 'J_'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J_'
- end
-
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_le, 'J!'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J!'
- end
- end
-
- describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_le, 'j_'
- it_behaves_like :string_unpack_32bit_le_signed, 'j_'
- end
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_64bit_le, 'j<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j<'
+ end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_le, 'j!'
- it_behaves_like :string_unpack_32bit_le_signed, 'j!'
- end
- end
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_64bit_be, 'j>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j>'
end
- big_endian do
- describe "String#unpack with format 'J'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_be, 'J_'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J_'
- end
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'j<_'
+ it_behaves_like :string_unpack_64bit_le, 'j_<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j<_'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j_<'
+ end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_be, 'J!'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J!'
- end
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'j<!'
+ it_behaves_like :string_unpack_64bit_le, 'j!<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j<!'
+ it_behaves_like :string_unpack_64bit_le_signed, 'j!<'
+ end
- describe "String#unpack with format 'j'" do
- describe "with modifier '_'" do
- it_behaves_like :string_unpack_32bit_be, 'j_'
- it_behaves_like :string_unpack_32bit_be_signed, 'j_'
- end
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'j>_'
+ it_behaves_like :string_unpack_64bit_be, 'j_>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j>_'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j_>'
+ end
- describe "with modifier '!'" do
- it_behaves_like :string_unpack_32bit_be, 'j!'
- it_behaves_like :string_unpack_32bit_be_signed, 'j!'
- end
- end
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'j>!'
+ it_behaves_like :string_unpack_64bit_be, 'j!>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j>!'
+ it_behaves_like :string_unpack_64bit_be_signed, 'j!>'
end
+ end
+end
+platform_is pointer_size: 32 do
+ little_endian do
describe "String#unpack with format 'J'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_32bit_le, 'J<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J<'
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'J_'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J_'
end
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_32bit_be, 'J>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J>'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'J!'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J!'
end
+ end
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_32bit_le, 'J<_'
- it_behaves_like :string_unpack_32bit_le, 'J_<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J<_'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J_<'
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'j_'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j_'
end
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_32bit_le, 'J<!'
- it_behaves_like :string_unpack_32bit_le, 'J!<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J<!'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'J!<'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'j!'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j!'
end
+ end
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_32bit_be, 'J>_'
- it_behaves_like :string_unpack_32bit_be, 'J_>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J>_'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J_>'
+ big_endian do
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'J_'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J_'
end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_32bit_be, 'J>!'
- it_behaves_like :string_unpack_32bit_be, 'J!>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J>!'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'J!>'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'J!'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J!'
end
end
describe "String#unpack with format 'j'" do
- describe "with modifier '<'" do
- it_behaves_like :string_unpack_32bit_le, 'j<'
- it_behaves_like :string_unpack_32bit_le_signed, 'j<'
+ describe "with modifier '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'j_'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j_'
end
- describe "with modifier '>'" do
- it_behaves_like :string_unpack_32bit_be, 'j>'
- it_behaves_like :string_unpack_32bit_be_signed, 'j>'
+ describe "with modifier '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'j!'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j!'
end
+ end
+ end
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_32bit_le, 'j<_'
- it_behaves_like :string_unpack_32bit_le, 'j_<'
- it_behaves_like :string_unpack_32bit_le_signed, 'j<_'
- it_behaves_like :string_unpack_32bit_le_signed, 'j_<'
- end
+ describe "String#unpack with format 'J'" do
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_32bit_le, 'J<'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J<'
+ end
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_32bit_le, 'j<!'
- it_behaves_like :string_unpack_32bit_le, 'j!<'
- it_behaves_like :string_unpack_32bit_le_signed, 'j<!'
- it_behaves_like :string_unpack_32bit_le_signed, 'j!<'
- end
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_32bit_be, 'J>'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J>'
+ end
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_32bit_be, 'j>_'
- it_behaves_like :string_unpack_32bit_be, 'j_>'
- it_behaves_like :string_unpack_32bit_be_signed, 'j>_'
- it_behaves_like :string_unpack_32bit_be_signed, 'j_>'
- end
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'J<_'
+ it_behaves_like :string_unpack_32bit_le, 'J_<'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J<_'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J_<'
+ end
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_32bit_be, 'j>!'
- it_behaves_like :string_unpack_32bit_be, 'j!>'
- it_behaves_like :string_unpack_32bit_be_signed, 'j>!'
- it_behaves_like :string_unpack_32bit_be_signed, 'j!>'
- end
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'J<!'
+ it_behaves_like :string_unpack_32bit_le, 'J!<'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J<!'
+ it_behaves_like :string_unpack_32bit_le_unsigned, 'J!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'J>_'
+ it_behaves_like :string_unpack_32bit_be, 'J_>'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J>_'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'J>!'
+ it_behaves_like :string_unpack_32bit_be, 'J!>'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J>!'
+ it_behaves_like :string_unpack_32bit_be_unsigned, 'J!>'
+ end
+ end
+
+ describe "String#unpack with format 'j'" do
+ describe "with modifier '<'" do
+ it_behaves_like :string_unpack_32bit_le, 'j<'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j<'
+ end
+
+ describe "with modifier '>'" do
+ it_behaves_like :string_unpack_32bit_be, 'j>'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j>'
+ end
+
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_32bit_le, 'j<_'
+ it_behaves_like :string_unpack_32bit_le, 'j_<'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j<_'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j_<'
+ end
+
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_32bit_le, 'j<!'
+ it_behaves_like :string_unpack_32bit_le, 'j!<'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j<!'
+ it_behaves_like :string_unpack_32bit_le_signed, 'j!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_32bit_be, 'j>_'
+ it_behaves_like :string_unpack_32bit_be, 'j_>'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j>_'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_32bit_be, 'j>!'
+ it_behaves_like :string_unpack_32bit_be, 'j!>'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j>!'
+ it_behaves_like :string_unpack_32bit_be_signed, 'j!>'
end
end
end
diff --git a/spec/ruby/core/string/uplus_spec.rb b/spec/ruby/core/string/uplus_spec.rb
index 6c6792590e..a7402b4549 100644
--- a/spec/ruby/core/string/uplus_spec.rb
+++ b/spec/ruby/core/string/uplus_spec.rb
@@ -1,24 +1,22 @@
require_relative '../../spec_helper'
-ruby_version_is "2.3" do
- describe 'String#+@' do
- it 'returns an unfrozen copy of a frozen String' do
- input = 'foo'.freeze
- output = +input
+describe 'String#+@' do
+ it 'returns an unfrozen copy of a frozen String' do
+ input = 'foo'.freeze
+ output = +input
- output.frozen?.should == false
- output.should == 'foo'
- end
+ output.frozen?.should == false
+ output.should == 'foo'
+ end
- it 'returns self if the String is not frozen' do
- input = 'foo'
- output = +input
+ it 'returns self if the String is not frozen' do
+ input = 'foo'
+ output = +input
- output.equal?(input).should == true
- end
+ output.equal?(input).should == true
+ end
- it 'returns mutable copy despite freeze-magic-comment in file' do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment.rb")).should == 'mutable'
- end
+ it 'returns mutable copy despite freeze-magic-comment in file' do
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment.rb")).should == 'mutable'
end
end
diff --git a/spec/ruby/core/struct/dig_spec.rb b/spec/ruby/core/struct/dig_spec.rb
index f51147a91b..c7c979fabe 100644
--- a/spec/ruby/core/struct/dig_spec.rb
+++ b/spec/ruby/core/struct/dig_spec.rb
@@ -1,44 +1,42 @@
require_relative '../../spec_helper'
-ruby_version_is "2.3" do
- describe "Struct#dig" do
- before(:each) do
- @klass = Struct.new(:a)
- @instance = @klass.new(@klass.new({ b: [1, 2, 3] }))
- end
-
- it "returns the nested value specified by the sequence of keys" do
- @instance.dig(:a, :a).should == { b: [1, 2, 3] }
- end
+describe "Struct#dig" do
+ before(:each) do
+ @klass = Struct.new(:a)
+ @instance = @klass.new(@klass.new({ b: [1, 2, 3] }))
+ end
- it "returns the nested value specified if the sequence includes an index" do
- @instance.dig(:a, :a, :b, 0).should == 1
- end
+ it "returns the nested value specified by the sequence of keys" do
+ @instance.dig(:a, :a).should == { b: [1, 2, 3] }
+ end
- it "returns nil if any intermediate step is nil" do
- @instance.dig(:b, 0).should == nil
- end
+ it "returns the nested value specified if the sequence includes an index" do
+ @instance.dig(:a, :a, :b, 0).should == 1
+ end
- it "raises a TypeError if any intermediate step does not respond to #dig" do
- instance = @klass.new(1)
- lambda {
- instance.dig(:a, 3)
- }.should raise_error(TypeError)
- end
+ it "returns nil if any intermediate step is nil" do
+ @instance.dig(:b, 0).should == nil
+ end
- it "raises an ArgumentError if no arguments provided" do
- lambda { @instance.dig }.should raise_error(ArgumentError)
- end
+ it "raises a TypeError if any intermediate step does not respond to #dig" do
+ instance = @klass.new(1)
+ lambda {
+ instance.dig(:a, 3)
+ }.should raise_error(TypeError)
+ end
- it "calls #dig on any intermediate step with the rest of the sequence as arguments" do
- obj = Object.new
- instance = @klass.new(obj)
+ it "raises an ArgumentError if no arguments provided" do
+ lambda { @instance.dig }.should raise_error(ArgumentError)
+ end
- def obj.dig(*args)
- {dug: args}
- end
+ it "calls #dig on any intermediate step with the rest of the sequence as arguments" do
+ obj = Object.new
+ instance = @klass.new(obj)
- instance.dig(:a, :bar, :baz).should == { dug: [:bar, :baz] }
+ def obj.dig(*args)
+ {dug: args}
end
+
+ instance.dig(:a, :bar, :baz).should == { dug: [:bar, :baz] }
end
end
diff --git a/spec/ruby/core/thread/name_spec.rb b/spec/ruby/core/thread/name_spec.rb
index 503a909158..adb2d08fae 100644
--- a/spec/ruby/core/thread/name_spec.rb
+++ b/spec/ruby/core/thread/name_spec.rb
@@ -1,56 +1,54 @@
require_relative '../../spec_helper'
-ruby_version_is '2.3' do
- describe "Thread#name" do
- before :each do
- @thread = Thread.new {}
- end
-
- after :each do
- @thread.join
- end
-
- it "is nil initially" do
- @thread.name.should == nil
- end
-
- it "returns the thread name" do
- @thread.name = "thread_name"
- @thread.name.should == "thread_name"
- end
- end
-
- describe "Thread#name=" do
- before :each do
- @thread = Thread.new {}
- end
-
- after :each do
- @thread.join
- end
-
- it "can be set to a String" do
- @thread.name = "new thread name"
- @thread.name.should == "new thread name"
- end
-
- it "raises an ArgumentError if the name includes a null byte" do
- lambda {
- @thread.name = "new thread\0name"
- }.should raise_error(ArgumentError)
- end
-
- it "can be reset to nil" do
- @thread.name = nil
- @thread.name.should == nil
- end
-
- it "calls #to_str to convert name to String" do
- name = mock("Thread#name")
- name.should_receive(:to_str).and_return("a thread name")
-
- @thread.name = name
- @thread.name.should == "a thread name"
- end
+describe "Thread#name" do
+ before :each do
+ @thread = Thread.new {}
+ end
+
+ after :each do
+ @thread.join
+ end
+
+ it "is nil initially" do
+ @thread.name.should == nil
+ end
+
+ it "returns the thread name" do
+ @thread.name = "thread_name"
+ @thread.name.should == "thread_name"
+ end
+end
+
+describe "Thread#name=" do
+ before :each do
+ @thread = Thread.new {}
+ end
+
+ after :each do
+ @thread.join
+ end
+
+ it "can be set to a String" do
+ @thread.name = "new thread name"
+ @thread.name.should == "new thread name"
+ end
+
+ it "raises an ArgumentError if the name includes a null byte" do
+ lambda {
+ @thread.name = "new thread\0name"
+ }.should raise_error(ArgumentError)
+ end
+
+ it "can be reset to nil" do
+ @thread.name = nil
+ @thread.name.should == nil
+ end
+
+ it "calls #to_str to convert name to String" do
+ name = mock("Thread#name")
+ name.should_receive(:to_str).and_return("a thread name")
+
+ @thread.name = name
+ @thread.name.should == "a thread name"
end
end
diff --git a/spec/ruby/core/time/at_spec.rb b/spec/ruby/core/time/at_spec.rb
index 8363a0bc70..7c66104156 100644
--- a/spec/ruby/core/time/at_spec.rb
+++ b/spec/ruby/core/time/at_spec.rb
@@ -34,7 +34,7 @@ describe "Time.at" do
describe "passed BigDecimal" do
it "doesn't round input value" do
require 'bigdecimal'
- Time.at(BigDecimal.new('1.1')).to_f.should == 1.1
+ Time.at(BigDecimal('1.1')).to_f.should == 1.1
end
end
end
diff --git a/spec/ruby/core/tracepoint/disable_spec.rb b/spec/ruby/core/tracepoint/disable_spec.rb
index 1ee3125351..e936d3498d 100644
--- a/spec/ruby/core/tracepoint/disable_spec.rb
+++ b/spec/ruby/core/tracepoint/disable_spec.rb
@@ -55,7 +55,7 @@ describe 'TracePoint#disable' do
end
end
- ruby_bug "#14057", "2.0"..."2.5" do
+ ruby_bug "#14057", ""..."2.5" do
it 'can accept param within a block but it should not yield arguments' do
event_name = nil
trace = TracePoint.new(:line) {}
diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb
index 769c1b643a..b1a8628896 100644
--- a/spec/ruby/core/tracepoint/enable_spec.rb
+++ b/spec/ruby/core/tracepoint/enable_spec.rb
@@ -62,7 +62,7 @@ describe 'TracePoint#enable' do
end.enable { event_name.should equal(:line) }
end
- ruby_bug "#14057", "2.0"..."2.5" do
+ ruby_bug "#14057", ""..."2.5" do
it 'can accept arguments within a block but it should not yield arguments' do
event_name = nil
trace = TracePoint.new(:line) { |tp| event_name = tp.event }
diff --git a/spec/ruby/core/tracepoint/new_spec.rb b/spec/ruby/core/tracepoint/new_spec.rb
index ec6f673745..77675561f6 100644
--- a/spec/ruby/core/tracepoint/new_spec.rb
+++ b/spec/ruby/core/tracepoint/new_spec.rb
@@ -56,7 +56,7 @@ describe 'TracePoint.new' do
-> { TracePoint.new(o) {}}.should raise_error(TypeError)
end
- ruby_bug "#140740", "2.0"..."2.5" do
+ ruby_bug "#140740", ""..."2.5" do
it 'expects to be called with a block' do
-> { TracePoint.new(:line) }.should raise_error(ArgumentError)
end