From 515e52a0b1ce61ccaffe9183bcb78dda95a64907 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 7 Apr 2024 10:59:51 +0900 Subject: Emit `warn` event for duplicated hash keys on ripper Need to use `rb_warn` macro instead of calling `rb_compile_warn` directly to emit `warn` event on ripper. --- test/ripper/test_parser_events.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 0bad60b259..cbae6e7ed5 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -1686,6 +1686,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_equal([3], args) end + def test_warn_duplicated_hash_keys + fmt, *args = warn("{ a: 1, a: 2 }") + assert_match(/is duplicated and overwritten on line/, fmt) + assert_equal([:a, 1], args) + end + def test_warn_cr_in_middle fmt = nil assert_warn("") {fmt, = warn("\r;")} -- cgit v1.2.3