1require 'rdoc/test_case' 2 3class TestRDocTokenStream < RDoc::TestCase 4 5 def test_class_to_html 6 tokens = [ 7 RDoc::RubyToken::TkCONSTANT. new(0, 0, 0, 'CONSTANT'), 8 RDoc::RubyToken::TkDEF. new(0, 0, 0, 'KW'), 9 RDoc::RubyToken::TkIVAR. new(0, 0, 0, 'IVAR'), 10 RDoc::RubyToken::TkOp. new(0, 0, 0, 'Op'), 11 RDoc::RubyToken::TkId. new(0, 0, 0, 'Id'), 12 RDoc::RubyToken::TkNode. new(0, 0, 0, 'Node'), 13 RDoc::RubyToken::TkCOMMENT. new(0, 0, 0, 'COMMENT'), 14 RDoc::RubyToken::TkREGEXP. new(0, 0, 0, 'REGEXP'), 15 RDoc::RubyToken::TkSTRING. new(0, 0, 0, 'STRING'), 16 RDoc::RubyToken::TkVal. new(0, 0, 0, 'Val'), 17 RDoc::RubyToken::TkBACKSLASH.new(0, 0, 0, '\\'), 18 ] 19 20 expected = [ 21 '<span class="ruby-constant">CONSTANT</span>', 22 '<span class="ruby-keyword">KW</span>', 23 '<span class="ruby-ivar">IVAR</span>', 24 '<span class="ruby-operator">Op</span>', 25 '<span class="ruby-identifier">Id</span>', 26 '<span class="ruby-node">Node</span>', 27 '<span class="ruby-comment">COMMENT</span>', 28 '<span class="ruby-regexp">REGEXP</span>', 29 '<span class="ruby-string">STRING</span>', 30 '<span class="ruby-value">Val</span>', 31 '\\' 32 ].join 33 34 assert_equal expected, RDoc::TokenStream.to_html(tokens) 35 end 36 37 def test_class_to_html_empty 38 assert_equal '', RDoc::TokenStream.to_html([]) 39 end 40 41end 42 43