feat: move corpus to library
Test / test (push) Failing after 1m38s

This commit is contained in:
alexm committed 2026-10-06 10:27:46 -04:00
1 parent 5b8b079165
commit cae5cff55a
1350 files changed
+197 -941995

No files matched your search

+5 -5
View File
@@ -45,7 +45,7 @@ test('each rule\'s example: both programs read, run, and print the same; the rul
});
test('grounding: every standard-library method a rewrite names is in the harvested index', () => {
const index = JSON.parse(fs.readFileSync(path.join(root, 'mojo', 'corpus', 'stdtypes', 'stdtypes.json'), 'utf8')).structs;
const index = JSON.parse(fs.readFileSync(path.join(root, 'library', 'mojo', 'corpus', 'stdtypes', 'stdtypes.json'), 'utf8')).structs;
let n = 0;
for (const r of RULES) for (const [type, method] of r.apis) { n++; assert.ok(index[type]?.methods.includes(method), `${r.id}: ${type}.${method}`); }
assert.ok(n >= 4);
@@ -63,8 +63,8 @@ function mojoFiles(dir, out = []) {
// (a variable declared apart from its value to show how `var` works, `imm` written out to name the convention). Each
// number is a reviewed count; a rule that starts firing more than this on code that is already good is too noisy.
const ALLOWED = { 'declare-then-assign': 10, 'augmented-assign': 6, 'argument-convention': 4, 'unneeded-raises': 3, 'comptime-constant': 3, 'codepoint-loop': 0, 'reserve': 2, 'transfer-last-use': 2, 'explicit-copy': 0 };
test('false-positive gate: over mojo/corpus/manual/ the rules fire no more than the reviewed allowlist', () => {
const files = mojoFiles(path.join(root, 'mojo', 'corpus', 'manual'));
test('false-positive gate: over library/mojo/corpus/manual/ the rules fire no more than the reviewed allowlist', () => {
const files = mojoFiles(path.join(root, 'library', 'mojo', 'corpus', 'manual'));
assert.ok(files.length >= 100, `${files.length} programs`);
const counts = {};
for (const f of files) for (const x of findPractices(fs.readFileSync(f, 'utf8'))) counts[x.rule] = (counts[x.rule] ?? 0) + 1;
@@ -112,8 +112,8 @@ test('idiomatic version: for every exercise the safe rewrites keep the program c
assert.ok(changed >= 5 && compared >= 5, `${changed} changed, ${compared} compared`);
});
test('Developer area: applying every fix to each mojo/local program keeps it checking and printing the same', () => {
const dir = path.join(root, 'mojo', 'local');
test('Developer area: applying every fix to each library/mojo/local program keeps it checking and printing the same', () => {
const dir = path.join(root, 'library', 'mojo', 'local');
let fired = 0;
for (const f of fs.readdirSync(dir).filter((x) => x.endsWith('.mojo'))) {
const src = fs.readFileSync(path.join(dir, f), 'utf8');