ruby-changes:63426
From: Benoit <ko1@a...>
Date: Sat, 24 Oct 2020 22:54:16 +0900 (JST)
Subject: [ruby-changes:63426] 148961adcd (master): Update to ruby/spec@4f59d86
https://git.ruby-lang.org/ruby.git/commit/?id=148961adcd From 148961adcd0704d964fce920330a6301b9704c25 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Sat, 24 Oct 2020 15:52:37 +0200 Subject: Update to ruby/spec@4f59d86 diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb index 31bb976..8343bc0 100644 --- a/spec/ruby/command_line/dash_upper_w_spec.rb +++ b/spec/ruby/command_line/dash_upper_w_spec.rb @@ -18,3 +18,25 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_upper_w_spec.rb#L18 describe "The -W command line option with 2" do it_behaves_like :command_line_verbose, "-W2" end + +ruby_version_is "2.7" do + describe "The -W command line option with :no-deprecated" do + it "suppresses deprecation warnings" do + result = ruby_exe('$; = ""', options: '-w', args: '2>&1') + result.should =~ /is deprecated/ + + result = ruby_exe('$; = ""', options: '-w -W:no-deprecated', args: '2>&1') + result.should == "" + end + end + + describe "The -W command line option with :no-experimental" do + it "suppresses experimental warnings" do + result = ruby_exe('0 in a', args: '2>&1') + result.should =~ /is experimental/ + + result = ruby_exe('0 in a', options: '-W:no-experimental', args: '2>&1') + result.should == "" + end + end +end diff --git a/spec/ruby/command_line/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb index 8848249..16e106b 100644 --- a/spec/ruby/command_line/feature_spec.rb +++ b/spec/ruby/command_line/feature_spec.rb @@ -37,11 +37,13 @@ describe "The --enable and --disable flags" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/feature_spec.rb#L37 ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false" end - it "can be used with all for enable" do - e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]" - env = {'RUBYOPT' => '-w'} - # Use a single variant here because it can be quite slow as it might enable jit, etc - ruby_exe(e, options: "--enable-all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]" + platform_is_not :darwin do # frequently hangs for >60s on GitHub Actions macos-latest + it "can be used with all for enable" do + e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]" + env = {'RUBYOPT' => '-w'} + # Use a single variant here because it can be quite slow as it might enable jit, etc + ruby_exe(e, options: "--enable-all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]" + end end it "can be used with all for disable" do diff --git a/spec/ruby/command_line/rubyopt_spec.rb b/spec/ruby/command_line/rubyopt_spec.rb index 2db42f7..ee4e594 100644 --- a/spec/ruby/command_line/rubyopt_spec.rb +++ b/spec/ruby/command_line/rubyopt_spec.rb @@ -59,6 +59,26 @@ describe "Processing RUBYOPT" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/rubyopt_spec.rb#L59 ruby_exe("p $VERBOSE", escape: true).chomp.should == "true" end + ruby_version_is "2.7" do + it "suppresses deprecation warnings for '-W:no-deprecated'" do + ENV["RUBYOPT"] = '-W:no-deprecated' + result = ruby_exe('$; = ""', args: '2>&1') + result.should == "" + end + + it "suppresses experimental warnings for '-W:no-experimental'" do + ENV["RUBYOPT"] = '-W:no-experimental' + result = ruby_exe('0 in a', args: '2>&1') + result.should == "" + end + + it "suppresses deprecation and experimental warnings for '-W:no-deprecated -W:no-experimental'" do + ENV["RUBYOPT"] = '-W:no-deprecated -W:no-experimental' + result = ruby_exe('($; = "") in a', args: '2>&1') + result.should == "" + end + end + it "requires the file for '-r'" do f = fixture __FILE__, "rubyopt" ENV["RUBYOPT"] = "-r#{f}" diff --git a/spec/ruby/core/array/minmax_spec.rb b/spec/ruby/core/array/minmax_spec.rb new file mode 100644 index 0000000..e11fe63 --- /dev/null +++ b/spec/ruby/core/array/minmax_spec.rb @@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/minmax_spec.rb#L1 +require_relative '../../spec_helper' +require_relative '../../shared/enumerable/minmax' + +describe "Array#minmax" do + before :each do + @enum = [6, 4, 5, 10, 8] + @empty_enum = [] + @incomparable_enum = [BasicObject.new, BasicObject.new] + @incompatible_enum = [11, "22"] + @strs = ["333", "2", "60", "55555", "1010", "111"] + end + + it_behaves_like :enumerable_minmax, :minmax +end diff --git a/spec/ruby/core/class/new_spec.rb b/spec/ruby/core/class/new_spec.rb index 989d674..f863766 100644 --- a/spec/ruby/core/class/new_spec.rb +++ b/spec/ruby/core/class/new_spec.rb @@ -96,11 +96,12 @@ describe "Class.new" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/class/new_spec.rb#L96 it "raises a TypeError when given a non-Class" do error_msg = /superclass must be a Class/ - -> { Class.new("") }.should raise_error(TypeError, error_msg) - -> { Class.new(1) }.should raise_error(TypeError, error_msg) - -> { Class.new(:symbol) }.should raise_error(TypeError, error_msg) - -> { Class.new(mock('o')) }.should raise_error(TypeError, error_msg) - -> { Class.new(Module.new) }.should raise_error(TypeError, error_msg) + -> { Class.new("") }.should raise_error(TypeError, error_msg) + -> { Class.new(1) }.should raise_error(TypeError, error_msg) + -> { Class.new(:symbol) }.should raise_error(TypeError, error_msg) + -> { Class.new(mock('o')) }.should raise_error(TypeError, error_msg) + -> { Class.new(Module.new) }.should raise_error(TypeError, error_msg) + -> { Class.new(BasicObject.new) }.should raise_error(TypeError, error_msg) end end diff --git a/spec/ruby/core/encoding/list_spec.rb b/spec/ruby/core/encoding/list_spec.rb index 2a20789..8efd94a 100644 --- a/spec/ruby/core/encoding/list_spec.rb +++ b/spec/ruby/core/encoding/list_spec.rb @@ -12,7 +12,7 @@ describe "Encoding.list" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/encoding/list_spec.rb#L12 end it "returns each encoding only once" do - orig = Encoding.list.map {|e| e.name} + orig = Encoding.list.map { |e| e.name } orig.should == orig.uniq end @@ -33,7 +33,17 @@ describe "Encoding.list" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/encoding/list_spec.rb#L33 end it "includes dummy encodings" do - Encoding.list.select {|e| e.dummy?}.should_not == [] + Encoding.list.select { |e| e.dummy? }.should_not == [] + end + + it 'includes UTF-8 encoding' do + Encoding.list.should.include?(Encoding::UTF_8) + end + + ruby_version_is "2.7" do + it 'includes CESU-8 encoding' do + Encoding.list.should.include?(Encoding::CESU_8) + end end # TODO: Find example that illustrates this diff --git a/spec/ruby/core/enumerable/minmax_spec.rb b/spec/ruby/core/enumerable/minmax_spec.rb index 29f1ecf..f5f17ef 100644 --- a/spec/ruby/core/enumerable/minmax_spec.rb +++ b/spec/ruby/core/enumerable/minmax_spec.rb @@ -1,41 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/enumerable/minmax_spec.rb#L1 require_relative '../../spec_helper' require_relative 'fixtures/classes' +require_relative '../../shared/enumerable/minmax' describe "Enumerable#minmax" do before :each do @enum = EnumerableSpecs::Numerous.new(6, 4, 5, 10, 8) - + @empty_enum = EnumerableSpecs::Empty.new + @incomparable_enum = EnumerableSpecs::Numerous.new(BasicObject.new, BasicObject.new) + @incompatible_enum = EnumerableSpecs::Numerous.new(11,"22") @strs = EnumerableSpecs::Numerous.new("333", "2", "60", "55555", "1010", "111") end - it "min should return the minimum element" do - @enum.minmax.should == [4, 10] - @strs.minmax.should == ["1010", "60" ] - end - - it "returns [nil, nil] for an empty Enumerable" do - EnumerableSpecs::Empty.new.minmax.should == [nil, nil] - end - - it "raises an ArgumentError when elements are incomparable" do - -> do - EnumerableSpecs::Numerous.new(11,"22").minmax - end.should raise_error(ArgumentError) - -> do - EnumerableSpecs::Numerous.new(11,12,22,33).minmax{|a, b| nil} - end.should raise_error(ArgumentError) - end - - it "raises a NoMethodError for elements without #<=>" do - -> do - EnumerableSpecs::Numerous.new(BasicObject.new, BasicObject.new).minmax - end.should raise_error(NoMethodError) - end - - it "returns the minimum when using a block rule" do - @enum.minmax {|a,b| b <=> a }.should == [10, 4] - @strs.minmax {|a,b| a.length <=> b.length }.should == ["2", "55555"] - end + it_behaves_like :enumerable_minmax, :minmax it "gathers whole arrays as elements when each yields multiple" do multi = EnumerableSpecs::YieldsMulti.new diff --git a/spec/ruby/core/env/shared/key.rb b/spec/ruby/core/env/shared/key.rb index fcb3a9b..93396d2 100644 --- a/spec/ruby/core/env/shared/key.rb +++ b/spec/ruby/core/env/shared/key.rb @@ -9,15 +9,23 @@ describe :env_key, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/shared/key.rb#L9 it "returns the index associated with the passed value" do ENV["foo"] = "bar" - ENV.send(@method, "bar").should == "foo" + suppress_warning { + ENV.send(@method, "bar").should == "foo" + } end it "returns nil if the passed value is not found" do ENV.delete("foo") - ENV.send(@method, "foo").should be_nil + suppress_warning { + ENV.send(@method, "foo").should be_nil + } end it "raises TypeError if the argument is not a String and does not respond to #to_str" do - -> { ENV.send(@method, Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { + suppress_warning { + ENV.send(@method, Object.new) + } + }.should (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/