Expanded the lexer comment tests.

This commit is contained in:
Yorick Peterse 2014-03-19 21:44:57 +01:00
parent f1fcdfbacb
commit 192ba9bb54
1 changed files with 26 additions and 0 deletions

View File

@ -25,5 +25,31 @@ describe Oga::Lexer do
[:T_COMMENT_END, '-->', 1, 9]
]
end
example 'lex a comment followed by text' do
lex('<!---->foo').should == [
[:T_COMMENT_START, '<!--', 1, 1],
[:T_COMMENT_END, '-->', 1, 5],
[:T_TEXT, 'foo', 1, 8]
]
end
example 'lex text followed by a comment' do
lex('foo<!---->').should == [
[:T_TEXT, 'foo', 1, 1],
[:T_COMMENT_START, '<!--', 1, 4],
[:T_COMMENT_END, '-->', 1, 8]
]
end
example 'lex an element followed by a comment' do
lex('<p></p><!---->').should == [
[:T_ELEM_OPEN, nil, 1, 1],
[:T_ELEM_NAME, 'p', 1, 2],
[:T_ELEM_CLOSE, nil, 1, 4],
[:T_COMMENT_START, '<!--', 1, 8],
[:T_COMMENT_END, '-->', 1, 12]
]
end
end
end