summaryrefslogtreecommitdiff
path: root/test/ruby/test_rubyoptions.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-12-12 15:59:25 +0900
committerNobuyoshi Nakada <[email protected]>2024-12-12 17:45:06 +0900
commit4d86f3bf6d1fe7bf7d4b25fc42f7aba9f401bbb4 (patch)
tree8f16cb2a1eefc672f77a115b0abf8324e9dac5da /test/ruby/test_rubyoptions.rb
parent267ecf5f02bf0bdb183be06f17b7d2fdc8d1a3ad (diff)
[Feature #20884] Reserve "Ruby" toplevel name
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12315
Diffstat (limited to 'test/ruby/test_rubyoptions.rb')
-rw-r--r--test/ruby/test_rubyoptions.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index f61466c035..ac4b5870eb 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -1326,4 +1326,19 @@ class TestRubyOptions < Test::Unit::TestCase
assert_ruby_status([env, "-e;"])
assert_in_out_err([env, "-W"], "", [], /Free at exit is experimental and may be unstable/)
end
+
+ def test_toplevel_ruby
+ reserved = ["", [], /::Ruby is reserved/]
+ env = {"RUBYOPT"=>""}
+ args = %w[-e Ruby=1]
+ assert_in_out_err([env, *args])
+ assert_in_out_err([env, "-w", *args], *reserved)
+ assert_in_out_err([env, "-W:deprecated", *args], *reserved)
+ assert_in_out_err([env, "-w", "-W:no-deprecated", *args])
+
+ args = ["-e", "class A; Ruby=1; end"]
+ assert_in_out_err([env, *args])
+ assert_in_out_err([env, "-w", *args])
+ assert_in_out_err([env, "-W:deprecated", *args])
+ end
end