From ab2a43265cfdda288d1baaa29936fd408c2a42bc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 24 May 2022 16:51:15 +0900 Subject: Warn suspicious flag to `Regexp.new` Now second argument should be `true`, `false`, `nil` or Integer. This flag is confused with third argument some times. --- test/ruby/test_regexp.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 71d56ad027..5ee6b1b03c 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -628,6 +628,12 @@ class TestRegexp < Test::Unit::TestCase assert_raise(RegexpError) { Regexp.new("((?))\\g<0>") } end + def test_initialize_bool_warning + assert_warning(/expected true or false as ignorecase/) do + Regexp.new("foo", :i) + end + end + def test_match_control_meta_escape assert_equal(0, /\c\xFF/ =~ "\c\xFF") assert_equal(0, /\c\M-\xFF/ =~ "\c\M-\xFF") -- cgit v1.2.3