-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add spec Warning[category] = true|false to emit/suppress warnings
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require_relative '../../spec_helper' | ||
|
||
ruby_version_is '2.7.2' do | ||
describe "Warning.[]" do | ||
it "returns default values for categories :deprecated and :experimental" do | ||
ruby_exe('p Warning[:deprecated]').chomp.should == "false" | ||
ruby_exe('p Warning[:experimental]').chomp.should == "true" | ||
end | ||
|
||
it "raises for unknown category" do | ||
-> { Warning[:noop] }.should raise_error(ArgumentError, /unknown category: noop/) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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 | ||
|
||
it "emits and suppresses warnings for :experimental" do | ||
ruby_exe('Warning[:experimental] = true; eval("0 in a")', args: "2>&1").should =~ /is experimental/ | ||
ruby_exe('Warning[:experimental] = false; eval("0 in a")', args: "2>&1").should == "" | ||
end | ||
|
||
it "raises for unknown category" do | ||
-> { Warning[:noop] = false }.should raise_error(ArgumentError, /unknown category: noop/) | ||
end | ||
end | ||
end |