require 'test/unit' require 'rockit/grammar' include Rockit require 'strscan' class UTestStringTerminal < Test::Unit::TestCase def setup @sta = StringTerminal.new("a") @stp = StringTerminal.new("+") end def test_01_smoke assert_kind_of(StringTerminal, @sta) assert_kind_of(GrammarSymbol, @sta) assert_kind_of(StringTerminal, @stp) assert_kind_of(GrammarSymbol, @stp) end def test_02_inspect assert_kind_of(String, @sta.inspect) assert_equal("a", @sta.inspect) end def test_03_string assert_kind_of(String, @sta.string) assert_equal("a", @sta.string) assert_kind_of(String, @stp.string) assert_equal("+", @stp.string) end def test_04_regexp assert_kind_of(Regexp, @sta.regexp) assert_equal(/\s*(a)/, @sta.regexp) assert_kind_of(Regexp, @stp.regexp) assert_equal(/\s*(\+)/, @stp.regexp) assert_equal("/\\s*(\\+)/", @stp.regexp.inspect) end end