summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2024-03-24 08:39:27 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2024-04-02 08:26:58 +0900
commit799e854897856e431c03a5122252358e2c57aff2 (patch)
tree4918d58d1bdcdb229c2419d381743007b62e1d2d /test/ruby
parent8066e3ea6e9462f510e5d0da887be94b18cce50b (diff)
[Feature #20331] Simplify parser warnings for hash keys duplication and when clause duplication
This commit simplifies warnings for hash keys duplication and when clause duplication, based on the discussion of https://bugs.ruby-lang.org/issues/20331. Warnings are reported only when strings are same to ohters.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_literal.rb3
-rw-r--r--test/ruby/test_syntax.rb4
2 files changed, 2 insertions, 5 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 61e1e096df..c6154af1f6 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -509,9 +509,6 @@ class TestRubyLiteral < Test::Unit::TestCase
) do |key|
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
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 371c41fe37..7cc5e542a7 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -734,7 +734,7 @@ WARN
end
}
}
- assert_warning(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m) {
+ assert_warning(/3: #{w}/m) {
eval %q{
case 1
when __LINE__, __LINE__
@@ -743,7 +743,7 @@ WARN
end
}
}
- assert_warning(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m) {
+ assert_warning(/3: #{w}/m) {
eval %q{
case 1
when __FILE__, __FILE__