🎉 initial commit

This commit is contained in:
2025-09-20 20:44:24 +08:00
commit 82538addcc
19 changed files with 483 additions and 0 deletions

35
test_deno/deno.test.ts Normal file
View File

@@ -0,0 +1,35 @@
import init, { format } from "../pkg/rust_fmt.js";
import { assertEquals } from "jsr:@std/assert";
import { walk } from "jsr:@std/fs/walk";
import { relative } from "jsr:@std/path";
await init();
const update = Deno.args.includes("--update");
const test_root = new URL("../test_data", import.meta.url);
for await (const entry of walk(test_root, {
includeDirs: false,
exts: ["rs"],
})) {
if (entry.name.startsWith(".")) {
continue;
}
const input = Deno.readTextFileSync(entry.path);
if (update) {
const actual = format(input);
Deno.writeTextFileSync(entry.path + ".snap", actual);
} else {
const test_name = relative(test_root.pathname, entry.path);
const expected = Deno.readTextFileSync(entry.path + ".snap");
Deno.test(test_name, () => {
const actual = format(input);
assertEquals(actual, expected);
});
}
}