diff options
author | Benoit Daloze <eregontp@gmail.com> | 2022-04-25 14:53:54 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2022-04-25 14:53:54 +0200 |
commit | 45cf4f218728a15eb36d14a6c9912086525f5e3f (patch) | |
tree | 2aa93fadcb904c226f722dde47827098b87a9846 /spec/ruby/core/warning/element_set_spec.rb | |
parent | 6ae81d49b52563a6720d666a6118ffa6e484f398 (diff) |
Update to ruby/spec@3affe1e
Diffstat (limited to 'spec/ruby/core/warning/element_set_spec.rb')
-rw-r--r-- | spec/ruby/core/warning/element_set_spec.rb | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/spec/ruby/core/warning/element_set_spec.rb b/spec/ruby/core/warning/element_set_spec.rb index 611060fb3a..d20ee215ad 100644 --- a/spec/ruby/core/warning/element_set_spec.rb +++ b/spec/ruby/core/warning/element_set_spec.rb @@ -1,37 +1,35 @@ require_relative '../../spec_helper' -ruby_version_is '2.7' do - describe "Warning.[]=" do - it "emits and suppresses warnings for :deprecated" do - ruby_exe('Warning[:deprecated] = true; $; = ""', args: "2>&1").should =~ /is deprecated/ - ruby_exe('Warning[:deprecated] = false; $; = ""', args: "2>&1").should == "" - end - - describe ":experimental" do - before do - ruby_version_is ""..."3.0" do - @src = 'case [0, 1]; in [a, b]; end' - end +describe "Warning.[]=" do + it "emits and suppresses warnings for :deprecated" do + ruby_exe('Warning[:deprecated] = true; $; = ""', args: "2>&1").should =~ /is deprecated/ + ruby_exe('Warning[:deprecated] = false; $; = ""', args: "2>&1").should == "" + end - ruby_version_is "3.0" do - @src = 'warn "This is experimental warning.", category: :experimental' - end + describe ":experimental" do + before do + ruby_version_is ""..."3.0" do + @src = 'case [0, 1]; in [a, b]; 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 == "" + ruby_version_is "3.0" do + @src = 'warn "This is experimental warning.", category: :experimental' end end - it "raises for unknown category" do - -> { Warning[:noop] = false }.should raise_error(ArgumentError, /unknown category: noop/) + 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 non-Symbol category" do - -> { Warning[42] = false }.should raise_error(TypeError) - -> { Warning[false] = false }.should raise_error(TypeError) - -> { Warning["noop"] = false }.should raise_error(TypeError) - end + it "raises for unknown category" do + -> { Warning[:noop] = false }.should raise_error(ArgumentError, /unknown category: noop/) + end + + it "raises for non-Symbol category" do + -> { Warning[42] = false }.should raise_error(TypeError) + -> { Warning[false] = false }.should raise_error(TypeError) + -> { Warning["noop"] = false }.should raise_error(TypeError) end end |