summaryrefslogtreecommitdiff
path: root/spec/ruby/library
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 /spec/ruby/library
parent6298ec2875a6f1a1e75698c96ceac94362f20bcf (diff)
Warn non-nil `$/` [Feature #14240]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2920
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/stringio/gets_spec.rb5
-rw-r--r--spec/ruby/library/stringio/readline_spec.rb5
-rw-r--r--spec/ruby/library/stringio/readlines_spec.rb5
-rw-r--r--spec/ruby/library/stringio/shared/each.rb5
4 files changed, 12 insertions, 8 deletions
diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb
index 69880672a3..97429e6a29 100644
--- a/spec/ruby/library/stringio/gets_spec.rb
+++ b/spec/ruby/library/stringio/gets_spec.rb
@@ -76,12 +76,13 @@ describe "StringIO#gets when passed no argument" do
@io.gets.should == "this is\n"
begin
- old_sep, $/ = $/, " "
+ old_sep = $/
+ suppress_warning {$/ = " "}
@io.gets.should == "an "
@io.gets.should == "example\nfor "
@io.gets.should == "StringIO#gets"
ensure
- $/ = old_sep
+ suppress_warning {$/ = old_sep}
end
end
diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb
index 9af633472e..94b67bc92d 100644
--- a/spec/ruby/library/stringio/readline_spec.rb
+++ b/spec/ruby/library/stringio/readline_spec.rb
@@ -64,12 +64,13 @@ describe "StringIO#readline when passed no argument" do
@io.readline.should == "this is\n"
begin
- old_sep, $/ = $/, " "
+ old_sep = $/
+ suppress_warning {$/ = " "}
@io.readline.should == "an "
@io.readline.should == "example\nfor "
@io.readline.should == "StringIO#readline"
ensure
- $/ = old_sep
+ suppress_warning {$/ = old_sep}
end
end
diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb
index 7f9f9f5846..4b007787e2 100644
--- a/spec/ruby/library/stringio/readlines_spec.rb
+++ b/spec/ruby/library/stringio/readlines_spec.rb
@@ -51,10 +51,11 @@ describe "StringIO#readlines when passed no argument" do
it "returns an Array containing lines based on $/" do
begin
- old_sep, $/ = $/, " "
+ old_sep = $/;
+ suppress_warning {$/ = " "}
@io.readlines.should == ["this ", "is\nan ", "example\nfor ", "StringIO#readlines"]
ensure
- $/ = old_sep
+ suppress_warning {$/ = old_sep}
end
end
diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb
index c08d40344c..14b0a013b3 100644
--- a/spec/ruby/library/stringio/shared/each.rb
+++ b/spec/ruby/library/stringio/shared/each.rb
@@ -71,11 +71,12 @@ describe :stringio_each_no_arguments, shared: true do
it "uses $/ as the default line separator" do
seen = []
begin
- old_rs, $/ = $/, " "
+ old_rs = $/
+ suppress_warning {$/ = " "}
@io.send(@method) {|s| seen << s }
seen.should eql(["a ", "b ", "c ", "d ", "e\n1 ", "2 ", "3 ", "4 ", "5"])
ensure
- $/ = old_rs
+ suppress_warning {$/ = old_rs}
end
end