summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-18 21:56:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-18 21:56:55 +0000
commit3ee0648dc7a5465b2cbadd7246fc2edbd676d759 (patch)
tree02b758f59e65fa4ea9b6861956807ba49be638d4 /spec
parent4751caecc357c313c3c81c3d422a3cbc880c6ecc (diff)
io.c: warn non-nil $,
* array.c (rb_ary_join_m): warn use of non-nil $,. * io.c (rb_output_fs_setter): warn when set to non-nil value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/array/join_spec.rb8
-rw-r--r--spec/ruby/core/array/shared/join.rb6
-rw-r--r--spec/ruby/core/kernel/p_spec.rb8
-rw-r--r--spec/ruby/library/English/English_spec.rb8
-rw-r--r--spec/ruby/optional/capi/globals_spec.rb4
5 files changed, 21 insertions, 13 deletions
diff --git a/spec/ruby/core/array/join_spec.rb b/spec/ruby/core/array/join_spec.rb
index 16f0dcee7a..403bae7183 100644
--- a/spec/ruby/core/array/join_spec.rb
+++ b/spec/ruby/core/array/join_spec.rb
@@ -38,11 +38,13 @@ describe "Array#join with $," do
end
after :each do
- $, = @before_separator
+ suppress_warning {$, = @before_separator}
end
it "separates elements with default separator when the passed separator is nil" do
- $, = "_"
- [1, 2, 3].join(nil).should == '1_2_3'
+ suppress_warning {
+ $, = "_"
+ [1, 2, 3].join(nil).should == '1_2_3'
+ }
end
end
diff --git a/spec/ruby/core/array/shared/join.rb b/spec/ruby/core/array/shared/join.rb
index 0fd2e0ff9b..28b3d8c04c 100644
--- a/spec/ruby/core/array/shared/join.rb
+++ b/spec/ruby/core/array/shared/join.rb
@@ -19,8 +19,10 @@ describe :array_join_with_default_separator, shared: true do
end
it "returns a string formed by concatenating each String element separated by $," do
- $, = " | "
- ["1", "2", "3"].send(@method).should == "1 | 2 | 3"
+ suppress_warning {
+ $, = " | "
+ ["1", "2", "3"].send(@method).should == "1 | 2 | 3"
+ }
end
it "attempts coercion via #to_str first" do
diff --git a/spec/ruby/core/kernel/p_spec.rb b/spec/ruby/core/kernel/p_spec.rb
index c95055cf35..1221465243 100644
--- a/spec/ruby/core/kernel/p_spec.rb
+++ b/spec/ruby/core/kernel/p_spec.rb
@@ -7,7 +7,9 @@ describe "Kernel#p" do
end
after :each do
- $/, $\, $, = @rs_f, @rs_b, @rs_c
+ suppress_warning {
+ $/, $\, $, = @rs_f, @rs_b, @rs_c
+ }
end
it "is a private method" do
@@ -50,7 +52,9 @@ describe "Kernel#p" do
o = mock("Inspector Gadget")
o.should_receive(:inspect).any_number_of_times.and_return "Next time, Gadget, NEXT TIME!"
- $, = " *helicopter sound*\n"
+ suppress_warning {
+ $, = " *helicopter sound*\n"
+ }
lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
$\ = " *helicopter sound*\n"
diff --git a/spec/ruby/library/English/English_spec.rb b/spec/ruby/library/English/English_spec.rb
index 45ce7ab322..f6153ec7c9 100644
--- a/spec/ruby/library/English/English_spec.rb
+++ b/spec/ruby/library/English/English_spec.rb
@@ -41,18 +41,18 @@ describe "English" do
it "aliases $OFS to $," do
original = $,
- $, = "|"
+ suppress_warning {$, = "|"}
$OFS.should_not be_nil
$OFS.should == $,
- $, = original
+ suppress_warning {$, = original}
end
it "aliases $OUTPUT_FIELD_SEPARATOR to $," do
original = $,
- $, = "|"
+ suppress_warning {$, = "|"}
$OUTPUT_FIELD_SEPARATOR.should_not be_nil
$OUTPUT_FIELD_SEPARATOR.should == $,
- $, = original
+ suppress_warning {$, = original}
end
it "aliases $RS to $/" do
diff --git a/spec/ruby/optional/capi/globals_spec.rb b/spec/ruby/optional/capi/globals_spec.rb
index 068b372230..0bded557ba 100644
--- a/spec/ruby/optional/capi/globals_spec.rb
+++ b/spec/ruby/optional/capi/globals_spec.rb
@@ -159,7 +159,7 @@ describe "CApiGlobalSpecs" do
end
after :each do
- $, = @dollar_comma
+ suppress_warning {$, = @dollar_comma}
end
it "returns nil by default" do
@@ -167,7 +167,7 @@ describe "CApiGlobalSpecs" do
end
it "returns the value of $\\" do
- $, = "foo"
+ suppress_warning {$, = "foo"}
@f.rb_output_fs.should == "foo"
end
end