Skip to main content

Module eval

Module eval 

Source
Expand description

bynk eval (#3585): evaluate a snippet in a project’s context and report the value it ends in.

The snippet becomes the body of one case in a synthetic suite that targets a unit of the project, exactly as a doc example marked bynk test does (crate::doc_examples), so it sees what a suite for that unit sees: the unit’s declarations, its own consumes, and the stubs it declares. It is built and run by crate::test_runner::run_test under the test runtime, so no real capability is ever reached (a capability the snippet calls needs a stub). The case’s last expression is not discarded, as an ordinary case’s is: it is encoded as the wire shape Json.encode gives it and reported beside its type (lower_test_case_body_reporting in bynk-emit).

Stateless. Each evaluation is independent. A client that wants an earlier cell’s lets in scope sends them again ahead of the snippet.

Header. A suite’s consumes and stub clauses belong to the suite, not to a case, so the snippet’s leading consumes and stub lines (with the blank and // comment lines among them) are the suite’s, and the rest is the case’s body. A snippet uses what it needs from another unit by consumesing it, as a suite file does.

Line-preserving. The synthetic suite has the snippet’s lines, each on the line it has in the snippet; only the first line is longer, by the generated suite … { opening.

This is an explicit, local run of code the user wrote in their own workspace, at the trust level of bynk test. It does not overturn ADR 0638, which kept the refined-type explorer off the build-and-run path because a hover is an implicit request.

Structs§

EvalDiagnostic
One diagnostic of a snippet that does not check.
EvalError
A snippet that checked but ran to no value.
EvalReport
The result document bynk eval prints: {"value", "type", "diagnostics"}, and an error when the snippet ran to no value.
EvalRequest
What to evaluate, and where.

Enums§

EvalOutcome
What an evaluation produced.

Constants§

DEFAULT_TIMEOUT
How long an evaluation may run before it is killed, when the caller sets no limit of its own.
EVAL_CASE
The name of the synthetic case. bynk-driver lowers a case of this name with its tail reported, and the run selects it by this name.

Functions§

evaluate
Run request: the snippet’s value, or why there is none.
suite_text
The synthetic suite for snippet, targeting unit: the snippet’s own lines, with the suite and case openings added to the first and last header lines and the closers after the last line. Also how many characters the generated opening adds to the first line.