From aac81630c81f7bef8920ce4681033f481c62a64c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 10:53:54 -1000 Subject: Cover the rest of syntax-highlight's output No token ever took hl-type or hl-comment, so a typo in either row, or a rule gone from the stylesheet, passed. Nothing fed the filter a NUL byte or a blob of exactly the size cap either. --- tests/extensions/test-syntax-highlight.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/extensions/test-syntax-highlight.lua') diff --git a/tests/extensions/test-syntax-highlight.lua b/tests/extensions/test-syntax-highlight.lua index 90ef5b9..c6c7b47 100644 --- a/tests/extensions/test-syntax-highlight.lua +++ b/tests/extensions/test-syntax-highlight.lua @@ -32,6 +32,9 @@ if mode == "nolexers" then h.equals("the fallback escapes markup", out, "a <b> & c") h.equals("and the error log hears of it only once", h.error_log(), "") + out = render("hello.fake", "a\0b") + h.equals("a nul byte cuts the escaped blob short", out, "a") + -- Large output leaves in slices, and a byte lost at a boundary would -- put the line numbers beside it out of step, so the whole escaped -- blob has to come back intact across several slices. @@ -121,6 +124,10 @@ h.equals("close answers zero", ret, 0) out = render("hello.fake", "'&'") h.equals("markup inside a token is escaped", out, "'<b>&'") +out = render("hello.fake", "-- note\nString x") +h.equals("comments and types take their classes", out, + "-- note\nString x") + out = render("hello.fake", "$color :hover") h.contains("a css property takes the number class", out, "$color") h.contains("a css pseudo-class takes the function class", out, ":hover") @@ -175,6 +182,14 @@ out = render("big.fake", string.rep("a", 512 * 1024 + 1)) h.excludes("an oversized blob skips the lexing pass", out, "a") + +-- cgit's sink stops at the first NUL byte, as the harness does, so a blob +-- holding one loses everything from there on. +out = render("hello.fake", "a\0b") +h.equals("a nul byte cuts the highlighted blob short", out, "a") + out, ret = render("empty.fake", "") h.equals("an empty blob renders empty", out, "") h.equals("an empty blob still answers zero", ret, 0) -- cgit 2.12.1