Documentation
¶
Overview ¶
Package lezertest checks a port against what the real Lezer gives: the goldens internal/lezer/gen/golden.mjs writes, one per fixture.
Index ¶
- Constants
- func Apply(units []uint16, edits []Edit) ([]uint16, []lezer.ChangedRange)
- func CompareLines(t *testing.T, got, want []string)
- func Describe(tree *lezer.Tree, text []uint16) []string
- func MatchCorpus(t *testing.T, p *lezer.Parser, grammar string)
- func MatchGoldens(t *testing.T, p *lezer.Parser, dir string)
- func MatchIncremental(t *testing.T, p *lezer.Parser, dir string)
- type Edit
- type Session
Constants ¶
const CorpusEnv = "LEZER_INCREMENTAL_CORPUS"
CorpusEnv names the directory of a randomized edit corpus written by gen/incremental.mjs, too big for the repository: one subdirectory of sessions and goldens per grammar. MatchCorpus skips when it is unset.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(units []uint16, edits []Edit) ([]uint16, []lezer.ChangedRange)
Apply makes the edits, in order and not overlapping, to units, and returns the result with the ChangedRanges they are.
func CompareLines ¶
CompareLines fails at the first line where got and want differ, then on a difference in their length.
func Describe ¶
Describe is what golden.mjs writes for tree, parsed from text: the tree, then its spans.
func MatchCorpus ¶
MatchCorpus is MatchIncremental over the subdirectory grammar of the corpus CorpusEnv names, reporting how many sessions and parses it checked and at how many steps Lezer's incremental parse highlights otherwise than a fresh one.
func MatchGoldens ¶
MatchGoldens parses and highlights every fixture in dir that has a .golden next to it, each in its own subtest, and fails at the first line that differs from it. A dir with no goldens fails: it is a mistyped path, not a pass.
func MatchIncremental ¶
MatchIncremental runs every session in dir that has a .golden next to it, each in its own subtest, and fails at the first parse whose tree, layout or spans, or the spans of a fresh parse of the same text, differ from what the real Lezer gave. A dir with no goldens fails.