summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-12-05 00:27:45 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2025-12-05 00:27:45 +0900
commitcf12aff0593a0aa70d957b96f03df8288c025938 (patch)
treec46cfc4b04ec03fe6d603d745cca29a4cfba7fc7 /spec
parent465a86c3417d2936c311d9571aa9b6494a83eed8 (diff)
[Bug #21764] Propagate the encoding of ID to warning
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/language/predefined_spec.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb
index f2488615aa..fc1667a38f 100644
--- a/spec/ruby/language/predefined_spec.rb
+++ b/spec/ruby/language/predefined_spec.rb
@@ -748,6 +748,10 @@ describe "Predefined global $/" do
it "raises a TypeError if assigned a boolean" do
-> { $/ = true }.should raise_error(TypeError, 'value of $/ must be String')
end
+
+ it "warns if assigned non-nil" do
+ -> { $/ = "_" }.should complain(/warning: (?:non-nil )?[`']\$\/' is deprecated/)
+ end
end
describe "Predefined global $-0" do
@@ -825,6 +829,10 @@ describe "Predefined global $-0" do
it "raises a TypeError if assigned a boolean" do
-> { $-0 = true }.should raise_error(TypeError, 'value of $-0 must be String')
end
+
+ it "warns if assigned non-nil" do
+ -> { $-0 = "_" }.should complain(/warning: (?:non-nil )?[`']\$-0' is deprecated/)
+ end
end
describe "Predefined global $\\" do
@@ -864,6 +872,10 @@ describe "Predefined global $\\" do
-> { $\ = 1 }.should raise_error(TypeError, 'value of $\ must be String')
-> { $\ = true }.should raise_error(TypeError, 'value of $\ must be String')
end
+
+ it "warns if assigned non-nil" do
+ -> { $\ = "_" }.should complain(/warning: (?:non-nil )?[`']\$\\' is deprecated/)
+ end
end
describe "Predefined global $," do
@@ -880,7 +892,7 @@ describe "Predefined global $," do
end
it "warns if assigned non-nil" do
- -> { $, = "_" }.should complain(/warning: [`']\$,' is deprecated/)
+ -> { $, = "_" }.should complain(/warning: (?:non-nil )?[`']\$,' is deprecated/)
end
end
@@ -917,7 +929,7 @@ describe "Predefined global $;" do
end
it "warns if assigned non-nil" do
- -> { $; = "_" }.should complain(/warning: [`']\$;' is deprecated/)
+ -> { $; = "_" }.should complain(/warning: (?:non-nil )?[`']\$;' is deprecated/)
end
end