bynk.val.outside_test
Error Val[T] was used outside a test case body.
Val[T] fabricates a value that merely satisfies T. That is what a test wants and what running code must not do, so Val is allowed only in test code. In a function or handler, take the value as a parameter or build it properly, for instance with Age.of(20). See bynk.val.needs_pin for a bare Val that a test cannot generate.
Example
type Age = Int where InRange(0, 150)
fn sample() -> Age { Val[Age] } // ✗ not test code
// tests/ages.test.bynklet a = Val[Age] // ✓ in a caseIn the Book
- Testing › Val[T] — value fabrication
- Testing › @example — a value for a pattern
- Testing
- Write tests, stub collaborators, and pin a `Val[T]`
See also
- The grammar rule it governs:
val_expr. - Every code in its category, Value fabrication, on the diagnostic index.
bynk explain bynk.val.outside_testshows the same from the installed toolchain, without a network.