1350 files changed
+197
-941995
No files matched your search
+9
-9
@@ -1,4 +1,4 @@
|
||||
// The Mojo corpus as the app sees it: the generated modules agree with mojo/pin.json
|
||||
// The Mojo corpus as the app sees it: the generated modules agree with library/mojo/pin.json
|
||||
// and the harvested corpus, and the Python pipeline's own tests pass.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
@@ -9,9 +9,9 @@ import { MOJO_KEYWORDS, MOJO_SOFT_KEYWORDS, MOJO_REMOVED_WORDS, MOJO_DECORATORS,
|
||||
import { Workspace } from '../dist/common/workspace.js';
|
||||
import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js';
|
||||
|
||||
const pin = JSON.parse(fs.readFileSync(new URL('../mojo/pin.json', import.meta.url), 'utf8'));
|
||||
const pin = JSON.parse(fs.readFileSync(new URL('../library/mojo/pin.json', import.meta.url), 'utf8'));
|
||||
|
||||
test('the generated pin is mojo/pin.json', () => {
|
||||
test('the generated pin is library/mojo/pin.json', () => {
|
||||
assert.equal(MOJO_VERSION, pin.mojo.version);
|
||||
assert.equal(GODBOLT_BASE, pin.godbolt.base);
|
||||
assert.equal(GODBOLT_COMPILER, pin.godbolt.compiler);
|
||||
@@ -37,7 +37,7 @@ test('the corpus pipeline tests pass (python3)', { skip: py.status !== 0 ? 'pyth
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Stage 1: the Mojo pane. Wherever possible these use godbolt's real answers
|
||||
* (mojo/golden), so they test against what the compiler said, not what we assume.
|
||||
* (library/mojo/golden), so they test against what the compiler said, not what we assume.
|
||||
* ------------------------------------------------------------------------- */
|
||||
import { tokenizeMojo } from '../dist/mojo/tokenize.js';
|
||||
import { removedSyntax } from '../dist/mojo/check.js';
|
||||
@@ -50,8 +50,8 @@ import { parseModule } from '../dist/mojo/parse.js';
|
||||
import { MOJO_PROGRAMS } from '../dist/mojo/generated/programs.js';
|
||||
|
||||
const ROOT = new URL('..', import.meta.url).pathname;
|
||||
const goldens = fs.readdirSync(new URL('../mojo/golden/', import.meta.url)).filter((f) => /^[0-9a-f]{64}\.json$/.test(f))
|
||||
.map((f) => JSON.parse(fs.readFileSync(new URL(`../mojo/golden/${f}`, import.meta.url), 'utf8')));
|
||||
const goldens = fs.readdirSync(new URL('../library/mojo/golden/', import.meta.url)).filter((f) => /^[0-9a-f]{64}\.json$/.test(f))
|
||||
.map((f) => JSON.parse(fs.readFileSync(new URL(`../library/mojo/golden/${f}`, import.meta.url), 'utf8')));
|
||||
/** godbolt's answer for one corpus item, rebuilt as the raw JSON the browser receives. */
|
||||
function answerFor(item) {
|
||||
const g = goldens.find((x) => x.firstItem === item);
|
||||
@@ -59,7 +59,7 @@ function answerFor(item) {
|
||||
const source = (a) => a.line ? { line: a.line, ...('file' in a ? { file: a.file } : {}), ...('main' in a ? { mainsource: a.main } : {}) } : null;
|
||||
return { golden: g, raw: { ...g.raw, asm: (g.result.asm || []).map((a) => ({ text: a.text, source: source(a) })) } };
|
||||
}
|
||||
const sourceOf = (item) => fs.readFileSync(new URL(`../mojo/${item.replace('probes/', 'probes/')}.mojo`, import.meta.url), 'utf8');
|
||||
const sourceOf = (item) => fs.readFileSync(new URL(`../library/mojo/${item.replace('probes/', 'probes/')}.mojo`, import.meta.url), 'utf8');
|
||||
function applyFix(src, f) {
|
||||
const lines = src.split('\n'); const l = lines[f.line - 1];
|
||||
lines[f.line - 1] = l.slice(0, f.col - 1) + f.text + l.slice(f.endCol == null ? l.length : f.endCol - 1);
|
||||
@@ -68,7 +68,7 @@ function applyFix(src, f) {
|
||||
const kinds = (line) => tokenizeMojo(line)[0].filter((t) => t.cls).map((t) => `${t.cls.replace('tok-', '')}:${t.text}`);
|
||||
|
||||
test('highlighting agrees with the Mojo grammar\'s own tests', () => {
|
||||
const { cases } = JSON.parse(fs.readFileSync(new URL('../mojo/corpus/syntax/cases.json', import.meta.url), 'utf8'));
|
||||
const { cases } = JSON.parse(fs.readFileSync(new URL('../library/mojo/corpus/syntax/cases.json', import.meta.url), 'utf8'));
|
||||
assert.ok(cases.length >= 20);
|
||||
for (const c of cases) {
|
||||
const toks = tokenizeMojo(c.text)[0];
|
||||
@@ -216,7 +216,7 @@ test('each exercise\'s Mojo prints, in the interpreter, what the exercise expect
|
||||
});
|
||||
|
||||
test('the Compile button builds with exactly the flags a passing probe verified', () => {
|
||||
const text = fs.readFileSync(new URL('../mojo/probes/godbolt-compile-button.mojo', import.meta.url), 'utf8');
|
||||
const text = fs.readFileSync(new URL('../library/mojo/probes/godbolt-compile-button.mojo', import.meta.url), 'utf8');
|
||||
const args = /^# args: (.*)$/m.exec(text)[1].trim();
|
||||
assert.equal(BUILD_ARGS.O0, args, 'change the probe and re-verify before changing the button');
|
||||
const g = goldens.find((x) => x.firstItem === 'probes/godbolt-compile-button');
|
||||
|
||||
Reference in new issue
Block a user