From 826907487e2b593f1c54e98b59fe2f6eb8cb6937 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 29 Aug 2023 13:09:44 +0200 Subject: break!: remove Token::Error An error isn't a token (in general and also according to the spec). You shouldn't have to filter out errors when you're just interested in tokens but most importantly having errors in the Token enum is annoying when implementing tree construction (since the spec conditions exhaustively cover all Token variants except Token::Error). --- integration_tests/tests/test_html5lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'integration_tests') diff --git a/integration_tests/tests/test_html5lib.rs b/integration_tests/tests/test_html5lib.rs index 0cf5868..2e404c5 100644 --- a/integration_tests/tests/test_html5lib.rs +++ b/integration_tests/tests/test_html5lib.rs @@ -115,7 +115,6 @@ fn run_test_inner( tokenizer.set_last_start_tag(last_start_tag); } - let mut actual_errors = Vec::new(); let mut actual_tokens = Vec::new(); while let Some(event) = tokenizer.next() { @@ -128,9 +127,6 @@ fn run_test_inner( }; match token { - Token::Error { error, .. } => actual_errors.push(TestError { - code: error.code().to_string(), - }), Token::StartTag(tag) => actual_tokens.push(TestToken::StartTag { name: tag.name, attributes: tag @@ -154,7 +150,13 @@ fn run_test_inner( assert_eq!( Output { - errors: actual_errors, + errors: tokenizer + .emitter_mut() + .drain_errors() + .map(|(e, _)| TestError { + code: e.code().to_string() + }) + .collect(), tokens: actual_tokens, }, test.output, -- cgit v1.2.3