diff options
Diffstat (limited to 'spec/ruby/core/kernel/shared')
| -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 |
3 files changed, 45 insertions, 98 deletions
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 |
