// SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC // SPDX-License-Identifier: Apache-2.0 // The site's own words (the home page, index.html, the README, docs/app.md, the library and the Quarto pages) say // what is held and no more: the claims ledger (pplus-core work/release/claims.md) found sentences that claimed more. // These tests hold the sentences that a test can hold, and keep the overstated ones from coming back. import test from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { installDocument } from '../dist/quarto/dom.js'; installDocument(); const store = new Map(); globalThis.localStorage = { getItem: (k) => store.get(k) ?? null, setItem: (k, v) => store.set(k, String(v)), removeItem: (k) => store.delete(k), key: (i) => [...store.keys()][i] ?? null, get length() { return store.size; } }; const { homeView } = await import('../dist/ui/home.js'); const { libraryView } = await import('../dist/ui/library.js'); const { DESCRIPTION } = await import('../dist/core/site.js'); const { AREAS } = await import('../dist/core/areas.js'); const { PROBLEMS, problemById, stateForProblem } = await import('../dist/core/catalog.js'); const { Session } = await import('../dist/core/session.js'); const { machineView } = await import('../dist/ui/views/panels.js'); const { generatedLabel } = await import('../dist/ui/provenance.js'); const read = (p) => readFileSync(new URL(`../${p}`, import.meta.url), 'utf8'); const squash = (s) => s.replace(/\s+/g, ' '); const home = homeView(); const homeText = squash(home.textContent); const html = read('index.html'); const meta = / { assert.match(DESCRIPTION, /^Programming\+ takes a procedure from an idea to Mojo to the machine\.$/); assert.ok(meta.startsWith(DESCRIPTION), 'the meta description starts with it'); assert.match(html, /Programming\+: from an idea to Mojo to the machine<\/title>/); const hero = squash(home.querySelector('.hero').textContent); assert.ok(hero.includes(DESCRIPTION), 'the hero says it'); const firstParagraph = (md) => md.split('\n\n').find((p) => !p.startsWith('#')); assert.ok(firstParagraph(read('README.md')).startsWith(DESCRIPTION), 'the README opens with it'); assert.ok(firstParagraph(read('docs/app.md')).startsWith(DESCRIPTION), 'docs/app.md opens with it'); }); test('each invented notation name is said what it is where the home page first uses it', () => { const gloss = { lingo: /plain[- ]English/i, matho: /equations/i, pseudo: /pseudocode/i, speco: /specification/i }; for (const [name, what] of Object.entries(gloss)) { const at = homeText.search(new RegExp(`\\b${name}\\b`)); assert.ok(at >= 0, `${name} is on the page`); const around = homeText.slice(Math.max(0, at - 80), at + 80); assert.match(around, what, `the first "${name}" is glossed: …${around}…`); } // the Bridge's tagline names them with what they are, and it is the first place on the page they appear assert.match(AREAS.bridge.tagline, /plain-English steps \(lingo\), equations \(matho\) or pseudocode \(pseudo\)/); }); test('the home page\'s samples are real runs: each card shows what the engines made as the page loaded', () => { const cards = home.querySelectorAll('.area-card'); assert.equal(cards.length, 3); const bridge = home.querySelector('.area-card-bridge'); assert.equal(bridge.querySelectorAll('.area-step').length, 4, 'matho, pseudo, lingo and Mojo'); for (const pre of bridge.querySelectorAll('pre')) assert.ok(pre.textContent.trim().length > 5, 'each notation has text'); const steps = home.querySelector('.area-card-dev').querySelectorAll('.feat-steps li'); assert.ok(steps.length >= 5, 'the first steps of count_base'); const regs = home.querySelector('.area-card-hw').querySelectorAll('.area-regs tr'); assert.equal(regs.length, 5, 'five registers of the machine at the first load'); assert.match(squash(home.querySelector('.proof-counts').textContent), /^[1-9]\d* proved ?0 broken ?0 open$/); }); test('every problem with Mojo has Mojo verified on the real compiler, as the problem list says', () => { assert.match(homeText, /each one with Mojo has a program verified on the real compiler/); const withMojo = PROBLEMS.filter((p) => p.mojo || p.sources.mojo); assert.ok(withMojo.length > 10); for (const p of withMojo) assert.ok(p.mojo?.verified, `${p.id}: verified on the pinned compiler`); }); test('where the Hardware area states a cost, it says it is the model machine\'s', () => { assert.match(homeText, /the cycles each instruction costs on the model machine/); assert.match(AREAS.hw.tagline, /model machine/); assert.match(meta, /Hardware steps its x86-64 on a model machine/); // the Counters card (the board, the machine embed, the Quarto pplus-machine view all draw it) const st = stateForProblem(problemById('asm-two-pointers')); st.lang = 'asm'; const root = document.createElement('div'); machineView(new Session(st), root)(); const text = squash(root.textContent); assert.match(text, /cycles/); assert.match(text, /a model machine: every count here is the model's, not a measurement of a real processor/); }); test('the generated label promises nothing a compiler did not answer', () => { const tip = generatedLabel('generated').getAttribute('title'); assert.doesNotMatch(tip, /\bIt runs\b/); assert.match(tip, /stops there with an error instead of guessing/); }); test('the overstatements the claims ledger found stay gone', () => { const surfaces = { 'home page': homeText, 'index.html': html, 'README.md': read('README.md'), 'AGENTS.md': read('AGENTS.md'), 'docs/app.md': read('docs/app.md'), 'docs/deploy.md': read('docs/deploy.md'), 'quarto/README.md': read('quarto/README.md'), 'library page': squash(libraryView().textContent), 'src/ui/quarto.ts': read('src/ui/quarto.ts'), }; const never = [ [/Everything runs in the browser/i, 'H1: Compile & run goes to godbolt.org'], [/checked against the real compiler/i, 'H2: held to its answers on the corpus, asked about the rest'], [/every step and every value in one Run view|every step and value in view|Every step, every value/i, 'H3: the interpreter reads a subset'], [/it runs and it can be compiled/i, 'H4'], [/completely specify any procedure|the notation is for any procedure/i, 'H5'], [/registers, caches and pipeline it runs on/i, 'H7'], [/It is built for the sciences/i, 'H8: an opinion'], [/every short input|the smallest input/i, 'H9, A12: every DNA string up to three letters; a smaller input'], [/The first group is computational biology/i, 'H10: the groups are by technique'], [/no runtime dependenc/i, 'R4, R19: CodeMirror is vendored'], [/gives `nan` in Mojo/i, 'A1: inf, -inf or nan'], [/a program that stops printing what it should fails the render/i, 'Q1: only with pplus-strict'], [/The prover is sound/i, 'A5: meant to be sound'], [/checked at every level/i, 'library: open, skipped and unverified checks exist'], [/interpreter are still JavaScript|typed only by their tests/i, "core's pseudo parser, checker and interpreter are strict TypeScript (core/src/engines/pseudo/*.ts)"], [/interpreter declines `chr`, `ord`|a string doubled in a loop/i, "core's Mojo interpreter runs ord and chr, and its run limits stop a doubled String (core/docs/limits.md)"], [/restructure plan|The plan said/i, 'a plan that is not in the repository'], [/labelled|colour|behaviour|optimis/i, 'US English'], ]; for (const [where, text] of Object.entries(surfaces)) for (const [re, why] of never) assert.doesNotMatch(text, re, `${where}: ${why}`); });