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

+7 -7
View File
@@ -1,5 +1,5 @@
// Programming+'s Mojo interpreter, judged against the real compiler: for every program godbolt
// compiled and ran (mojo/golden), the interpreter either declines ("cannot run this yet") or
// compiled and ran (library/mojo/golden), the interpreter either declines ("cannot run this yet") or
// prints exactly what godbolt's run printed and ends the same way. It never disagrees.
import test from 'node:test';
import assert from 'node:assert/strict';
@@ -10,17 +10,17 @@ import { runMojo } from '../dist/mojo/interp.js';
const R = new URL('..', import.meta.url).pathname;
const read = (p) => JSON.parse(fs.readFileSync(R + p, 'utf8'));
const verdicts = new Map(read('mojo/golden/status.json').items.map((r) => [r.id, r]));
const golden = (key) => key && fs.existsSync(`${R}mojo/golden/${key}.json`) ? read(`mojo/golden/${key}.json`) : null;
const verdicts = new Map(read('library/mojo/golden/status.json').items.map((r) => [r.id, r]));
const golden = (key) => key && fs.existsSync(`${R}library/mojo/golden/${key}.json`) ? read(`library/mojo/golden/${key}.json`) : null;
const run = (src, input = []) => runMojo(parseModule(src), src, { input, maxSteps: 200000 });
const AGREE_AT_LEAST = 203; // raise as the interpreter learns more (3a: 171, 4a: 180, 4b: 182, 4c: 191, 7a: 201, 7b: 203)
test('the interpreter never disagrees with godbolt, and agrees on at least the ratchet', () => {
const programs = [];
for (const [dir, mf] of [['quest', 'quest'], ['manual', 'manual']]) for (const it of read(`mojo/corpus/${mf}/manifest.json`).items) programs.push([it.id, `mojo/corpus/${dir}/${it.file}`]);
for (const f of fs.readdirSync(R + 'mojo/probes')) programs.push([`probes/${f.replace('.mojo', '')}`, `mojo/probes/${f}`]);
for (const f of fs.readdirSync(R + 'mojo/local')) programs.push([`local/${f.replace('.mojo', '')}`, `mojo/local/${f}`]);
for (const f of fs.readdirSync(R + 'mojo/stress')) programs.push([`stress/${f.replace('.mojo', '')}`, `mojo/stress/${f}`]);
for (const [dir, mf] of [['quest', 'quest'], ['manual', 'manual']]) for (const it of read(`library/mojo/corpus/${mf}/manifest.json`).items) programs.push([it.id, `library/mojo/corpus/${dir}/${it.file}`]);
for (const f of fs.readdirSync(R + 'library/mojo/probes')) programs.push([`probes/${f.replace('.mojo', '')}`, `library/mojo/probes/${f}`]);
for (const f of fs.readdirSync(R + 'library/mojo/local')) programs.push([`local/${f.replace('.mojo', '')}`, `library/mojo/local/${f}`]);
for (const f of fs.readdirSync(R + 'library/mojo/stress')) programs.push([`stress/${f.replace('.mojo', '')}`, `library/mojo/stress/${f}`]);
const disagree = []; let agree = 0;
for (const [id, file] of programs) {
const g = golden(verdicts.get(id)?.key);