diff options
Diffstat (limited to 'tests/extensions')
-rw-r--r--tests/extensions/fake-lexers/lexer.lua11
-rw-r--r--tests/extensions/test-syntax-highlight.lua4
2 files changed, 11 insertions, 4 deletions
diff --git a/tests/extensions/fake-lexers/lexer.lua b/tests/extensions/fake-lexers/lexer.lua
index adf7d5b..0632744 100644
--- a/tests/extensions/fake-lexers/lexer.lua
+++ b/tests/extensions/fake-lexers/lexer.lua
@@ -1,9 +1,9 @@
-- A miniature stand-in for the Scintillua lexer module, just enough for the
-- syntax-highlight checks to drive every path through the filter without the
-- real collection installed. load() hands out one of the toy lexers below by
--- name and detect() recognises a single filename suffix, so a check can tell
--- the detection path apart from the extension path by which lexer ends up
--- running. Anything the filter treats as optional, a lexer that will not
+-- name and detect() recognises a single filename suffix or a shebang naming
+-- fake, so a check can tell the detection path apart from the extension path
+-- by which lexer ends up running. Anything the filter treats as optional, a lexer that will not
-- load or one that raises while lexing, has a name here too.
local M = {}
@@ -67,10 +67,13 @@ function M.load(name)
return lexer
end
-function M.detect(filename)
+function M.detect(filename, line)
if filename:match("%.viadetect$") then
return "fake"
end
+ if line ~= nil and line:match("^#!.*fake") then
+ return "fake"
+ end
return nil
end
diff --git a/tests/extensions/test-syntax-highlight.lua b/tests/extensions/test-syntax-highlight.lua
index a9e8b36..a87cd80 100644
--- a/tests/extensions/test-syntax-highlight.lua
+++ b/tests/extensions/test-syntax-highlight.lua
@@ -60,6 +60,10 @@ h.equals("a lexer that raises falls back to escaped text", out, "some <code&g
out = render("script.viadetect", "if")
h.equals("filename detection picks the lexer", out, "<span class='hl-keyword'>if</span>")
+out = render("post-receive", "#!/usr/bin/fake\nif")
+h.contains("a shebang picks the lexer of a file with no extension", out,
+ "<span class='hl-keyword'>if</span>")
+
out = render("tool.py", "import <x>")
h.equals("an extension with no lexer serves escaped text", out, "import &lt;x&gt;")