v0.1.0 28f9d6e

fromjson_errors.mjs RawHistoryFolder

1// SPDX-License-Identifier: MIT
2//
3// Writes testdata/fromjson_errors.json: for the inputs of testdata/fromjson_cases.json
4// that the runner's fromJSON rejects, plus a few hand-picked ones (blank input, a
5// bad character on a later line or deep in a document), the message of the
6// JsonReaderException. TestFromJSONErrorsMatchRunner replays it.
7//
8//   node expr/gen/runner/fromjson_errors.mjs > expr/testdata/fromjson_errors.json
9//
10// Needs the built driver, see README.md.
11
12import { readFileSync, writeFileSync, mkdtempSync, rmSync } from "node:fs";
13import { tmpdir } from "node:os";
14import { join } from "node:path";
15import { runDriver, here, checkEnvironment } from "./env.mjs";
16
17checkEnvironment();
18const cases = JSON.parse(readFileSync(join(here, "../../testdata/fromjson_cases.json"), "utf8"));
19const extra = [
20  "", "   ", "\n", "not json", "  not json", "\nnot json", "[x]", "[1,x]", '{"a":x}', "[\n  x]", '{"a b":x}', '{"a.b":[1,x]}',
21  "{\"it's\":x}", '{"a":{"b":[1,2,x]}}', "[[x]]", "{", "[", "[1,2", '{"a":1', '"abc', "{'a'}", "[1 2]", '{"a":1 "b":2}',
22  "tru", '{"k":tru}', '"\\q"', "[1,\n2,\n x]", " \n x", '{"a":\n\n  [1,\n  x]}',
23];
24const inputs = [...new Set([...cases.filter(c => !c.ok).map(c => c.in), ...extra])];
25const lit = s => "'" + s.replaceAll("'", "''") + "'";
26const tmp = mkdtempSync(join(tmpdir(), "fje-"));
27writeFileSync(join(tmp, "in.json"), JSON.stringify({ contexts: {}, cases: inputs.map(s => ({ e: `fromJSON(${lit(s)})` })) }));
28const out = runDriver([join(tmp, "in.json")]).split("\n").filter(Boolean);
29rmSync(tmp, { recursive: true });
30if (out.length !== inputs.length) throw new Error("answer count");
31const res = [];
32inputs.forEach((s, i) => {
33  const r = JSON.parse(out[i]);
34  if (r.err && r.err.t === "eval") res.push({ in: s, msg: r.err.m });
35});
36process.stdout.write(JSON.stringify(res));

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 3

↑↓ moveenter openesc close