aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-21 08:37:44 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-23 13:37:40 +0900
commit8a7e0aaaef3b19f90d6debe6781e4b3031f56237 (patch)
treee4c6fb0dd79b1d856cd8a200f550170114bbf30a /test
parent6298ec2875a6f1a1e75698c96ceac94362f20bcf (diff)
downloadruby-8a7e0aaaef3b19f90d6debe6781e4b3031f56237.tar.gz
Warn non-nil `$/` [Feature #14240]
Diffstat (limited to 'test')
-rw-r--r--test/openssl/test_pair.rb4
-rw-r--r--test/ruby/test_string.rb14
2 files changed, 16 insertions, 2 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
index e9cf98df15..a77abfd923 100644
--- a/test/openssl/test_pair.rb
+++ b/test/openssl/test_pair.rb
@@ -160,10 +160,10 @@ module OpenSSL::TestPairM
ssl_pair {|s1, s2|
begin
old = $/
- $/ = '*'
+ EnvUtil.suppress_warning {$/ = '*'}
s1.puts 'a'
ensure
- $/ = old
+ EnvUtil.suppress_warning {$/ = old}
end
s1.close
assert_equal("a\n", s2.read)
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index f0b765314c..5274097626 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -387,6 +387,8 @@ CODE
end
def test_chomp
+ verbose, $VERBOSE = $VERBOSE, nil
+
assert_equal(S("hello"), S("hello").chomp("\n"))
assert_equal(S("hello"), S("hello\n").chomp("\n"))
save = $/
@@ -452,9 +454,12 @@ CODE
assert_equal("foo", s.chomp("\n"))
ensure
$/ = save
+ $VERBOSE = verbose
end
def test_chomp!
+ verbose, $VERBOSE = $VERBOSE, nil
+
a = S("hello")
a.chomp!(S("\n"))
@@ -511,6 +516,7 @@ CODE
s = S("").freeze
assert_raise_with_message(FrozenError, /frozen/) {s.chomp!}
+ $VERBOSE = nil # EnvUtil.suppress_warning resets $VERBOSE to the original state
s = S("ax")
o = Struct.new(:s).new(s)
@@ -519,6 +525,7 @@ CODE
"x"
end
assert_raise_with_message(FrozenError, /frozen/) {s.chomp!(o)}
+ $VERBOSE = nil # EnvUtil.suppress_warning resets $VERBOSE to the original state
s = S("hello")
assert_equal("hel", s.chomp!('lo'))
@@ -569,6 +576,7 @@ CODE
assert_equal("foo", s.chomp!("\n"))
ensure
$/ = save
+ $VERBOSE = verbose
end
def test_chop
@@ -859,6 +867,8 @@ CODE
end
def test_each
+ verbose, $VERBOSE = $VERBOSE, nil
+
save = $/
$/ = "\n"
res=[]
@@ -878,6 +888,7 @@ CODE
assert_equal(S("world"), res[1])
ensure
$/ = save
+ $VERBOSE = verbose
end
def test_each_byte
@@ -1055,6 +1066,8 @@ CODE
end
def test_each_line
+ verbose, $VERBOSE = $VERBOSE, nil
+
save = $/
$/ = "\n"
res=[]
@@ -1101,6 +1114,7 @@ CODE
end
ensure
$/ = save
+ $VERBOSE = verbose
end
def test_each_line_chomp