1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
-- Self-check for themes.popular. Run with: panto lua _selfcheck.lua
local here = debug.getinfo(1, "S").source:match("^@(.*)/[^/]+$") or "."
package.path = here .. "/?.lua;" .. package.path
local roles = {
"dim", "assistant", "user", "tool", "footer", "tool_text",
"tool_pending", "tool_success", "tool_error", "compaction_header",
"thinking_header", "cursor", "err", "welcome", "waiting_peak",
"waiting_near", "waiting_far", "err_diff", "add_diff", "thinking",
"compaction", "user_bg", "tool_pending_bg", "tool_success_bg",
"tool_error_bg", "diff_remove_bg", "diff_add_bg", "user_text",
"tool_header", "canvas_fg", "canvas_bg", "syntax_base",
"syntax_comment", "syntax_string", "syntax_number", "syntax_keyword",
"syntax_function", "syntax_type", "syntax_variable", "syntax_tag",
}
local names = {
"Tokyo Night", "Catppuccin Mocha", "Gruvbox Dark", "Solarized Light",
"Solarized Dark", "Nord", "Dracula", "Tokyo Storm", "Tokyo Moon",
"Tokyo Day", "Catppuccin Latte", "Catppuccin Frappe",
"Catppuccin Macchiato", "Gruvbox Dark Hard", "Gruvbox Dark Soft",
"Gruvbox Light", "Gruvbox Light Hard", "Gruvbox Light Soft",
"Dracula Soft", "Kanagawa Wave", "Kanagawa Dragon", "Kanagawa Lotus",
}
local function copy(t)
local out = {}
for k, v in pairs(t) do out[k] = v end
return out
end
local registered = {}
package.loaded["panto"] = {
ext = {
style = function(name, values)
assert(type(name) == "string")
assert(type(values) == "table", "registration values for " .. name)
local old = registered[name]
if old then
for k, v in pairs(values) do
assert(old[k] == v, "conflicting re-registration for " .. name .. ": " .. k)
end
else
registered[name] = copy(values)
end
end,
},
}
local entry = require("panto-popular-themes.init")
assert(entry.name == "themes.popular", "entry name")
assert(type(entry.activate) == "function", "entry activate")
entry.activate()
local count = 0
for name in pairs(registered) do count = count + 1 end
assert(count == 22, "expected 22 themes, got " .. count)
for _, name in ipairs(names) do
local values = registered[name]
assert(values, "missing theme " .. name)
for _, role in ipairs(roles) do
assert(type(values[role]) == "string", name .. " missing role " .. role)
end
assert(values.reset == "\27[0m", name .. " reset")
end
local function eq(name, role, expected)
assert(registered[name][role] == expected,
name .. "." .. role .. " was " .. tostring(registered[name][role]) ..
", expected " .. expected)
end
eq("Tokyo Night", "tool", "\27[38;2;122;162;247m")
eq("Tokyo Night", "diff_add_bg", "\27[48;2;36;62;74m")
eq("Solarized Light", "diff_add_bg", "\27[48;2;229;227;181m")
eq("Kanagawa Lotus", "canvas_bg", "\27[48;2;242;236;188m")
eq("Kanagawa Lotus", "syntax_tag", "\27[38;2;102;147;191m")
eq("Kanagawa Wave", "reset", "\27[0m")
print("selfcheck: OK")
|