aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2020-09-29 22:43:25 +0900
committernagachika <nagachika@ruby-lang.org>2020-09-29 22:43:25 +0900
commitdf3f52a6331f1a47af9933b77311a8650727d8d1 (patch)
treedd16cd215d11caf4907614d0bc6a9b2b08d96930 /test
parent665589cbdf7bf652067113dd1c0bc49012b990e0 (diff)
downloadruby-df3f52a6331f1a47af9933b77311a8650727d8d1.tar.gz
merge revision(s) 996af2ce086249e904b2ce95ab2fcd1de7d757be: [Backport #16345] [Backport #17000]
Disable deprecation warning by the default [Feature #16345] And `-w` option turns it on.
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_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
7 files changed, 31 insertions, 114 deletions
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index 277fa368f5..5c2356524f 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -991,7 +991,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
@@ -1002,7 +1001,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
@@ -1013,7 +1011,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
@@ -1024,7 +1021,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 c66446d2e8..306f0bcce0 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -405,19 +405,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
@@ -1822,70 +1809,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_module.rb b/test/ruby/test_module.rb
index 2e7e5804d0..69f03ae772 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1579,23 +1579,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 add5b9fb15..442a7551a0 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -954,13 +954,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 093720b1fc..fba53cd982 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 09d099bb4a..746471553d 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1768,13 +1768,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