Move the engine core into core/, a project of its own (pplus-core)
What programs mean (the languages, translators, Mojo checker and
interpreter, prover, fuzzer, machine model, catalog problems and the Mojo
corpus with godbolt's stored answers) was mixed into the site's tree, so a
change to the prover and a change to a button went through the same gate
and the same docs. This moves all of it under core/, laid out as its own
repository, ready to be extracted with its history and pinned here as a
git submodule.
- core/: src/{engines,services,sync,mojo,exercises,curriculum,common},
mojo/, syntax/mojo.xml, its tests (with Workspace and workForProblem in
place of the site's Session), scripts (corpus pipeline, play, the
exercise and probe starters, engines export/diff), and its docs
(engines, trust, mojo-corpus, exercises, coverage). Its own pixi.toml,
package.json, README, AGENTS.md and CI workflow.
- core/tests/boundary.test.mjs: library modules use no DOM, import no
page widget, and import nothing outside src/.
- core/scripts/cli.mjs: pixi run cli check|run|prove|fuzz|translate.
- core/scripts/dafny.py: Dafny 4.11.0 pinned by version and SHA-256 per
platform, fetched into .tools/ (pixi run dafny-fetch, pixi run dafny).
- The site imports core only as #core/<path>.js: an import map in
index.html, "imports" in package.json for node, core's declarations for
tsc. The site's TypeScript builds core first (npm run build).
- assemble.sh, the Quarto engine copy, the render cache key, check-pages,
quarto-export and quarto-css read core/dist and core/mojo; quarto-css
copies core's syntax/mojo.xml into the extension.
- Site tests that covered engines moved to core; the rest keep Session.
- README, AGENTS.md, docs/app.md, docs/deploy.md and the CI workflow
describe the split (checkout with submodules; core's tests and corpus
status run against the pinned commit).
Gate: site 110 pass; core 307 pass; corpus status --strict passes.
Manual check: the assembled site opens Bridge (count-base-proved),
Developer and Hardware (count-base) with the editor, the stepper and the
board, and no module errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
This commit is contained in:
1567 files changed
+3670
-981
No files matched your search
@@ -0,0 +1,52 @@
|
||||
// DECLARE <name> : <type> <- <value>: one line that declares a name and gives it its starting value
|
||||
// (src/services/pseudo-study.ts). The two-line form still reads exactly as before.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { studyOf, runPseudo } from '../dist/services/pseudo.js';
|
||||
import { splitDeclareInits } from '../dist/services/pseudo-study.js';
|
||||
import { pseudoToMojo } from '../dist/sync/pseudo-to-mojo.js';
|
||||
import { checkMojo } from '../dist/mojo/check.js';
|
||||
|
||||
const fn = (decls) => `FUNCTION COUNT_BASE(B : CHAR, T : STRING) RETURNS INTEGER\n${decls}\n FOR I <- 0 TO N\n IF T[I] == B THEN\n Total <- Total + 1\n ENDIF\n NEXT I\n RETURN Total\nENDFUNCTION\n`;
|
||||
const ONE = fn(' DECLARE N : INTEGER <- LENGTH(T)\n DECLARE Total : INTEGER <- 0');
|
||||
const TWO = fn(' DECLARE N : INTEGER\n N <- LENGTH(T)\n DECLARE Total : INTEGER\n Total <- 0');
|
||||
const CALL = `COUNT_BASE('A', "GATTACA")`;
|
||||
|
||||
test('the value is blanked out of the line with its columns kept, and found apart from strings and comments', () => {
|
||||
const { source, inits } = splitDeclareInits('DECLARE S : STRING <- "x <- y" // a <- b\nDECLARE N : INTEGER');
|
||||
assert.equal(source.split('\n')[0].length, 'DECLARE S : STRING <- "x <- y" // a <- b'.length);
|
||||
assert.equal(source.split('\n')[0], `DECLARE S : STRING ${' '.repeat(12)}// a <- b`);
|
||||
assert.deepEqual(inits.map((i) => [i.line, i.names, i.value, i.valueCol]), [[1, ['S'], '"x <- y"', 23]]);
|
||||
});
|
||||
|
||||
test('one line and two lines read, run, and answer the same, with no diagnostics', () => {
|
||||
for (const src of [ONE, TWO]) {
|
||||
const st = studyOf(src);
|
||||
assert.ok(st.ok);
|
||||
assert.deepEqual(st.diagnostics.filter((d) => d.severity !== 'note'), []);
|
||||
assert.deepEqual(runPseudo(st, { call: CALL }).output, ['COUNT_BASE returned 3']);
|
||||
}
|
||||
});
|
||||
|
||||
test('the run shows the declaration and its starting value as steps of the same line', () => {
|
||||
const tr = runPseudo(studyOf(ONE), { call: CALL });
|
||||
assert.deepEqual(tr.steps.filter((s) => s.line === 2).map((s) => s.text), ['N is INTEGER, with no value yet.', 'N becomes 7.']);
|
||||
});
|
||||
|
||||
test('the Mojo is var x: T = value for the one-line form, and stays two lines for the two-line form', () => {
|
||||
const one = pseudoToMojo(ONE, { call: CALL }).source;
|
||||
assert.match(one, /^ {4}var n: Int = t\.count_codepoints\(\)$/m);
|
||||
assert.match(one, /^ {4}var total: Int = 0$/m);
|
||||
assert.doesNotMatch(one, /^ {4}n = /m);
|
||||
assert.deepEqual(checkMojo(one).diagnostics.filter((d) => d.severity === 'error'), []);
|
||||
const two = pseudoToMojo(TWO, { call: CALL }).source;
|
||||
assert.match(two, /^ {4}var n: Int\n {4}n = t\.count_codepoints\(\)$/m);
|
||||
});
|
||||
|
||||
test('a mistake in the form says what the form is', () => {
|
||||
const msg = (src) => studyOf(src + '\n').diagnostics.filter((d) => d.severity === 'error').map((d) => d.message).join(' | ');
|
||||
assert.match(msg('DECLARE A, B : INTEGER <- 0'), /names one variable/);
|
||||
assert.match(msg('DECLARE A : INTEGER <-'), /nothing on the right of its arrow/);
|
||||
assert.match(msg('DECLARE A <- 3'), /needs its type before a starting value/);
|
||||
assert.match(msg('DECLARE A : INTEGER <- "x"'), /INTEGER values, and "x" is a STRING/);
|
||||
});
|
||||
Reference in new issue
Block a user