summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-31 14:58:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-25 09:50:33 +0900
commit996af2ce086249e904b2ce95ab2fcd1de7d757be (patch)
tree1b70f747a0eefc32be13f05bdb037275d1e664a1 /test
parent83ff0f74bf69650754cac020bcd4ff9adbba877e (diff)
Disable deprecation warning by the default [Feature #16345]
And `-w` option turns it on.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3481
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_argf.rb4
-rw-r--r--test/ruby/test_enumerator.rb1
-rw-r--r--test/ruby/test_io.rb77
-rw-r--r--test/ruby/test_lambda.rb6
-rw-r--r--test/ruby/test_module.rb40
-rw-r--r--test/ruby/test_object.rb9
-rw-r--r--test/ruby/test_rubyoptions.rb7
-rw-r--r--test/ruby/test_string.rb7
8 files changed, 31 insertions, 120 deletions
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index 4734d5b3ae..e558f7648d 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -1006,7 +1006,6 @@ class TestArgf < Test::Unit::TestCase
ARGF.lines {|l| s << l }
p s
};
- assert_match(/deprecated/, f.gets)
assert_equal("[\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\"]\n", f.read)
end
end
@@ -1017,7 +1016,6 @@ class TestArgf < Test::Unit::TestCase
$stderr = $stdout
print Marshal.dump(ARGF.bytes.to_a)
};
- assert_match(/deprecated/, f.gets)
assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
end
end
@@ -1028,7 +1026,6 @@ class TestArgf < Test::Unit::TestCase
$stderr = $stdout
print [Marshal.dump(ARGF.chars.to_a)].pack('m')
};
- assert_match(/deprecated/, f.gets)
assert_equal(["1", "\n", "2", "\n", "3", "\n", "4", "\n", "5", "\n", "6", "\n"], Marshal.load(f.read.unpack('m').first))
end
end
@@ -1039,7 +1036,6 @@ class TestArgf < Test::Unit::TestCase
$stderr = $stdout
print Marshal.dump(ARGF.codepoints.to_a)
};
- assert_match(/deprecated/, f.gets)
assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
end
end
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index 75cf1aeec6..b619150571 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -72,7 +72,6 @@ class TestEnumerator < Test::Unit::TestCase
_, err = capture_io do
assert_equal([1, 2, 3], Enumerator.new(@obj, :foo, 1, 2, 3).to_a)
end
- assert_match 'Enumerator.new without a block is deprecated', err
assert_equal([1, 2, 3], Enumerator.new { |y| i = 0; loop { y << (i += 1) } }.take(3))
assert_raise(ArgumentError) { Enumerator.new }
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index fafb082154..7b1ddce78b 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -418,19 +418,6 @@ class TestIO < Test::Unit::TestCase
}
end
- def test_codepoints
- make_tempfile {|t|
- bug2959 = '[ruby-core:28650]'
- a = ""
- File.open(t, 'rt') {|f|
- assert_warn(/deprecated/) {
- f.codepoints {|c| a << c}
- }
- }
- assert_equal("foo\nbar\nbaz\n", a, bug2959)
- }
- end
-
def test_rubydev33072
t = make_tempfile
path = t.path
@@ -1835,70 +1822,6 @@ class TestIO < Test::Unit::TestCase
end)
end
- def test_lines
- verbose, $VERBOSE = $VERBOSE, nil
- pipe(proc do |w|
- w.puts "foo"
- w.puts "bar"
- w.puts "baz"
- w.close
- end, proc do |r|
- e = nil
- assert_warn(/deprecated/) {
- e = r.lines
- }
- assert_equal("foo\n", e.next)
- assert_equal("bar\n", e.next)
- assert_equal("baz\n", e.next)
- assert_raise(StopIteration) { e.next }
- end)
- ensure
- $VERBOSE = verbose
- end
-
- def test_bytes
- verbose, $VERBOSE = $VERBOSE, nil
- pipe(proc do |w|
- w.binmode
- w.puts "foo"
- w.puts "bar"
- w.puts "baz"
- w.close
- end, proc do |r|
- e = nil
- assert_warn(/deprecated/) {
- e = r.bytes
- }
- (%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
- assert_equal(c.ord, e.next)
- end
- assert_raise(StopIteration) { e.next }
- end)
- ensure
- $VERBOSE = verbose
- end
-
- def test_chars
- verbose, $VERBOSE = $VERBOSE, nil
- pipe(proc do |w|
- w.puts "foo"
- w.puts "bar"
- w.puts "baz"
- w.close
- end, proc do |r|
- e = nil
- assert_warn(/deprecated/) {
- e = r.chars
- }
- (%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
- assert_equal(c, e.next)
- end
- assert_raise(StopIteration) { e.next }
- end)
- ensure
- $VERBOSE = verbose
- end
-
def test_readbyte
pipe(proc do |w|
w.binmode
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index 75362e2796..03b501a6c9 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -74,12 +74,6 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_raise(ArgumentError, bug9605) {proc(&plus).call [1,2]}
end
- def test_warning_for_non_literal_blocks
- assert_warn(/lambda without a literal block/, '[ruby-core:93482] [Feature #15973]') do
- lambda(&:symbol)
- end
- end
-
def pass_along(&block)
lambda(&block)
end
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 94e415b08c..3003a743d1 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1755,23 +1755,31 @@ class TestModule < Test::Unit::TestCase
c = Class.new
c.const_set(:FOO, "foo")
c.deprecate_constant(:FOO)
- assert_warn(/deprecated/) {c::FOO}
- assert_warn(/#{c}::FOO is deprecated/) {Class.new(c)::FOO}
+ assert_warn(/deprecated/) do
+ Warning[:deprecated] = true
+ c::FOO
+ end
+ assert_warn(/#{c}::FOO is deprecated/) do
+ Warning[:deprecated] = true
+ Class.new(c)::FOO
+ end
bug12382 = '[ruby-core:75505] [Bug #12382]'
- assert_warn(/deprecated/, bug12382) {c.class_eval "FOO"}
- Warning[:deprecated] = false
- assert_warn('') {c::FOO}
- end
-
- NIL = nil
- FALSE = false
- deprecate_constant(:NIL, :FALSE)
-
- def test_deprecate_nil_constant
- w = EnvUtil.verbose_warning {2.times {FALSE}}
- assert_equal(1, w.scan("::FALSE").size, w)
- w = EnvUtil.verbose_warning {2.times {NIL}}
- assert_equal(1, w.scan("::NIL").size, w)
+ assert_warn(/deprecated/, bug12382) do
+ Warning[:deprecated] = true
+ c.class_eval "FOO"
+ end
+ assert_warn('') do
+ Warning[:deprecated] = false
+ c::FOO
+ end
+ assert_warn('') do
+ Warning[:deprecated] = false
+ Class.new(c)::FOO
+ end
+ assert_warn('') do
+ Warning[:deprecated] = false
+ c.class_eval "FOO"
+ end
end
def test_constants_with_private_constant
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 3aa0a1b652..782ae6ac72 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -990,13 +990,4 @@ class TestObject < Test::Unit::TestCase
end
EOS
end
-
- def test_matcher
- assert_warning(/deprecated Object#=~ is called on Object/) do
- assert_equal(Object.new =~ 42, nil)
- end
- assert_warning(/deprecated Object#=~ is called on Array/) do
- assert_equal([] =~ 42, nil)
- end
- end
end
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 7101175568..6ca8dbea33 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -80,6 +80,9 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%w(-W:experimental -e) + ['p Warning[:experimental]'], "", %w(true), [])
assert_in_out_err(%w(-W:no-experimental -e) + ['p Warning[:experimental]'], "", %w(false), [])
assert_in_out_err(%w(-W:qux), "", [], /unknown warning category: `qux'/)
+ assert_in_out_err(%w(-w -e) + ['p Warning[:deprecated]'], "", %w(true), [])
+ assert_in_out_err(%w(-W -e) + ['p Warning[:deprecated]'], "", %w(true), [])
+ assert_in_out_err(%w(-e) + ['p Warning[:deprecated]'], "", %w(false), [])
ensure
ENV['RUBYOPT'] = save_rubyopt
end
@@ -333,6 +336,10 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%w(), "p $VERBOSE", ["true"])
assert_in_out_err(%w(-W1), "p $VERBOSE", ["false"])
assert_in_out_err(%w(-W0), "p $VERBOSE", ["nil"])
+ assert_in_out_err(%w(), "p Warning[:deprecated]", ["true"])
+ assert_in_out_err(%w(-W0), "p Warning[:deprecated]", ["false"])
+ assert_in_out_err(%w(-W1), "p Warning[:deprecated]", ["false"])
+ assert_in_out_err(%w(-W2), "p Warning[:deprecated]", ["true"])
ENV['RUBYOPT'] = '-W:deprecated'
assert_in_out_err(%w(), "p Warning[:deprecated]", ["true"])
ENV['RUBYOPT'] = '-W:no-deprecated'
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index fde1c9cdc5..810c700c8c 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1764,13 +1764,6 @@ CODE
GC.start
assert_equal([], "".split, bug)
end;
-
- begin
- fs = $;
- assert_warn(/`\$;' is deprecated/) {$; = " "}
- ensure
- EnvUtil.suppress_warning {$; = fs}
- end
end
def test_split_encoding