summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2024-01-02 14:23:13 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2024-01-07 14:32:10 +0900
commit9d3dcb86d1c95ceb75089595145bbfbc32a5c77c (patch)
tree421e32eaf6a6b1e8f5783939d650012ed3779bdc /test/ruby
parente4a9a73931072458f2bc13b29aeb33efb2eb9ae9 (diff)
Check hash key duplication for `__LINE__` and `__FILE__`
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_literal.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 99dd3a0c56..a736874024 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -496,11 +496,14 @@ class TestRubyLiteral < Test::Unit::TestCase
'1.0i',
'1.72723e-77',
'//',
+ '__LINE__',
+ '__FILE__',
) do |key|
- assert_warning(/key #{Regexp.quote(eval(key).inspect)} is duplicated/) do
- eval("{#{key} => :bar, #{key} => :foo}")
- end
+ assert_warning(/key #{Regexp.quote(eval(key).inspect)} is duplicated/) { eval("{#{key} => :bar, #{key} => :foo}") }
end
+
+ assert_warning(/key 1 is duplicated/) { eval("{__LINE__ => :bar, 1 => :foo}") }
+ assert_warning(/key \"FILENAME\" is duplicated/) { eval("{__FILE__ => :bar, 'FILENAME' => :foo}", binding, "FILENAME") }
end
def test_hash_frozen_key_id