Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'tests/extensions/test-syntax-highlight.lua')
| -rw-r--r-- | tests/extensions/test-syntax-highlight.lua | 15 |
1 file changed, 15 insertions, 0 deletions
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", "'<b>&'") h.equals("markup inside a token is escaped", out, "<span class='hl-string'>'<b>&'</span>") +out = render("hello.fake", "-- note\nString x") +h.equals("comments and types take their classes", out, + "<span class='hl-comment'>-- note</span>\n<span class='hl-type'>String</span> <span class='hl-keyword'>x</span>") + out = render("hello.fake", "$color :hover") h.contains("a css property takes the number class", out, "<span class='hl-number'>$color</span>") h.contains("a css pseudo-class takes the function class", out, "<span class='hl-func'>:hover</span>") @@ -175,6 +182,14 @@ out = render("big.fake", string.rep("a", 512 * 1024 + 1)) h.excludes("an oversized blob skips the lexing pass", out, "<span") h.equals("and still arrives whole", #out, 512 * 1024 + 1) +out = render("big.fake", string.rep("a", 512 * 1024)) +h.equals("a blob of exactly the cap is still lexed", out:sub(1, 26), "<span class='hl-keyword'>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, "<span class='hl-keyword'>a</span>") + out, ret = render("empty.fake", "") h.equals("an empty blob renders empty", out, "") h.equals("an empty blob still answers zero", ret, 0) |
