Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { embeddedScripts, withEmbeddedScripts } from "./embeddedScripts.ts";
4
5function scriptsOf(command: string) {
6 return embeddedScripts(command).map((script) => {
7 script.starts.forEach((start, index) => {
8 expect(start).toBeLessThan(script.ends[index]!);
9 if (index > 0) expect(start).toBeGreaterThanOrEqual(script.ends[index - 1]!);
10 });
11 return [
12 script.language,
13 script.text,
14 command.slice(script.starts[0], script.ends.at(-1)),
15 ] as const;
16 });
17}
18
19const pythonScript = `from pathlib import Path
20import json
21
22# print every package.json name and version
23for p in sorted(Path('.').glob('**/package.json')):
24 data = json.loads(p.read_text())
25 print(f"{data['name']:16} {data.get('version', '?')}")
26`;
27
28describe("embeddedScripts", () => {
29 it("finds the script inside a Codex login-shell wrapper and the script inside that", () => {
30 const inner = `console.log('interrupt fixture tool started'); setTimeout(() => {}, 30000)`;
31 const command = `/bin/bash -lc "node -e \\"${inner}\\""`;
32 expect(scriptsOf(command)).toEqual([
33 ["shellscript", `node -e "${inner}"`, `node -e \\"${inner}\\"`],
34 ["javascript", inner, inner],
35 ]);
36 });
37
38 it("skips the -- that ends a login shell's options before the script", () => {
39 expect(scriptsOf(`bash -lc -- "python3 -c 'print(1)'"`)).toEqual([
40 ["shellscript", "python3 -c 'print(1)'", "python3 -c 'print(1)'"],
41 ["python", "print(1)", "print(1)"],
42 ]);
43 });
44
45 it.each([
46 [`bash -c -e "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
47 [`bash -c +e "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
48 [`bash -c -e -- "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
49 [`bash -c - "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
50 [`bash -c -o pipefail "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
51 [`bash -co pipefail "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
52 [`bash -c -oe pipefail "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
53 [`bash -oc pipefail "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
54 [`bash -c +o errexit "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
55 [
56 `zsh -oextendedglob -c "python3 -c 'print(1)'"`,
57 "python3 -c 'print(1)'",
58 "python",
59 "print(1)",
60 ],
61 [`zsh -c --errexit "python3 -c 'print(1)'"`, "python3 -c 'print(1)'", "python", "print(1)"],
62 ])(
63 "extracts nested scripts across POSIX shell options in %s",
64 (command, shellScript, nestedLanguage, nestedScript) => {
65 expect(scriptsOf(command).map(([language, text]) => [language, text])).toEqual([
66 ["shellscript", shellScript],
67 [nestedLanguage, nestedScript],
68 ]);
69 },
70 );
71
72 it("highlights a heredoc fed to an interpreter in that interpreter's language", () => {
73 const command = `python3 - <<'PY'\n${pythonScript}PY`;
74 expect(scriptsOf(command)).toEqual([["python", pythonScript, pythonScript]]);
75 });
76
77 it("maps escaped characters back to both source characters", () => {
78 const command = `/bin/zsh -lc "python3 - <<'PY'\nprint(\\"\\$HOME\\")\nPY"`;
79 const [shell, python] = scriptsOf(command);
80 expect(shell?.[1]).toBe(`python3 - <<'PY'\nprint("$HOME")\nPY`);
81 expect(python).toEqual(["python", `print("$HOME")\n`, `print(\\"\\$HOME\\")\n`]);
82 });
83
84 it("maps attached short inline scripts back to exact source offsets", () => {
85 expect(scriptsOf(`bash -lc "python3 -c'print(\\"\\$HOME\\")'"`)).toEqual([
86 ["shellscript", `python3 -c'print("$HOME")'`, `python3 -c'print(\\"\\$HOME\\")'`],
87 ["python", `print("$HOME")`, `print(\\"\\$HOME\\")`],
88 ]);
89 expect(scriptsOf("python3 -c'x = 1\nprint(x)'")).toEqual([
90 ["python", "x = 1\nprint(x)", "x = 1\nprint(x)"],
91 ]);
92 });
93
94 it.each([
95 `fish -C 'echo init' -c 'echo hi'`,
96 `fish -d debug -D 3 -c 'echo hi'`,
97 `fish --profile-startup startup.log --debug-output=debug.log -ic 'echo hi'`,
98 ])("finds the fish inline script after value options: %s", (command) => {
99 expect(scriptsOf(command)).toEqual([["fish", "echo hi", "echo hi"]]);
100 });
101
102 it.each([
103 [`bash -Ec 'echo hi'`, "shellscript", "echo hi"],
104 [`bash -euo pipefail -c 'echo hi'`, "shellscript", "echo hi"],
105 [`bash +x -c 'echo hi'`, "shellscript", "echo hi"],
106 [`bash -c -- -e`, "shellscript", "-e"],
107 [`bash -s -c 'echo 1' <<'EOF'\necho 2\nEOF`, "shellscript", "echo 1"],
108 [`sh --rcfile /dev/null -c 'echo SCRIPT'`, "shellscript", "echo SCRIPT"],
109 [`zsh -conoclobber 'echo hi'`, "shellscript", "echo hi"],
110 [`zsh -Oc 'echo hi'`, "shellscript", "echo hi"],
111 [`zsh -ofunctionargzero -c 'echo hi'`, "shellscript", "echo hi"],
112 [`zsh --emulate sh -c 'echo hi'`, "shellscript", "echo hi"],
113 [`fish -c -e "python3 -c 'print(1)'"`, "fish", "-e"],
114 [`fish -lc 'echo hi'`, "fish", "echo hi"],
115 [`fish -iNc'echo hi'`, "fish", "echo hi"],
116 [`python3 -c 'print(1)'`, "python", "print(1)"],
117 [`py -3 -c 'print(1)'`, "python", "print(1)"],
118 [`"C:\\Program Files\\Python312\\python.exe" -c 'print(1)'`, "python", "print(1)"],
119 [`node --eval "process.exit(0)"`, "javascript", "process.exit(0)"],
120 [`node -p "1 + 2"`, "javascript", "1 + 2"],
121 [`node -p -e "1 + 2"`, "javascript", "1 + 2"],
122 [`node --print --eval "1 + 2"`, "javascript", "1 + 2"],
123 [`bun -e 'console.log(Bun.version)'`, "typescript", "console.log(Bun.version)"],
124 [`deno eval 'console.log(1)'`, "typescript", "console.log(1)"],
125 [`deno eval --config deno.json 'console.log(1)'`, "typescript", "console.log(1)"],
126 [`psql -f schema.sql -c 'select 1'`, "sql", "select 1"],
127 [`node -C development -e 'console.log(1)'`, "javascript", "console.log(1)"],
128 [
129 `node --input-type module -e "import fs from 'node:fs'"`,
130 "javascript",
131 "import fs from 'node:fs'",
132 ],
133 [
134 `node --env-file .env -e 'console.log(process.env.FOO)'`,
135 "javascript",
136 "console.log(process.env.FOO)",
137 ],
138 [`node --env-file-if-exists .env.local -e 'console.log(1)'`, "javascript", "console.log(1)"],
139 [`node --experimental-loader ./loader.mjs -e 'console.log(1)'`, "javascript", "console.log(1)"],
140 [`node --title 'build job' -e 'console.log(42)'`, "javascript", "console.log(42)"],
141 [`node --inspect-port 9234 -e 'console.log(42)'`, "javascript", "console.log(42)"],
142 [
143 `node --disable-warning ExperimentalWarning -e 'console.log(42)'`,
144 "javascript",
145 "console.log(42)",
146 ],
147 [`node --unhandled-rejections strict -e 'console.log(42)'`, "javascript", "console.log(42)"],
148 [`node --redirect-warnings /dev/null -e 'console.log(42)'`, "javascript", "console.log(42)"],
149 [`ruby -e 'puts 1'`, "ruby", "puts 1"],
150 [`ruby -I lib -e 'puts 1'`, "ruby", "puts 1"],
151 [`ruby -E UTF-8 -e 'puts 1'`, "ruby", "puts 1"],
152 [`ruby --encoding UTF-8 -e 'puts 1'`, "ruby", "puts 1"],
153 [`ruby --external-encoding UTF-8 -e 'puts 1'`, "ruby", "puts 1"],
154 [`ruby --internal-encoding UTF-8 -e 'puts 1'`, "ruby", "puts 1"],
155 [`ruby --enable frozen-string-literal -e 'puts 1'`, "ruby", "puts 1"],
156 [`ruby --disable gems -e 'puts 1'`, "ruby", "puts 1"],
157 [`ruby -wE UTF-8 -e 'puts 1'`, "ruby", "puts 1"],
158 [`ruby -ne 'print if /foo/' input.txt`, "ruby", "print if /foo/"],
159 [`python3 -uc 'print(1)'`, "python", "print(1)"],
160 [`python3 -c'print(1)'`, "python", "print(1)"],
161 [`python3 -uc'print(1)'`, "python", "print(1)"],
162 [`python3 -uXdev -c'print(42)'`, "python", "print(42)"],
163 [`python3 --check-hash-based-pycs always -c 'print(42)'`, "python", "print(42)"],
164 [`node -pe 'process.version'`, "javascript", "process.version"],
165 [`perl -E 'say 1'`, "perl", "say 1"],
166 [`perl -e'print 1'`, "perl", "print 1"],
167 [`perl -pe 's/foo/bar/' input.txt`, "perl", "s/foo/bar/"],
168 [`perl -0777e'print 1'`, "perl", "print 1"],
169 [`perl -l0123e 'print 42'`, "perl", "print 42"],
170 [`perl -0777ne 'print length' input.txt`, "perl", "print length"],
171 [`perl -I lib -Mstrict -pe 's/foo/bar/' input.txt`, "perl", "s/foo/bar/"],
172 [`perl -nwIlib -e'print 1'`, "perl", "print 1"],
173 [`perl -e'print 1;' file.txt -e 'print 2'`, "perl", "print 1;"],
174 [`ruby -ne'puts $_' input.txt`, "ruby", "puts $_"],
175 [`ruby -0777e'puts 42'`, "ruby", "puts 42"],
176 [`ruby -W0e'puts 42'`, "ruby", "puts 42"],
177 [`ruby -Kue'puts 42'`, "ruby", "puts 42"],
178 [`ruby -e'puts 1' -- -e'puts 2'`, "ruby", "puts 1"],
179 [`sqlite3 app.db "select * from users"`, "sql", "select * from users"],
180 [`duckdb -s 'SELECT 42'`, "sql", "SELECT 42"],
181 [`duckdb -newline -s app.db 'SELECT 42'`, "sql", "SELECT 42"],
182 [`pwsh -NoProfile -Command "Get-ChildItem"`, "powershell", "Get-ChildItem"],
183 [
184 `osascript -e 'tell application "Finder" to activate'`,
185 "applescript",
186 'tell application "Finder" to activate',
187 ],
188 [
189 `osascript -l JavaScript -e 'Application("Finder").activate()'`,
190 "javascript",
191 'Application("Finder").activate()',
192 ],
193 [
194 `osascript -lJavaScript <<'EOF'\nApplication("Finder").activate()\nEOF`,
195 "javascript",
196 'Application("Finder").activate()\n',
197 ],
198 [`osascript -l JavaScript -l AppleScript -e 'beep'`, "applescript", "beep"],
199 [`env FOO=1 sudo -u bob python3 -c 'print(1)'`, "python", "print(1)"],
200 [`env -- FOO=1 python3 -c 'print(1)'`, "python", "print(1)"],
201 [`env -iu UNUSED python3 -c 'print(42)'`, "python", "print(42)"],
202 [`env -iuUNUSED python3 -c 'print(42)'`, "python", "print(42)"],
203 [`sudo -Eu bob python3 -c 'print(1)'`, "python", "print(1)"],
204 [`sudo -nHu postgres psql -c 'select 1'`, "sql", "select 1"],
205 [`sudo -S -p '' python3 -c 'print(1)'`, "python", "print(1)"],
206 [`sudo -Sp '' python3 -c 'print(1)'`, "python", "print(1)"],
207 [`sudo -h localhost python3 -c 'print(1)'`, "python", "print(1)"],
208 [`timeout 30 python3 -c 'print(1)'`, "python", "print(1)"],
209 [`gtimeout 30 python3 -c 'print(1)'`, "python", "print(1)"],
210 [`timeout -k 5 30s node -e 'console.log(1)'`, "javascript", "console.log(1)"],
211 [`timeout -k5s -v -sKILL 10 bash -c 'echo hi'`, "shellscript", "echo hi"],
212 [`timeout --kill-after 5 --signal KILL 30 bash -c 'echo hi'`, "shellscript", "echo hi"],
213 [`timeout -fk 5 1.5m bash -c 'echo hi'`, "shellscript", "echo hi"],
214 [`timeout -s KILL -v -- 0 bash -c 'echo hi'`, "shellscript", "echo hi"],
215 [`timeout 30 env FOO=1 python3 -c 'print(1)'`, "python", "print(1)"],
216 [`node --eval="process.exit(0)"`, "javascript", "process.exit(0)"],
217 [`psql --command='select 1'`, "sql", "select 1"],
218 [`psql -c 'select 1' <<'EOF'\nselect 2;\nEOF`, "sql", "select 1"],
219 [`mysql -c -e 'select 1'`, "sql", "select 1"],
220 [`psql -Atc 'select 1'`, "sql", "select 1"],
221 [`mysql -Ne 'select 1'`, "sql", "select 1"],
222 [`psql app <<'EOF'\nselect 1;\nEOF`, "sql", "select 1;\n"],
223 [`echo "$(node -e 'console.log(1)')"`, "javascript", "console.log(1)"],
224 [`python3 <<< 'print(1)'`, "python", "print(1)"],
225 ])("finds the inline script in %s", (command, language, script) => {
226 expect(scriptsOf(command)).toEqual([[language, script, expect.any(String)]]);
227 });
228
229 it.each([
230 [
231 `perl -e'print 1;' -E 'say 2'`,
232 [
233 ["perl", "print 1;", "print 1;"],
234 ["perl", "say 2", "say 2"],
235 ],
236 ],
237 [
238 `ruby -e'puts 1' -e 'puts 2'`,
239 [
240 ["ruby", "puts 1", "puts 1"],
241 ["ruby", "puts 2", "puts 2"],
242 ],
243 ],
244 [
245 `osascript -l JavaScript -e 'const app = Application("Finder")' -e 'app.activate()'`,
246 [
247 ["javascript", 'const app = Application("Finder")', 'const app = Application("Finder")'],
248 ["javascript", "app.activate()", "app.activate()"],
249 ],
250 ],
251 ])("finds repeated inline scripts in %s", (command, expected) => {
252 expect(scriptsOf(command)).toEqual(expected);
253 });
254
255 it.each([[`psql -c 'select 1' -c 'select 2'`], [`sqlite3 app.db "select 1" "select 2"`]])(
256 "finds every statement a SQL shell runs: %s",
257 (command) => {
258 expect(scriptsOf(command).map(([language, text]) => [language, text])).toEqual([
259 ["sql", "select 1"],
260 ["sql", "select 2"],
261 ]);
262 },
263 );
264
265 it.each([
266 [`psql -c 'select 1' -f - <<'EOF'\nselect 2;\nEOF`, ["select 1", "select 2;\n"]],
267 [`psql --command='select 1' -f - <<< 'select 2;'`, ["select 1", "select 2;"]],
268 ])("highlights both inline and stdin SQL in %s", (command, expected) => {
269 expect(scriptsOf(command).map(([language, text]) => [language, text])).toEqual(
270 expected.map((text) => ["sql", text]),
271 );
272 });
273
274 it.each([
275 ["the file `cat` writes", `cat > src/app.ts <<'EOF'\nconst a = 1;\nEOF`, "typescript"],
276 ["the file `tee` writes", `tee -a config.json <<EOF\n{}\nEOF`, "json"],
277 ["its delimiter", `kubectl apply -f - <<'YAML'\nkind: Pod\nYAML`, "yaml"],
278 ["the shell reading it", `bash <<'EOF'\necho hi\nEOF`, "shellscript"],
279 ["Node.js with -p", `node -p <<'EOF'\n1 + 2\nEOF`, "javascript"],
280 [
281 "a shell reading stdin with -s and operands",
282 `bash -euxs -- prod <<'EOF'\necho "$1"\nEOF`,
283 "shellscript",
284 ],
285 ["zsh with -onoclobber", `zsh -onoclobber <<'EOF'\necho hi\nEOF`, "shellscript"],
286 ["zsh with --emulate", `zsh --emulate sh <<'EOF'\necho hi\nEOF`, "shellscript"],
287 ["psql reading stdin with -f -", `psql -f - <<'EOF'\nselect 1;\nEOF`, "sql"],
288 ["psql reading stdin with --file=-", `psql --file=- <<'EOF'\nselect 1;\nEOF`, "sql"],
289 ["psql reading stdin with attached -f-", `psql -Atf- <<'EOF'\nselect 1;\nEOF`, "sql"],
290 ["psql mixing a file and -f -", `psql -f schema.sql -f - <<'EOF'\nselect 1;\nEOF`, "sql"],
291 ])("takes a heredoc's language from %s", (_source, command, language) => {
292 expect(scriptsOf(command).map(([lang]) => lang)).toEqual([language]);
293 });
294
295 it.each([
296 ["a script file", `python3 build.py <<EOF\ndata\nEOF`],
297 ["a module", `python3 -m json.tool <<EOF\n{}\nEOF`],
298 ["a SQL file", `psql -f migrate.sql <<EOF\ny\nEOF`],
299 ["a SQL file given with =", `psql --file=migrate.sql <<EOF\ny\nEOF`],
300 ["plain commands", `rg -n "foo" src && git status`],
301 ["an unnamed heredoc into a plain command", `git commit -F - <<'EOF'\nfix: x\nEOF`],
302 ["an empty script", `bash -lc ' '`],
303 ["a perl -i backup suffix of e", `perl -pie 's/foo/bar/' input.txt`],
304 ["a ruby -i backup suffix of e", `ruby -ie 'puts 1' input.txt`],
305 ["a python -W value of c", `python3 -Wc 'print(1)'`],
306 ["an attached python -W value starting with c", `python3 -Wc'print(1)'`],
307 ["a bundled python -X consuming the next arg", `python3 -uX -c'print(42)'`],
308 ["a bundled python -W consuming the next arg", `python3 -uW -c'print(42)'`],
309 ["an attached python -m module before -c", `python3 -mthis -c'print(42)'`],
310 ["a bundled python -m module before -c", `python3 -um this -c'print(42)'`],
311 ["an attached perl -M module starting with e", `perl -Me'print 1'`],
312 ["a bundled perl -I consuming the next arg", `perl -nwI -e'print 1'`],
313 ["an invalid perl octal switch without leading 0", `perl -7e'print 1'`],
314 ["an attached ruby -r require starting with e", `ruby -re'puts 1'`],
315 ["a ruby -K option consuming e as its encoding", `ruby -Ke 'puts 42'`],
316 ["a bundled ruby -I consuming the next arg", `ruby -wI -e'puts 42'`],
317 ["a ruby -W category before e", `ruby -W:deprecatede'puts 42'`],
318 ["a node -e flag with an attached value", `node -e'console.log(1)'`],
319 ["an attached inline flag after --", `python3 -- -c'print(1)'`],
320 [
321 "a whitespace-only attached inline script before a heredoc",
322 `python3 -c' ' <<'EOF'\nprint(2)\nEOF`,
323 ],
324 ["an empty attached python -c before a heredoc", `python3 -c'' <<'EOF'\nprint(2)\nEOF`],
325 ["an empty separate python -c before a heredoc", `python3 -c '' <<'EOF'\nprint(2)\nEOF`],
326 ["a bare python -c before a heredoc", `python3 -c <<'EOF'\nprint(2)\nEOF`],
327 ["a bare psql -c before a heredoc", `psql -c <<'EOF'\nselect 1;\nEOF`],
328 ["a psql -d database named c", `psql -dc 'select 1'`],
329 ["a bundled psql -f script file", `psql -Atf query.sql <<'EOF'\nselect 1;\nEOF`],
330 ["a bare psql -f before a heredoc", `psql -f <<'EOF'\nselect 1;\nEOF`],
331 ["a psql -f - followed by a bare -f before a heredoc", `psql -f - -f <<'EOF'\nselect 1;\nEOF`],
332 ["a duckdb -f - before a heredoc", `duckdb -f - <<'EOF'\nselect 1;\nEOF`],
333 ["a fish -C init command named c", `fish -Cc 'echo hi'`],
334 ["a shell whose -c has no script, before a heredoc", `sh -c -- <<'EOF'\necho hi\nEOF`],
335 [
336 "a shell whose -c has only trailing options before a heredoc",
337 `sh -c -e <<'EOF'\necho hi\nEOF`,
338 ],
339 [
340 "a shell whose -co option has no script after its option value",
341 `bash -co pipefail <<'EOF'\necho hi\nEOF`,
342 ],
343 [
344 "a shell with a GNU long option after -c",
345 `bash -c --rcfile /dev/null "python3 -c 'print(1)'"`,
346 ],
347 ["a shell with a GNU long option after -s", `bash -s --norc prod <<'EOF'\necho hi\nEOF`],
348 ["a zsh -o option name containing s", `zsh -oshwordsplit run.sh <<'EOF'\necho hi\nEOF`],
349 ["a ksh -o option name containing c", `ksh -onoclobber run.sh`],
350 ["a shell clearing -s with +s", `dash -s +s run.sh <<'EOF'\necho hi\nEOF`],
351 ["a heredoc `cat` sends to stdout while stderr goes to a file", `cat 2>log.ts <<'EOF'\nx\nEOF`],
352 ])("finds nothing for %s", (_case, command) => {
353 expect(scriptsOf(command)).toEqual([]);
354 });
355
356 it("trusts nothing in a command whose quoting does not parse", () => {
357 // Secret redaction removed an escaped quote's backslash, breaking the -lc argument.
358 const command = `/bin/zsh -lc "python3 -c 'token=[REDACTED_SECRET]"apiToken\\"]; print(token)'"`;
359 expect(scriptsOf(command)).toEqual([]);
360 });
361});
362
363describe("withEmbeddedScripts", () => {
364 function tokenize(text: string, language: string) {
365 if (language === "unknown") throw new Error("Language not found");
366 let lineStart = 0;
367 return text.split(/\r?\n/u).map((line) => {
368 const tokens = [...line.matchAll(/\S+|\s+/gu)].map((match) => ({
369 content: match[0],
370 offset: lineStart + match.index,
371 color: language,
372 }));
373 lineStart +=
374 line.length + (text.slice(lineStart + line.length).match(/^\r?\n/u)?.[0].length ?? 0);
375 return tokens;
376 });
377 }
378
379 function colorsOf(code: string, scripts = embeddedScripts(code)) {
380 const lines = withEmbeddedScripts(code, tokenize(code, "shellscript"), scripts, tokenize);
381 expect(lines.map((line) => line.map((token) => token.content).join("")).join("\n")).toBe(
382 code.replaceAll("\r\n", "\n"),
383 );
384 return lines.flat().map((token) => [token.content, token.color]);
385 }
386
387 it("colors each nested script with its own grammar, keeping the text", () => {
388 expect(colorsOf(`bash -lc "python3 -c 'print(1)'"`)).toEqual([
389 [`bash -lc "python3 -c '`, "shellscript"],
390 ["print(1)", "python"],
391 [`'"`, "shellscript"],
392 ]);
393 });
394
395 it("colors an escape sequence like the character it spells", () => {
396 expect(colorsOf(`bash -c "python3 -c 'print(\\"x\\")'"`)).toContainEqual([
397 `print(\\"x\\")`,
398 "python",
399 ]);
400 });
401
402 it("keeps the surrounding colors where a grammar is missing", () => {
403 const code = "cat > x.ts <<'EOF'\r\nbody\r\nEOF";
404 const [script] = embeddedScripts(code);
405 const characterColors = (scripts: ReturnType<typeof embeddedScripts>) =>
406 colorsOf(code, scripts).flatMap(([content, color]) => [...content!].map(() => color));
407 expect(characterColors([{ ...script!, language: "unknown" }])).toEqual(characterColors([]));
408 });
409});