diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-01-20 17:53:46 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-23 13:37:40 +0900 |
commit | 6298ec2875a6f1a1e75698c96ceac94362f20bcf (patch) | |
tree | 70143b5c6d6df6dfdc7a0ea2707a050fbdc59131 /spec/ruby | |
parent | 588a86e32c9e646823e1436e53ffe1c37206abd3 (diff) | |
download | ruby-6298ec2875a6f1a1e75698c96ceac94362f20bcf.tar.gz |
Warn non-nil `$\` [Feature #14240]
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/core/io/print_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/kernel/p_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/English/English_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/stringio/print_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/library/stringio/puts_spec.rb | 15 | ||||
-rw-r--r-- | spec/ruby/optional/capi/globals_spec.rb | 4 |
6 files changed, 29 insertions, 20 deletions
diff --git a/spec/ruby/core/io/print_spec.rb b/spec/ruby/core/io/print_spec.rb index 2021cd5420..0e8805348e 100644 --- a/spec/ruby/core/io/print_spec.rb +++ b/spec/ruby/core/io/print_spec.rb @@ -4,12 +4,12 @@ require_relative 'fixtures/classes' describe IO, "#print" do before :each do @old_separator = $\ - $\ = '->' + suppress_warning {$\ = '->'} @name = tmp("io_print") end after :each do - $\ = @old_separator + suppress_warning {$\ = @old_separator} rm_r @name end diff --git a/spec/ruby/core/kernel/p_spec.rb b/spec/ruby/core/kernel/p_spec.rb index 798bd47b34..1bdd1740ca 100644 --- a/spec/ruby/core/kernel/p_spec.rb +++ b/spec/ruby/core/kernel/p_spec.rb @@ -57,10 +57,14 @@ describe "Kernel#p" do } -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n") - $\ = " *helicopter sound*\n" + suppress_warning { + $\ = " *helicopter sound*\n" + } -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n") - $/ = " *helicopter sound*\n" + suppress_warning { + $/ = " *helicopter sound*\n" + } -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n") end diff --git a/spec/ruby/library/English/English_spec.rb b/spec/ruby/library/English/English_spec.rb index f6153ec7c9..480602d5e5 100644 --- a/spec/ruby/library/English/English_spec.rb +++ b/spec/ruby/library/English/English_spec.rb @@ -67,18 +67,18 @@ describe "English" do it "aliases $ORS to $\\" do original = $\ - $\ = "\t" + suppress_warning {$\ = "\t"} $ORS.should_not be_nil $ORS.should == $\ - $\ = original + suppress_warning {$\ = original} end it "aliases $OUTPUT_RECORD_SEPARATOR to $\\" do original = $\ - $\ = "\t" + suppress_warning {$\ = "\t"} $OUTPUT_RECORD_SEPARATOR.should_not be_nil $OUTPUT_RECORD_SEPARATOR.should == $\ - $\ = original + suppress_warning {$\ = original} end it "aliases $INPUT_LINE_NUMBER to $." do diff --git a/spec/ruby/library/stringio/print_spec.rb b/spec/ruby/library/stringio/print_spec.rb index d0f07d1e50..6ac6430900 100644 --- a/spec/ruby/library/stringio/print_spec.rb +++ b/spec/ruby/library/stringio/print_spec.rb @@ -39,13 +39,14 @@ describe "StringIO#print" do end it "honors the output record separator global" do - old_rs, $\ = $\, 'x' + old_rs = $\ + suppress_warning {$\ = 'x'} begin @io.print(5, 6, 7, 8) @io.string.should == '5678xle' ensure - $\ = old_rs + suppress_warning {$\ = old_rs} end end @@ -58,13 +59,14 @@ describe "StringIO#print" do end it "correctly updates the current position when honoring the output record separator global" do - old_rs, $\ = $\, 'x' + old_rs = $\ + suppress_warning {$\ = 'x'} begin @io.print(5, 6, 7, 8) @io.pos.should eql(5) ensure - $\ = old_rs + suppress_warning {$\ = old_rs} end end end diff --git a/spec/ruby/library/stringio/puts_spec.rb b/spec/ruby/library/stringio/puts_spec.rb index 2d3db25c5f..a9f289a5a5 100644 --- a/spec/ruby/library/stringio/puts_spec.rb +++ b/spec/ruby/library/stringio/puts_spec.rb @@ -30,11 +30,12 @@ describe "StringIO#puts when passed an Array" do it "does not honor the global output record separator $\\" do begin - old_rs, $\ = $\, "test" + old_rs = $\ + suppress_warning {$\ = "test"} @io.puts([1, 2, 3, 4]) @io.string.should == "1\n2\n3\n4\n" ensure - $\ = old_rs + suppress_warning {$\ = old_rs} end end @@ -68,11 +69,12 @@ describe "StringIO#puts when passed 1 or more objects" do it "does not honor the global output record separator $\\" do begin - old_rs, $\ = $\, "test" + old_rs = $\ + suppress_warning {$\ = "test"} @io.puts(1, 2, 3, 4) @io.string.should == "1\n2\n3\n4\n" ensure - $\ = old_rs + suppress_warning {$\ = old_rs} end end @@ -117,11 +119,12 @@ describe "StringIO#puts when passed no arguments" do it "does not honor the global output record separator $\\" do begin - old_rs, $\ = $\, "test" + old_rs = $\ + suppress_warning {$\ = "test"} @io.puts @io.string.should == "\n" ensure - $\ = old_rs + suppress_warning {$\ = old_rs} end end end diff --git a/spec/ruby/optional/capi/globals_spec.rb b/spec/ruby/optional/capi/globals_spec.rb index 84694b1375..ffc579023d 100644 --- a/spec/ruby/optional/capi/globals_spec.rb +++ b/spec/ruby/optional/capi/globals_spec.rb @@ -140,7 +140,7 @@ describe "CApiGlobalSpecs" do end after :each do - $\ = @dollar_backslash + suppress_warning {$\ = @dollar_backslash} end it "returns nil by default" do @@ -148,7 +148,7 @@ describe "CApiGlobalSpecs" do end it "returns the value of $\\" do - $\ = "foo" + suppress_warning {$\ = "foo"} @f.rb_output_rs.should == "foo" end end |