summaryrefslogtreecommitdiff
path: root/spec/ruby/command_line
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/command_line')
-rw-r--r--spec/ruby/command_line/backtrace_limit_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_upper_w_spec.rb33
-rw-r--r--spec/ruby/command_line/dash_w_spec.rb6
-rw-r--r--spec/ruby/command_line/fixtures/backtrace.rb2
4 files changed, 23 insertions, 22 deletions
diff --git a/spec/ruby/command_line/backtrace_limit_spec.rb b/spec/ruby/command_line/backtrace_limit_spec.rb
index c0b243841e..56afa8efef 100644
--- a/spec/ruby/command_line/backtrace_limit_spec.rb
+++ b/spec/ruby/command_line/backtrace_limit_spec.rb
@@ -9,7 +9,7 @@ ruby_version_is "3.0" do
out.should == <<-MSG
top
-/fixtures/backtrace.rb:2:in `a': unhandled exception
+/fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
\tfrom /fixtures/backtrace.rb:6:in `b'
\tfrom /fixtures/backtrace.rb:10:in `c'
\t ... 2 levels...
@@ -23,7 +23,7 @@ top
out.should == <<-MSG
full_message
-/fixtures/backtrace.rb:2:in `a': unhandled exception
+/fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
\tfrom /fixtures/backtrace.rb:6:in `b'
\tfrom /fixtures/backtrace.rb:10:in `c'
\t ... 2 levels...
diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb
index 1b36a1cc22..cbb040a8dd 100644
--- a/spec/ruby/command_line/dash_upper_w_spec.rb
+++ b/spec/ruby/command_line/dash_upper_w_spec.rb
@@ -19,34 +19,29 @@ describe "The -W command line option with 2" do
it_behaves_like :command_line_verbose, "-W2"
end
+# Regarding the defaults, see core/warning/element_reference_spec.rb
ruby_version_is "2.7" do
+ describe "The -W command line option with :deprecated" do
+ it "enables deprecation warnings" do
+ ruby_exe('p Warning[:deprecated]', options: '-W:deprecated').should == "true\n"
+ end
+ end
+
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 == ""
+ ruby_exe('p Warning[:deprecated]', options: '-w -W:no-deprecated').should == "false\n"
end
end
- describe "The -W command line option with :no-experimental" do
- before do
- ruby_version_is ""..."3.0" do
- @src = 'case [0, 1]; in [a, b]; end'
- end
-
- ruby_version_is "3.0" do
- @src = 'warn "This is experimental warning.", category: :experimental'
- end
+ describe "The -W command line option with :experimental" do
+ it "enables experimental warnings" do
+ ruby_exe('p Warning[:experimental]', options: '-W:experimental').should == "true\n"
end
+ end
+ describe "The -W command line option with :no-experimental" do
it "suppresses experimental warnings" do
- result = ruby_exe(@src, args: '2>&1')
- result.should =~ /is experimental/
-
- result = ruby_exe(@src, options: '-W:no-experimental', args: '2>&1')
- result.should == ""
+ ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n"
end
end
end
diff --git a/spec/ruby/command_line/dash_w_spec.rb b/spec/ruby/command_line/dash_w_spec.rb
index 1d93e0347b..c262df12cc 100644
--- a/spec/ruby/command_line/dash_w_spec.rb
+++ b/spec/ruby/command_line/dash_w_spec.rb
@@ -3,4 +3,10 @@ require_relative 'shared/verbose'
describe "The -w command line option" do
it_behaves_like :command_line_verbose, "-w"
+
+ ruby_version_is "2.7" do
+ it "enables both deprecated and experimental warnings" do
+ ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n"
+ end
+ end
end
diff --git a/spec/ruby/command_line/fixtures/backtrace.rb b/spec/ruby/command_line/fixtures/backtrace.rb
index 19ad638d35..99acae95c8 100644
--- a/spec/ruby/command_line/fixtures/backtrace.rb
+++ b/spec/ruby/command_line/fixtures/backtrace.rb
@@ -1,5 +1,5 @@
def a
- raise
+ raise 'oops'
end
def b