Skip to content

Commit

Permalink
Fix Rubyspec (ruby-2.7) failures
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tsj committed Nov 1, 2020
1 parent e03e198 commit e0e2492
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
14 changes: 12 additions & 2 deletions spec/ruby/command_line/dash_upper_w_spec.rb
Expand Up @@ -31,11 +31,21 @@
end

describe "The -W command line option with :no-experimental" do
before do
ruby_version_is ""..."3.0" do
@src = 'case 0; in a; end'
end

ruby_version_is "3.0" do
@src = '1 => a'
end
end

it "suppresses experimental warnings" do
result = ruby_exe('1 => a', args: '2>&1')
result = ruby_exe(@src, args: '2>&1')
result.should =~ /is experimental/

result = ruby_exe('case 0; in a; end', options: '-W:no-experimental', args: '2>&1')
result = ruby_exe(@src, options: '-W:no-experimental', args: '2>&1')
result.should == ""
end
end
Expand Down
18 changes: 15 additions & 3 deletions spec/ruby/core/warning/element_set_spec.rb
Expand Up @@ -7,9 +7,21 @@
ruby_exe('Warning[:deprecated] = false; $; = ""', args: "2>&1").should == ""
end

it "emits and suppresses warnings for :experimental" do
ruby_exe('Warning[:experimental] = true; eval("1 => a")', args: "2>&1").should =~ /is experimental/
ruby_exe('Warning[:experimental] = false; eval("1 => a")', args: "2>&1").should == ""
describe ":experimental" do
before do
ruby_version_is ""..."3.0" do
@src = 'case 0; in a; end'
end

ruby_version_is "3.0" do
@src = '1 => a'
end
end

it "emits and suppresses warnings for :experimental" do
ruby_exe("Warning[:experimental] = true; eval('#{@src}')", args: "2>&1").should =~ /is experimental/
ruby_exe("Warning[:experimental] = false; eval('#{@src}')", args: "2>&1").should == ""
end
end

it "raises for unknown category" do
Expand Down
20 changes: 14 additions & 6 deletions spec/ruby/language/pattern_matching_spec.rb
Expand Up @@ -38,12 +38,20 @@
RUBY
end

it "warns about pattern matching is experimental feature" do
-> {
eval <<~RUBY
1 => a
RUBY
}.should complain(/warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!/)
describe "warning" do
before do
ruby_version_is ""..."3.0" do
@src = 'case 0; in a; end'
end

ruby_version_is "3.0" do
@src = '1 => a'
end
end

it "warns about pattern matching is experimental feature" do
-> { eval @src }.should complain(/pattern matching is experimental, and the behavior may change in future versions of Ruby!/i)
end
end

it "binds variables" do
Expand Down

0 comments on commit e0e2492

Please sign in to comment.