Initial commit
Build, test, deploy / site (push) Failing after 15m13s

This commit is contained in:
alexm committed 2026-11-12 22:24:02 -05:00
commit e092cb029c
252 files changed
+35037

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
// SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
// SPDX-License-Identifier: Apache-2.0
// The library page (#/library, src/ui/library.ts) and a library routine opened in the Bridge (src/core/library.ts):
// every routine of core's registry is listed with its checks, and opens as a problem that runs.
import test from 'node:test';
import assert from 'node:assert/strict';
import { installDocument } from '../dist/quarto/dom.js';
installDocument();
const { parseRoute, routeFor } = await import('../dist/core/state.js');
const { libraryModules, libraryState, checksOf, tally, LIBRARY_PREFIX } = await import('../dist/core/library.js');
const { Session } = await import('../dist/core/session.js');
test('routes: #/library and #/library/<id>, and a routine opens under the problem id lib:<id>', () => {
assert.deepEqual(parseRoute('#/library'), { kind: 'library' });
assert.deepEqual(parseRoute('#/library/md.LennardJones'), { kind: 'library', id: 'md.LennardJones' });
assert.equal(routeFor({ kind: 'library', id: 'md.LennardJones' }), '#/library/md.LennardJones');
assert.deepEqual(parseRoute('#/bridge/p/lib:md.LennardJones'), { kind: 'problem', area: 'bridge', id: 'lib:md.LennardJones' });
assert.equal(libraryState('lib:md.NoSuch'), null);
assert.equal(libraryState('count-base'), null);
});
test('every routine opens in the Bridge with its pseudo and its first case, and runs to that case\'s result', () => {
let n = 0;
for (const m of libraryModules()) for (const r of m.routines) {
n++;
const st = libraryState(`${LIBRARY_PREFIX}${r.id}`);
assert.equal(st.sources.pseudo, r.source);
assert.equal(st.call, r.cases[0].call);
const session = new Session(st, { area: 'bridge' });
const tr = session.trace('pseudo');
assert.equal(tr.error, null, `${r.id}: ${tr.error?.message}`);
assert.equal(tr.output.at(-1), `${r.name} returned ${r.cases[0].result}`, r.id);
// stepping into the routine is the point of opening it: its own lines are in the run
assert.ok(tr.steps.some((s) => s.line > 1 && s.kind !== 'call'), `${r.id}: the run shows none of the routine's lines`);
}
assert.ok(n >= 16);
});
test('the page lists every routine with its checks, and each routine\'s page shows its source, cases, references and checks', async () => {
const { libraryView } = await import('../dist/ui/library.js');
const index = libraryView();
const text = index.textContent;
for (const m of libraryModules()) {
assert.ok(text.includes(m.title), m.title);
for (const r of m.routines) assert.ok(text.includes(r.name), r.id);
}
const r = libraryModules().find((m) => m.name === 'md').routines.find((x) => x.name === 'LennardJones');
const page = libraryView(r.id);
const t = page.textContent;
assert.ok(t.includes('Open in the Bridge'));
assert.ok(t.includes(`USE ${r.id}`));
for (const c of r.cases) assert.ok(t.includes(c.call) && t.includes(c.result), c.call);
for (const ref of r.references) assert.ok(t.includes(`${ref.lang} · ${ref.level}`), `${ref.lang}/${ref.level}`);
assert.equal(page.querySelectorAll('.lib-chip').length >= checksOf(r).length, true);
assert.ok(libraryView('md.NoSuch').textContent.includes('No such routine'));
const t2 = tally(r);
assert.equal(t2.fail, 0);
});