From 0b57e70b88f99728b3ff916f24e6258a4dacdbb8 Mon Sep 17 00:00:00 2001 From: darkuss Date: Tue, 29 Sep 2026 03:40:27 +0200 Subject: [PATCH] Add tokenizer tests for processing instructions --- tokenizer/README.md | 1 + tokenizer/test2.test | 20 ++-- tokenizer/test3.test | 276 ++++++++++++++++++++++++++++++------------- 3 files changed, 204 insertions(+), 93 deletions(-) diff --git a/tokenizer/README.md b/tokenizer/README.md index 66b81e8f..996d1e6f 100644 --- a/tokenizer/README.md +++ b/tokenizer/README.md @@ -76,6 +76,7 @@ tokens are: ["StartTag", name, {attributes}] ["EndTag", name] ["Comment", data] + ["ProcessingInstruction", data] ["Character", data] `public_id` and `system_id` are either strings or `null`. `correctness` diff --git a/tokenizer/test2.test b/tokenizer/test2.test index c29e4c31..edbec4b5 100644 --- a/tokenizer/test2.test +++ b/tokenizer/test2.test @@ -183,19 +183,17 @@ { "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 } ]}, -{"description":"Simili processing instruction", +{"description":"Processing instruction", "input":"", -"output":[["Comment", "?namespace"]], -"errors":[ - { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 } -]}, +"output":[["ProcessingInstruction", "namespace", ""]]}, -{"description":"A bogus comment stops at >, even if preceded by two dashes", -"input":"", -"output":[["Comment", "?foo--"]], -"errors":[ - { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 } -]}, +{"description":"A processing instruction delimited by ?> doesn't contain the delimiting ?", +"input":"", +"output":[["ProcessingInstruction", "foo", "bar"]]}, + +{"description":"A processing instruction's data delimited by ?> contains the correct amount of ?", +"input":"", +"output":[["ProcessingInstruction", "foo", "bar?"]]}, {"description":"Unescaped <", "input":"foo < bar", diff --git a/tokenizer/test3.test b/tokenizer/test3.test index 901a581e..7a6a1b90 100644 --- a/tokenizer/test3.test +++ b/tokenizer/test3.test @@ -8954,16 +8954,184 @@ {"description":"", "input":"", "output":[["Comment", "?"]], "errors":[ - { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 } + { "code": "invalid-first-character-of-processing-instruction-target", "line": 1, "col": 3 } ]}, {"description":"