From 192ba9bb544591ee0e32fd6b9fcc9458f0eaa9f3 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 19 Mar 2014 21:44:57 +0100 Subject: [PATCH] Expanded the lexer comment tests. --- spec/oga/lexer/comments_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/oga/lexer/comments_spec.rb b/spec/oga/lexer/comments_spec.rb index cd2b2bf..254bb22 100644 --- a/spec/oga/lexer/comments_spec.rb +++ b/spec/oga/lexer/comments_spec.rb @@ -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, 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, 8] + ] + end + + example 'lex an element followed by a comment' do + lex('

').should == [ + [:T_ELEM_OPEN, nil, 1, 1], + [:T_ELEM_NAME, 'p', 1, 2], + [:T_ELEM_CLOSE, nil, 1, 4], + [:T_COMMENT_START, '', 1, 12] + ] + end end end