diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-01-21 08:37:44 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-23 13:37:40 +0900 |
commit | 8a7e0aaaef3b19f90d6debe6781e4b3031f56237 (patch) | |
tree | e4c6fb0dd79b1d856cd8a200f550170114bbf30a /spec/ruby/core/io | |
parent | 6298ec2875a6f1a1e75698c96ceac94362f20bcf (diff) |
Warn non-nil `$/` [Feature #14240]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2920
Diffstat (limited to 'spec/ruby/core/io')
-rw-r--r-- | spec/ruby/core/io/puts_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/io/readlines_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/each.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/readlines.rb | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/spec/ruby/core/io/puts_spec.rb b/spec/ruby/core/io/puts_spec.rb index 3e4b877b7f..be220c4035 100644 --- a/spec/ruby/core/io/puts_spec.rb +++ b/spec/ruby/core/io/puts_spec.rb @@ -16,7 +16,7 @@ describe "IO#puts" do ScratchPad.clear @io.close if @io rm_r @name - $/ = @before_separator + suppress_warning {$/ = @before_separator} end it "writes just a newline when given no args" do @@ -105,7 +105,7 @@ describe "IO#puts" do end it "ignores the $/ separator global" do - $/ = ":" + suppress_warning {$/ = ":"} @io.puts(5).should == nil ScratchPad.recorded.should == "5\n" end diff --git a/spec/ruby/core/io/readlines_spec.rb b/spec/ruby/core/io/readlines_spec.rb index 0d4f002972..eb99eb8d3a 100644 --- a/spec/ruby/core/io/readlines_spec.rb +++ b/spec/ruby/core/io/readlines_spec.rb @@ -22,11 +22,11 @@ describe "IO#readlines" do describe "when passed no arguments" do before :each do - @sep, $/ = $/, " " + suppress_warning {@sep, $/ = $/, " "} end after :each do - $/ = @sep + suppress_warning {$/ = @sep} end it "returns an Array containing lines based on $/" do @@ -184,7 +184,7 @@ describe "IO.readlines" do after :each do Encoding.default_external = @external Encoding.default_internal = @internal - $/ = @dollar_slash + suppress_warning {$/ = @dollar_slash} end it "encodes lines using the default external encoding" do @@ -196,7 +196,7 @@ describe "IO.readlines" do it "encodes lines using the default internal encoding, when set" do Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_16 - $/ = $/.encode Encoding::UTF_16 + suppress_warning {$/ = $/.encode Encoding::UTF_16} lines = IO.readlines(@name) lines.all? { |s| s.encoding == Encoding::UTF_16 }.should be_true end diff --git a/spec/ruby/core/io/shared/each.rb b/spec/ruby/core/io/shared/each.rb index 0b2dfa3548..91766fbe03 100644 --- a/spec/ruby/core/io/shared/each.rb +++ b/spec/ruby/core/io/shared/each.rb @@ -168,12 +168,12 @@ describe :io_each_default_separator, shared: true do before :each do @io = IOSpecs.io_fixture "lines.txt" ScratchPad.record [] - @sep, $/ = $/, " " + suppress_warning {@sep, $/ = $/, " "} end after :each do @io.close if @io - $/ = @sep + suppress_warning {$/ = @sep} end it "uses $/ as the default line separator" do diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb index de803f42e5..339684a5d4 100644 --- a/spec/ruby/core/io/shared/readlines.rb +++ b/spec/ruby/core/io/shared/readlines.rb @@ -60,11 +60,11 @@ describe :io_readlines_options_19, shared: true do end after :each do - $/ = @sep + suppress_warning {$/ = @sep} end it "defaults to $/ as the separator" do - $/ = " " + suppress_warning {$/ = " "} result = IO.send(@method, @name, 10, &@object) (result ? result : ScratchPad.recorded).should == IOSpecs.lines_space_separator_limit end |