require 'rdoc/test_case' class TestRDocRubyLex < RDoc::TestCase def setup @TK = RDoc::RubyToken end def mu_pp obj s = '' s = PP.pp obj, s s = s.force_encoding(Encoding.default_external) if defined? Encoding s.chomp end def test_class_tokenize tokens = RDoc::RubyLex.tokenize "def x() end", nil expected = [ @TK::TkDEF .new( 0, 1, 0, "def"), @TK::TkSPACE .new( 3, 1, 3, " "), @TK::TkIDENTIFIER.new( 4, 1, 4, "x"), @TK::TkLPAREN .new( 5, 1, 5, "("), @TK::TkRPAREN .new( 6, 1, 6, ")"), @TK::TkSPACE .new( 7, 1, 7, " "), @TK::TkEND .new( 8, 1, 8, "end"), @TK::TkNL .new(11, 1, 11, "\n"), ] assert_equal expected, tokens end def test_class_tokenize_def_heredoc tokens = RDoc::RubyLex.tokenize <<-'RUBY', nil def x <