Files
vercel-labs--zerolang/extensions/vscode/tests/vscode-extension.test.mjs
T
wehub-resource-sync e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:29:30 +08:00

59 lines
2.5 KiB
JavaScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { describe, it } from "node:test";
describe("VS Code extension manifest", () => {
it("contributes Zero language support for .0 files", async () => {
const manifest = JSON.parse(await readFile("package.json", "utf8"));
const language = manifest.contributes?.languages?.find((entry) => entry.id === "zero");
const grammar = manifest.contributes?.grammars?.find((entry) => entry.language === "zero");
const snippets = manifest.contributes?.snippets?.find((entry) => entry.language === "zero");
assert.ok(language);
assert.deepEqual(language.extensions, [".0"]);
assert.equal(language.configuration, "./language-configuration/zero.json");
assert.ok(grammar);
assert.equal(grammar.scopeName, "source.zero");
assert.equal(grammar.path, "./syntaxes/zero.tmLanguage.json");
assert.ok(snippets);
assert.equal(snippets.path, "./snippets/zero.json");
});
it("ships snippets for main, type, fn, and test", async () => {
const snippets = JSON.parse(await readFile("snippets/zero.json", "utf8"));
assert.ok(snippets.main);
assert.ok(snippets.type);
assert.ok(snippets.function);
assert.ok(snippets.test);
});
it("highlights core Zero keywords and types", async () => {
const grammar = JSON.parse(await readFile("syntaxes/zero.tmLanguage.json", "utf8"));
const matches = Object.values(grammar.repository)
.flatMap((entry) => entry.patterns)
.map((pattern) => pattern.match ?? "")
.join("\n");
assert.match(matches, /fn/);
assert.match(matches, /raises/);
assert.match(matches, /type/);
assert.match(matches, /World/);
assert.doesNotMatch(matches, /Vercel|Request|Response/);
const declarationKeywords = grammar.repository.keywords.patterns.find(
(pattern) => pattern.name === "keyword.declaration.zero"
)?.match;
assert.match(declarationKeywords, /\|mut\|/);
});
it("highlights comments, strings, and numbers", async () => {
const grammar = JSON.parse(await readFile("syntaxes/zero.tmLanguage.json", "utf8"));
assert.equal(grammar.repository.comments.patterns[0].name, "comment.line.double-slash.zero");
assert.equal(grammar.repository.comments.patterns[1].name, "comment.block.zero");
assert.equal(grammar.repository.strings.patterns[0].name, "string.quoted.double.zero");
assert.equal(grammar.repository.numbers.patterns[0].name, "constant.numeric.zero");
});
});