v0.1.0 28f9d6e

runner_strict_test.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package expr
4
5import (
6	"encoding/json"
7	"sort"
8	"testing"
9)
10
11// knownRunnerDifference classifies the answers of the corpus on which this
12// package knowingly differs from the runner. It returns the reason, or "".
13// There is none left: negative zero is written "-0" like the legacy engine.
14func knownRunnerDifference(g, r runnerCase) string { return "" }
15
16// TestRunnerOracle holds the package to the answers of the runner's own code on
17// the 34 765 expressions of the oracle corpus: same result kind, string form
18// and toJSON text, same error phase and kind (the error texts of the runner's
19// Json.NET are not reproduced).
20func TestRunnerOracle(t *testing.T) {
21	of, ctxValues, ctxNames := loadOracle(t)
22	rf := loadRunner(t)
23	if len(rf.Cases) != len(of.Cases) {
24		t.Fatalf("runner answers %d cases, oracle has %d", len(rf.Cases), len(of.Cases))
25	}
26	t.Logf("runner: %s @ %s, %s", rf.Reference.Source, rf.Reference.Commit, rf.Reference.Runtime)
27	ec := EvalContext{Contexts: ctxValues, Funcs: oracleFuncs, MaxResultBytes: -1}
28	known := map[string]int{}
29	failures := 0
30	for i, rc := range rf.Cases {
31		if rc.E != of.Cases[i].E {
32			t.Fatalf("case %d: runner expression %q, oracle %q", i, rc.E, of.Cases[i].E)
33		}
34		g := goAnswer(rc.E, ctxNames, ec)
35		if sameAnswer(g, rc) {
36			continue
37		}
38		if reason := knownRunnerDifference(g, rc); reason != "" {
39			known[reason]++
40			continue
41		}
42		failures++
43		if failures <= 30 {
44			gj, _ := json.Marshal(g)
45			rj, _ := json.Marshal(rc)
46			t.Errorf("%q:\n  go     %s\n  runner %s", clip(rc.E), gj, rj)
47		}
48	}
49	reasons := make([]string, 0, len(known))
50	for k := range known {
51		reasons = append(reasons, k)
52	}
53	sort.Strings(reasons)
54	for _, k := range reasons {
55		t.Logf("known difference from the runner (%d cases): %s", known[k], k)
56	}
57	t.Logf("%d cases, %d failures", len(rf.Cases), failures)
58	if failures > 0 {
59		t.Fatalf("%d mismatches with the runner", failures)
60	}
61}

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