aboutsummaryrefslogtreecommitdiff
path: root/integration_tests/tests
diff options
context:
space:
mode:
Diffstat (limited to 'integration_tests/tests')
-rw-r--r--integration_tests/tests/test_html5lib.rs30
1 files changed, 23 insertions, 7 deletions
diff --git a/integration_tests/tests/test_html5lib.rs b/integration_tests/tests/test_html5lib.rs
index 8fedc1a..a682cb3 100644
--- a/integration_tests/tests/test_html5lib.rs
+++ b/integration_tests/tests/test_html5lib.rs
@@ -1,11 +1,12 @@
-use std::{fs::File, io::BufReader, path::Path};
+use std::{fs::File, io::BufReader, ops::Range, path::Path};
use html5lib_tests::{
parse_tests, Error as TestError, InitialState, Output, Test, Token as TestToken,
};
use html5tokenizer::{
- offset::NoopOffset, reader::Reader, CdataAction, DefaultEmitter, Event, InternalState, Token,
- Tokenizer,
+ offset::{Offset, Position},
+ reader::Reader,
+ CdataAction, DefaultEmitter, Emitter, Error, Event, InternalState, Token, Tokenizer,
};
use similar_asserts::assert_eq;
@@ -90,14 +91,19 @@ fn run_test(fname: &str, test_i: usize, test: Test) {
}
}
-fn run_test_inner<R: Reader>(
+fn run_test_inner<R, O, E, T>(
fname: &str,
test_i: usize,
test: &Test,
state: &InitialState,
- mut tokenizer: Tokenizer<R, NoopOffset, DefaultEmitter>,
+ mut tokenizer: Tokenizer<R, O, E>,
tokenizer_info: &str,
-) {
+) where
+ R: Reader + Position<O>,
+ O: Offset,
+ E: Emitter<O> + Iterator<Item = T> + DrainErrors<O>,
+ T: Into<Token<O>>,
+{
println!(
"==== FILE {}, TEST {}, STATE {:?}, TOKENIZER {} ====",
fname, test_i, state, tokenizer_info,
@@ -123,7 +129,7 @@ fn run_test_inner<R: Reader>(
tokenizer.handle_cdata_open(CdataAction::BogusComment);
continue;
}
- Event::Token(token) => token,
+ Event::Token(token) => token.into(),
};
match token {
@@ -170,3 +176,13 @@ fn run_test_inner<R: Reader>(
test.output,
);
}
+
+trait DrainErrors<O> {
+ fn drain_errors(&mut self) -> Box<dyn Iterator<Item = (Error, Range<O>)> + '_>;
+}
+
+impl<O> DrainErrors<O> for DefaultEmitter<O> {
+ fn drain_errors(&mut self) -> Box<dyn Iterator<Item = (Error, Range<O>)> + '_> {
+ Box::new(self.drain_errors())
+ }
+}