internal/cuetxtar: add @test(allows, sel) directive
Add an `allows` directive that calls `cue.Value.Allows(sel)` to check
whether a selector is allowed by a struct value.
Syntax:
@test(allows, sel) // asserts Allows returns true
@test(allows=false, sel) // asserts Allows returns false
Supported selector forms:
foo or "foo" regular string field
#Def definition field
string any-string pattern (cue.AnyString)
int any-index pattern (cue.AnyIndex)
Negative tests are in TestRunAllowAssertion (inline_test.go),
calling runAllowAssertion directly with failCapture. Positive
end-to-end tests are in TestInlineRunner_Basic (inlinerunner_test.go).
The directive is documented in cue/testdata/readme.md and
doc/specs/inline-test-attributes/spec.md. A new test file
cue/testdata/inlinetest/closedness.txtar exercises the directive
against closed structs and definitions.
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I0126ee29c9f22ffc0d24028b58eb4a01573c472c
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1235351
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>