Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spec for Warning[category] = true|false to emit/suppress warnings #806

Merged
merged 1 commit into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/warning/element_reference_spec.rb
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
19 changes: 19 additions & 0 deletions core/warning/element_set_spec.rb
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