require File.expand_path("../../helpers", __FILE__) class TestParserGroups < Test::Unit::TestCase def test_parse_root_options_mi t = RP.parse((/[abc]/mi).to_s, 'ruby/1.8') assert_equal( true, t.m? ) assert_equal( true, t.i? ) assert_equal( false, t.x? ) end def test_parse_nested_options_m t = RP.parse('(?xi-m:a(?m-ix:b))', 'ruby/1.8') assert_equal( true, t.expressions[0].expressions[1].m? ) assert_equal( false, t.expressions[0].expressions[1].i? ) assert_equal( false, t.expressions[0].expressions[1].x? ) end def test_parse_nested_options_xm t = RP.parse(/(?i-xm:a(?mx-i:b))/, 'ruby/1.8') assert_equal( true, t.expressions[0].expressions[1].m? ) assert_equal( false, t.expressions[0].expressions[1].i? ) assert_equal( true, t.expressions[0].expressions[1].x? ) end def test_parse_nested_options_im t = RP.parse(/(?x-mi:a(?mi-x:b))/, 'ruby/1.8') assert_equal( true, t.expressions[0].expressions[1].m? ) assert_equal( true, t.expressions[0].expressions[1].i? ) assert_equal( false, t.expressions[0].expressions[1].x? ) end def test_parse_lookahead t = RP.parse('(?=abc)(?!def)', 'ruby/1.8') assert( t.expressions[0].is_a?(Assertion::Lookahead), "Expected lookahead, but got #{t.expressions[0].class.name}") assert( t.expressions[1].is_a?(Assertion::NegativeLookahead), "Expected negative lookahead, but got #{t.expressions[0].class.name}") end def test_parse_lookbehind t = RP.parse('(?<=abc)(?