diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-08 19:43:27 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-01 15:36:20 +0900 |
commit | 826f44834fe11f3f9c52343443a15b6c83466889 (patch) | |
tree | f2c2abed62db1c750515cd8b0fbac6442b6d4200 /spec/ruby/core/kernel | |
parent | 3a2073e61b6ccce6d07d31ebd89d4c385b9a55f2 (diff) | |
download | ruby-826f44834fe11f3f9c52343443a15b6c83466889.tar.gz |
Drop support for ruby 2.4 from ruby/spec
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r-- | spec/ruby/core/kernel/freeze_spec.rb | 24 | ||||
-rw-r--r-- | spec/ruby/core/kernel/frozen_spec.rb | 36 | ||||
-rw-r--r-- | spec/ruby/core/kernel/pp_spec.rb | 12 | ||||
-rw-r--r-- | spec/ruby/core/kernel/shared/dup_clone.rb | 26 | ||||
-rw-r--r-- | spec/ruby/core/kernel/shared/require.rb | 73 | ||||
-rw-r--r-- | spec/ruby/core/kernel/shared/sprintf.rb | 44 | ||||
-rw-r--r-- | spec/ruby/core/kernel/warn_spec.rb | 124 | ||||
-rw-r--r-- | spec/ruby/core/kernel/yield_self_spec.rb | 6 |
8 files changed, 141 insertions, 204 deletions
diff --git a/spec/ruby/core/kernel/freeze_spec.rb b/spec/ruby/core/kernel/freeze_spec.rb index 214b619f9f..e4a01b5df5 100644 --- a/spec/ruby/core/kernel/freeze_spec.rb +++ b/spec/ruby/core/kernel/freeze_spec.rb @@ -51,21 +51,19 @@ describe "Kernel#freeze" do end end - ruby_version_is "2.5" do - describe "on a Complex" do - it "has no effect since it is already frozen" do - c = Complex(1.3, 3.1) - c.frozen?.should be_true - c.freeze - end + describe "on a Complex" do + it "has no effect since it is already frozen" do + c = Complex(1.3, 3.1) + c.frozen?.should be_true + c.freeze end + end - describe "on a Rational" do - it "has no effect since it is already frozen" do - r = Rational(1, 3) - r.frozen?.should be_true - r.freeze - end + describe "on a Rational" do + it "has no effect since it is already frozen" do + r = Rational(1, 3) + r.frozen?.should be_true + r.freeze end end diff --git a/spec/ruby/core/kernel/frozen_spec.rb b/spec/ruby/core/kernel/frozen_spec.rb index 5887ed75ba..54edae15b1 100644 --- a/spec/ruby/core/kernel/frozen_spec.rb +++ b/spec/ruby/core/kernel/frozen_spec.rb @@ -50,29 +50,27 @@ describe "Kernel#frozen?" do end end - ruby_version_is "2.5" do - describe "on a Complex" do - it "returns true" do - c = Complex(1.3, 3.1) - c.frozen?.should be_true - end + describe "on a Complex" do + it "returns true" do + c = Complex(1.3, 3.1) + c.frozen?.should be_true + end - it "literal returns true" do - c = eval "1.3i" - c.frozen?.should be_true - end + it "literal returns true" do + c = eval "1.3i" + c.frozen?.should be_true end + end - describe "on a Rational" do - it "returns true" do - r = Rational(1, 3) - r.frozen?.should be_true - end + describe "on a Rational" do + it "returns true" do + r = Rational(1, 3) + r.frozen?.should be_true + end - it "literal returns true" do - r = eval "1/3r" - r.frozen?.should be_true - end + it "literal returns true" do + r = eval "1/3r" + r.frozen?.should be_true end end end diff --git a/spec/ruby/core/kernel/pp_spec.rb b/spec/ruby/core/kernel/pp_spec.rb index e19dc64caf..b5b1c98d38 100644 --- a/spec/ruby/core/kernel/pp_spec.rb +++ b/spec/ruby/core/kernel/pp_spec.rb @@ -1,11 +1,9 @@ require_relative '../../spec_helper' -ruby_version_is "2.5" do - describe "Kernel#pp" do - it "lazily loads the 'pp' library and delegates the call to that library" do - # Run in child process to ensure 'pp' hasn't been loaded yet. - output = ruby_exe("pp [1, 2, 3]") - output.should == "[1, 2, 3]\n" - end +describe "Kernel#pp" do + it "lazily loads the 'pp' library and delegates the call to that library" do + # Run in child process to ensure 'pp' hasn't been loaded yet. + output = ruby_exe("pp [1, 2, 3]") + output.should == "[1, 2, 3]\n" end end diff --git a/spec/ruby/core/kernel/shared/dup_clone.rb b/spec/ruby/core/kernel/shared/dup_clone.rb index a52ccab359..968efd80f3 100644 --- a/spec/ruby/core/kernel/shared/dup_clone.rb +++ b/spec/ruby/core/kernel/shared/dup_clone.rb @@ -103,27 +103,13 @@ describe :kernel_dup_clone, shared: true do :my_symbol.send(@method).should == :my_symbol end - ruby_version_is ''...'2.5' do - it "raises a TypeError for Complex" do - c = Complex(1.3, 3.1) - -> { c.send(@method) }.should raise_error(TypeError) - end - - it "raises a TypeError for Rational" do - r = Rational(1, 3) - -> { r.send(@method) }.should raise_error(TypeError) - end + it "returns self for Complex" do + c = Complex(1.3, 3.1) + c.send(@method).should equal c end - ruby_version_is '2.5' do - it "returns self for Complex" do - c = Complex(1.3, 3.1) - c.send(@method).should equal c - end - - it "returns self for Rational" do - r = Rational(1, 3) - r.send(@method).should equal r - end + it "returns self for Rational" do + r = Rational(1, 3) + r.send(@method).should equal r end end diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb index 52089f22fe..69977194e9 100644 --- a/spec/ruby/core/kernel/shared/require.rb +++ b/spec/ruby/core/kernel/shared/require.rb @@ -354,26 +354,13 @@ describe :kernel_require, shared: true do rm_r @dir, @symlink_to_dir end - ruby_version_is ""..."2.4.4" do - it "canonicalizes neither the entry in $LOAD_PATH nor the filename passed to #require" do - $LOAD_PATH.unshift(@symlink_to_dir) - @object.require("symfile").should be_true - loaded_feature = "#{@symlink_to_dir}/symfile.rb" - ScratchPad.recorded.should == [loaded_feature] - $".last.should == loaded_feature - $LOAD_PATH[0].should == @symlink_to_dir - end - end - - ruby_version_is "2.4.4" do - it "canonicalizes the entry in $LOAD_PATH but not the filename passed to #require" do - $LOAD_PATH.unshift(@symlink_to_dir) - @object.require("symfile").should be_true - loaded_feature = "#{@dir}/symfile.rb" - ScratchPad.recorded.should == [loaded_feature] - $".last.should == loaded_feature - $LOAD_PATH[0].should == @symlink_to_dir - end + it "canonicalizes the entry in $LOAD_PATH but not the filename passed to #require" do + $LOAD_PATH.unshift(@symlink_to_dir) + @object.require("symfile").should be_true + loaded_feature = "#{@dir}/symfile.rb" + ScratchPad.recorded.should == [loaded_feature] + $".last.should == loaded_feature + $LOAD_PATH[0].should == @symlink_to_dir end end end @@ -527,41 +514,25 @@ describe :kernel_require, shared: true do ScratchPad.recorded.should == [] end - 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') - provided.each { |feature| - features.should =~ /\b#{feature}\.(rb|so|jar)$/ - } + it "complex, enumerator, rational and thread are already required" do + provided = %w[complex enumerator rational thread] + features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems') + provided.each { |feature| + features.should =~ /\b#{feature}\.(rb|so|jar)$/ + } - code = provided.map { |f| "puts require #{f.inspect}\n" }.join - required = ruby_exe(code, options: '--disable-gems') - required.should == "false\n" * provided.size - end + code = provided.map { |f| "puts require #{f.inspect}\n" }.join + required = ruby_exe(code, options: '--disable-gems') + required.should == "false\n" * provided.size end - ruby_version_is "2.5" do - it "complex, enumerator, rational and thread are already required" do - provided = %w[complex enumerator rational thread] - features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems') - provided.each { |feature| - features.should =~ /\b#{feature}\.(rb|so|jar)$/ - } - - code = provided.map { |f| "puts require #{f.inspect}\n" }.join - required = ruby_exe(code, options: '--disable-gems') - required.should == "false\n" * provided.size - end + it "unicode_normalize is part of core and not $LOADED_FEATURES" do + features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems') + features.lines.each { |feature| + feature.should_not include("unicode_normalize") + } - it "unicode_normalize is part of core and not $LOADED_FEATURES" do - features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems') - features.lines.each { |feature| - feature.should_not include("unicode_normalize") - } - - -> { @object.require("unicode_normalize") }.should raise_error(LoadError) - end + -> { @object.require("unicode_normalize") }.should raise_error(LoadError) end end diff --git a/spec/ruby/core/kernel/shared/sprintf.rb b/spec/ruby/core/kernel/shared/sprintf.rb index 1ad6f8a3cf..ca1e6bb2ed 100644 --- a/spec/ruby/core/kernel/shared/sprintf.rb +++ b/spec/ruby/core/kernel/shared/sprintf.rb @@ -345,18 +345,10 @@ describe :kernel_sprintf, shared: true do end describe "%" do - ruby_version_is ""..."2.5" do - it "alone displays the percent sign" do - @method.call("%").should == "%" - end - end - - ruby_version_is "2.5" do - it "alone raises an ArgumentError" do - -> { - @method.call("%") - }.should raise_error(ArgumentError) - end + it "alone raises an ArgumentError" do + -> { + @method.call("%") + }.should raise_error(ArgumentError) end it "is escaped by %" do @@ -876,22 +868,20 @@ describe :kernel_sprintf, shared: true do }.should raise_error(KeyError) end - ruby_version_is "2.5" do - it "sets the Hash as the receiver of KeyError" do - -> { - @method.call("%<foo>s", @object) - }.should raise_error(KeyError) { |err| - err.receiver.should equal(@object) - } - end + it "sets the Hash as the receiver of KeyError" do + -> { + @method.call("%<foo>s", @object) + }.should raise_error(KeyError) { |err| + err.receiver.should equal(@object) + } + end - it "sets the unmatched key as the key of KeyError" do - -> { - @method.call("%<foo>s", @object) - }.should raise_error(KeyError) { |err| - err.key.to_s.should == 'foo' - } - end + it "sets the unmatched key as the key of KeyError" do + -> { + @method.call("%<foo>s", @object) + }.should raise_error(KeyError) { |err| + err.key.to_s.should == 'foo' + } end end end diff --git a/spec/ruby/core/kernel/warn_spec.rb b/spec/ruby/core/kernel/warn_spec.rb index 774f4378ad..84cfa78672 100644 --- a/spec/ruby/core/kernel/warn_spec.rb +++ b/spec/ruby/core/kernel/warn_spec.rb @@ -87,71 +87,69 @@ describe "Kernel#warn" do }.should output(nil, "to_s called\n") end - ruby_version_is "2.5" do - describe ":uplevel keyword argument" do - before :each do - $VERBOSE = true - end - - it "prepends a message with specified line from the backtrace" do - w = KernelSpecs::WarnInNestedCall.new - - -> { w.f4("foo", 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: foo|) - -> { w.f4("foo", 1) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f1_call_lineno}: warning: foo|) - -> { w.f4("foo", 2) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f2_call_lineno}: warning: foo|) - -> { w.f4("foo", 3) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f3_call_lineno}: warning: foo|) - end - - it "converts first arg using to_s" do - w = KernelSpecs::WarnInNestedCall.new - - -> { w.f4(false, 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: false|) - -> { w.f4(nil, 1) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f1_call_lineno}: warning: |) - obj = mock("obj") - obj.should_receive(:to_s).and_return("to_s called") - -> { w.f4(obj, 2) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f2_call_lineno}: warning: to_s called|) - end - - it "does not prepend caller information if the uplevel argument is too large" do - w = KernelSpecs::WarnInNestedCall.new - -> { w.f4("foo", 100) }.should output(nil, "warning: foo\n") - end - - it "prepends even if a message is empty or nil" do - w = KernelSpecs::WarnInNestedCall.new - - -> { w.f4("", 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: \n$|) - -> { w.f4(nil, 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: \n$|) - end - - it "converts value to Integer" do - w = KernelSpecs::WarnInNestedCall.new - - -> { w.f4(0.1) }.should output(nil, %r|classes.rb:#{w.warn_call_lineno}:|) - -> { w.f4(Rational(1, 2)) }.should output(nil, %r|classes.rb:#{w.warn_call_lineno}:|) - end - - it "raises ArgumentError if passed negative value" do - -> { warn "", uplevel: -2 }.should raise_error(ArgumentError) - -> { warn "", uplevel: -100 }.should raise_error(ArgumentError) - end - - it "raises ArgumentError if passed -1" do - -> { warn "", uplevel: -1 }.should raise_error(ArgumentError) - end - - it "raises TypeError if passed not Integer" do - -> { warn "", uplevel: "" }.should raise_error(TypeError) - -> { warn "", uplevel: [] }.should raise_error(TypeError) - -> { warn "", uplevel: {} }.should raise_error(TypeError) - -> { warn "", uplevel: Object.new }.should raise_error(TypeError) - end + describe ":uplevel keyword argument" do + before :each do + $VERBOSE = true + end + + it "prepends a message with specified line from the backtrace" do + w = KernelSpecs::WarnInNestedCall.new + + -> { w.f4("foo", 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: foo|) + -> { w.f4("foo", 1) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f1_call_lineno}: warning: foo|) + -> { w.f4("foo", 2) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f2_call_lineno}: warning: foo|) + -> { w.f4("foo", 3) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f3_call_lineno}: warning: foo|) end - it "treats empty hash as no keyword argument" do - h = {} - -> { warn(**h) }.should_not complain(verbose: true) - -> { warn('foo', **h) }.should complain("foo\n") + it "converts first arg using to_s" do + w = KernelSpecs::WarnInNestedCall.new + + -> { w.f4(false, 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: false|) + -> { w.f4(nil, 1) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f1_call_lineno}: warning: |) + obj = mock("obj") + obj.should_receive(:to_s).and_return("to_s called") + -> { w.f4(obj, 2) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f2_call_lineno}: warning: to_s called|) end + + it "does not prepend caller information if the uplevel argument is too large" do + w = KernelSpecs::WarnInNestedCall.new + -> { w.f4("foo", 100) }.should output(nil, "warning: foo\n") + end + + it "prepends even if a message is empty or nil" do + w = KernelSpecs::WarnInNestedCall.new + + -> { w.f4("", 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: \n$|) + -> { w.f4(nil, 0) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.warn_call_lineno}: warning: \n$|) + end + + it "converts value to Integer" do + w = KernelSpecs::WarnInNestedCall.new + + -> { w.f4(0.1) }.should output(nil, %r|classes.rb:#{w.warn_call_lineno}:|) + -> { w.f4(Rational(1, 2)) }.should output(nil, %r|classes.rb:#{w.warn_call_lineno}:|) + end + + it "raises ArgumentError if passed negative value" do + -> { warn "", uplevel: -2 }.should raise_error(ArgumentError) + -> { warn "", uplevel: -100 }.should raise_error(ArgumentError) + end + + it "raises ArgumentError if passed -1" do + -> { warn "", uplevel: -1 }.should raise_error(ArgumentError) + end + + it "raises TypeError if passed not Integer" do + -> { warn "", uplevel: "" }.should raise_error(TypeError) + -> { warn "", uplevel: [] }.should raise_error(TypeError) + -> { warn "", uplevel: {} }.should raise_error(TypeError) + -> { warn "", uplevel: Object.new }.should raise_error(TypeError) + end + end + + it "treats empty hash as no keyword argument" do + h = {} + -> { warn(**h) }.should_not complain(verbose: true) + -> { warn('foo', **h) }.should complain("foo\n") end end diff --git a/spec/ruby/core/kernel/yield_self_spec.rb b/spec/ruby/core/kernel/yield_self_spec.rb index affedae144..e311dcee47 100644 --- a/spec/ruby/core/kernel/yield_self_spec.rb +++ b/spec/ruby/core/kernel/yield_self_spec.rb @@ -1,8 +1,6 @@ require_relative '../../spec_helper' require_relative 'shared/then' -ruby_version_is "2.5" do - describe "Kernel#yield_self" do - it_behaves_like :kernel_then, :yield_self - end +describe "Kernel#yield_self" do + it_behaves_like :kernel_then, :yield_self end |