diff options
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 |
