Permalink
Browse files

Updated doctype-parsing tokeniser tests and code to match updated spec

  • Loading branch information...
excors
excors committed Feb 14, 2008
1 parent f057244 commit 06e837066441f103d2da18f31309b46bd015ad65
Showing with 21 additions and 1 deletion.
  1. +20 −0 lib/html5/tokenizer.rb
  2. +1 −1 test/test_tokenizer.rb
View
@@ -824,6 +824,11 @@ def doctype_public_identifier_double_quoted_state
data = @stream.char
if data == "\""
@state = :after_doctype_public_identifier_state
+ elsif data == ">"
+ @token_queue << {:type => :ParseError, :data => "unexpected-end-of-doctype"}
+ @current_token[:correct] = false
+ @token_queue << @current_token
+ @state = :data_state
elsif data == :EOF
@token_queue << {:type => :ParseError, :data => "eof-in-doctype"}
@current_token[:correct] = false
@@ -839,6 +844,11 @@ def doctype_public_identifier_single_quoted_state
data = @stream.char
if data == "'"
@state = :after_doctype_public_identifier_state
+ elsif data == ">"
+ @token_queue << {:type => :ParseError, :data => "unexpected-end-of-doctype"}
+ @current_token[:correct] = false
+ @token_queue << @current_token
+ @state = :data_state
elsif data == :EOF
@token_queue << {:type => :ParseError, :data => "eof-in-doctype"}
@current_token[:correct] = false
@@ -904,6 +914,11 @@ def doctype_system_identifier_double_quoted_state
data = @stream.char
if data == "\""
@state = :after_doctype_system_identifier_state
+ elsif data == ">"
+ @token_queue << {:type => :ParseError, :data => "unexpected-end-of-doctype"}
+ @current_token[:correct] = false
+ @token_queue << @current_token
+ @state = :data_state
elsif data == :EOF
@token_queue << {:type => :ParseError, :data => "eof-in-doctype"}
@current_token[:correct] = false
@@ -919,6 +934,11 @@ def doctype_system_identifier_single_quoted_state
data = @stream.char
if data == "'"
@state = :after_doctype_system_identifier_state
+ elsif data == ">"
+ @token_queue << {:type => :ParseError, :data => "unexpected-end-of-doctype"}
+ @current_token[:correct] = false
+ @token_queue << @current_token
+ @state = :data_state
elsif data == :EOF
@token_queue << {:type => :ParseError, :data => "eof-in-doctype"}
@current_token[:correct] = false
View
@@ -8,7 +8,7 @@ class Html5TokenizerTestCase < Test::Unit::TestCase
def assert_tokens_match(expectedTokens, receivedTokens, ignoreErrorOrder, message)
if !ignoreErrorOrder
- return expectedTokens == receivedTokens
+ assert_equal expectedTokens, receivedTokens, message
else
#Sort the tokens into two groups; non-parse errors and parse errors
expected = [[],[]]

0 comments on commit 06e8370

Please sign in to comment.