diff options
author | Tim Morgan <tim@timmorgan.org> | 2023-09-11 06:13:48 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-09-11 15:25:05 +0000 |
commit | 689dffc8576215239ae3c38633b3f2257208fc70 (patch) | |
tree | d6dcb433bc6bb8c4c06027cf05a03d09c8195361 /test | |
parent | b1f0d009cbdf1990813c09165d372be29485f8ae (diff) |
[ruby/yarp] Add failing test for Regexp flags
https://github.com/ruby/yarp/commit/16fe179c5f
Diffstat (limited to 'test')
-rw-r--r-- | test/yarp/regexp_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/yarp/regexp_test.rb b/test/yarp/regexp_test.rb index 9863a54758..2fcc7d13f3 100644 --- a/test/yarp/regexp_test.rb +++ b/test/yarp/regexp_test.rb @@ -192,10 +192,35 @@ module YARP refute_nil(named_captures("foo{1, 2}")) end + ############################################################################## + # These test that flag values are correct. + ############################################################################## + + def test_flag_ignorecase + assert_equal(Regexp::IGNORECASE, flags("i")) + end + + def test_flag_extended + assert_equal(Regexp::EXTENDED, flags("x")) + end + + def test_flag_multiline + assert_equal(Regexp::MULTILINE, flags("m")) + end + + def test_flag_combined + value = Regexp::IGNORECASE | Regexp::MULTILINE | Regexp::EXTENDED + assert_equal(value, flags("mix")) + end + private def named_captures(source) Debug.named_captures(source) end + + def flags(str) + YARP.parse("/foo/#{str}").value.child_nodes.first.child_nodes.first.flags + end end end |