Skip to content

Commit b32af72

Browse files
committed
error order doesn't always matter
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40938
1 parent f750822 commit b32af72

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/test_tokenizer.rb

+28-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@
66

77
class Html5TokenizerTestCase < Test::Unit::TestCase
88

9+
def assert_tokens_match(expectedTokens, receivedTokens, ignoreErrorOrder, message)
10+
if !ignoreErrorOrder
11+
return expectedTokens == receivedTokens
12+
else
13+
#Sort the tokens into two groups; non-parse errors and parse errors
14+
expected = [[],[]]
15+
received = [[],[]]
16+
17+
for token in expectedTokens
18+
if token != "ParseError"
19+
expected[0] << token
20+
else
21+
expected[1] << token
22+
end
23+
end
24+
25+
for token in receivedTokens
26+
if token != "ParseError"
27+
received[0] << token
28+
else
29+
received[1] << token
30+
end
31+
end
32+
assert_equal expected, received, message
33+
end
34+
end
35+
936
def type_of?(token_name, token)
1037
token != 'ParseError' and token_name == token.first
1138
end
@@ -48,7 +75,7 @@ def tokenizer_test(data)
4875

4976
expected = concatenate_consecutive_characters(data['output'])
5077

51-
assert_equal expected, actual, message
78+
assert_tokens_match expected, actual, data["ignoreErrorOrder"], message
5279
end
5380
end
5481
end

0 commit comments

Comments
 (0)