diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-30 19:11:19 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-12-05 02:52:36 +0100 |
commit | f9639d724e1a6f1e8edaeafa78c2c3d8b43640a3 (patch) | |
tree | 643dfe2a34082edb6b7ca3bd293f59f343766e10 /tests | |
parent | 042409a2c40bb997739326928eab7d0430cec50b (diff) |
spans: add spans to Token::Error
Diffstat (limited to 'tests')
-rw-r--r-- | tests/span-tests/demo.html | 10 | ||||
-rw-r--r-- | tests/span-tests/demo.out | 46 | ||||
-rw-r--r-- | tests/test_html5lib.rs | 4 | ||||
-rw-r--r-- | tests/test_spans.rs | 4 |
4 files changed, 43 insertions, 21 deletions
diff --git a/tests/span-tests/demo.html b/tests/span-tests/demo.html index c635846..07c305b 100644 --- a/tests/span-tests/demo.html +++ b/tests/span-tests/demo.html @@ -3,3 +3,13 @@ this is a tag: <h1>test</h1> tags can have attributes: <div id = foobar> Attribute values can be quoted: <input name = 'age' type = "number"> + +But you cannot put attributes everywhere: </nope data=foobar> + +Please mind the gap: < test + +The pirate says &arrrrr; + +Does this open two pages? <a href=foo.html href=bar.html>click me</a> + +Do you start or do you end? </yes/> diff --git a/tests/span-tests/demo.out b/tests/span-tests/demo.out index ad9cfb8..37ab8be 100644 --- a/tests/span-tests/demo.out +++ b/tests/span-tests/demo.out @@ -1,19 +1,29 @@ note: - ┌─ test.html:1:1 - │ -1 │ this is a tag: <h1>test</h1> - │ ^^ ^^ end tag - │ │ - │ start tag -2 │ -3 │ tags can have attributes: <div id = foobar> - │ ^^ ^^^^^^ attr value - │ │ - │ attr name -4 │ -5 │ Attribute values can be quoted: <input name = 'age' type = "number"> - │ ^^^^ ^^^ ^^^^ ^^^^^^ attr value - │ │ │ │ - │ │ │ attr name - │ │ attr value - │ attr name + ┌─ test.html:1:17 + │ + 1 │ this is a tag: <h1>test</h1> + │ ^^ ^^ end tag + │ │ + │ start tag + · + 5 │ Attribute values can be quoted: <input name = 'age' type = "number"> + │ ^^^^ ^^^ ^^^^ ^^^^^^ attr value + │ │ │ │ + │ │ │ attr name + │ │ attr value + │ attr name + 6 │ + 7 │ But you cannot put attributes everywhere: </nope data=foobar> + │ ^^^^ end-tag-with-attributes + 8 │ + 9 │ Please mind the gap: < test + │ ^ invalid-first-character-of-tag-name +10 │ +11 │ The pirate says &arrrrr; + │ ^ unknown-named-character-reference +12 │ +13 │ Does this open two pages? <a href=foo.html href=bar.html>click me</a> + │ ^^^^ duplicate-attribute +14 │ +15 │ Do you start or do you end? </yes/> + │ ^ end-tag-with-trailing-solidus diff --git a/tests/test_html5lib.rs b/tests/test_html5lib.rs index 662f3c5..cd3785f 100644 --- a/tests/test_html5lib.rs +++ b/tests/test_html5lib.rs @@ -296,9 +296,9 @@ fn run_test_inner<R: Reader>( for token in tokenizer { let token = token.unwrap(); - if let Token::Error(e) = token { + if let Token::Error { error, .. } = token { actual_errors.push(ParseError { - code: ParseErrorInner(e), + code: ParseErrorInner(error), }); } else { actual_tokens.push(token); diff --git a/tests/test_spans.rs b/tests/test_spans.rs index 9cc745c..aeb4a94 100644 --- a/tests/test_spans.rs +++ b/tests/test_spans.rs @@ -31,7 +31,7 @@ fn test() { if let Token::StartTag(tag) = token { if tag.name == "h1" { labels.push(Label::primary(file_id, tag.name_span).with_message("start tag")); - } else { + } else if tag.name == "input" { for attr in tag.attributes.values() { labels.push( Label::primary(file_id, attr.name_span.clone()).with_message("attr name"), @@ -45,6 +45,8 @@ fn test() { if tag.name == "h1" { labels.push(Label::primary(file_id, tag.name_span).with_message("end tag")); } + } else if let Token::Error { error, span } = token { + labels.push(Label::primary(file_id, span).with_message(error.to_string())); } } |