# $Id: tc_regexp.rb,v 1.8 2003/04/22 06:13:48 knu Exp $

require 'test/unit'
begin
  require 'features/ruby18/regexp'
rescue LoadError; end

class TC_Regexp < Test::Unit::TestCase
  def test_eql?
    assert(/a/.eql?(/a/))
  end

  def test_hash
    assert_equal(/a/.hash, /a/.hash)
  end

  def test_options
    re = /a/

    assert_equal(0,
		 re.options & (Regexp::IGNORECASE |
			       Regexp::EXTENDED |
			       Regexp::MULTILINE))

    re = /a/i

    assert_equal(Regexp::IGNORECASE,
		 re.options & (Regexp::IGNORECASE |
			       Regexp::EXTENDED |
			       Regexp::MULTILINE))

    re = /a/mix

    assert_equal(Regexp::IGNORECASE |
		 Regexp::EXTENDED |
		 Regexp::MULTILINE,
		 re.options & (Regexp::IGNORECASE |
			       Regexp::EXTENDED |
			       Regexp::MULTILINE))
  end

=begin
  def test_to_s
    re = /(a|b)*/

    assert_equal("(?-mix:(a|b)*)", re.to_s)

    re = /(a|b)*/i

    assert_equal("(?i-mx:(a|b)*)", re.to_s)

    re = /(a|b)*/mix

    assert_equal("(?mix:(a|b)*)", re.to_s)
  end
=end
end

class TC_MatchData < Test::Unit::TestCase
  def test_select
    m = /(.)(..)(...)(..)(.)/.match('abcdefghi')

    assert_equal(['a', 'def', 'i'], m.select(1, 3, 5))
  end
end
