Skip to main content

Crate nanvm_harness

Crate nanvm_harness 

Source
Expand description

The MVP walking skeleton (todo/fjs-nanvm-integration.md, nanvm/lib/todo/mvp-roadmap.md): evaluate a compiled module, select one of its exports, read or call it, and print the result as JSON.

fjs run ./fjs/nanvm/harness/module.f.mjs (npm run gen) compiles each of fixtures/*.mjs into gen.fixtures/*.rs through the Rust code generator, named after its Rust module (function-scope.mjs becomes function_scope.rs), and writes gen.fixtures/mod.rs naming every one — committed and drift-checked (see ../../../fjs/ci/README.md) the same way nanvm/lib/tests/test/gen.corpus/ is. The directory is the list of fixtures: adding one is adding its .mjs. fixtures pulls them in with one #[path]: a gen. name is never a Rust identifier.

Modules§

expected
The expectation of each corpus fixture, gen.expected/*.rs, named by the generated gen.expected/mod.rs: the value of its default as a graph, and its JSON text where it has one, and CASES pairing each with its compiled fixture for check.
fixtures
The compiled fixtures, gen.fixtures/*.rs, named by the generated gen.fixtures/mod.rs; one #[path] names that file.

Structs§

Case
A corpus fixture and what it is expected to be, one row of the generated gen.expected/mod.rs.

Enums§

Action
What the harness does with the selected export.
RunError
Why a run produced no JSON.

Functions§

check
Runs both layers for one case: Ok when the compiled fixture is what its expectation says, or the first difference.
run
Evaluates a module once, selects one of its exports, reads or calls it, and renders that one value as JSON. Nothing else in the export object is called or serialized.
runtime
The runtime value every compiled module takes as its parameter, built once per run: nanvm_lib::vm::runtime, which cannot fail for the runtime the repository compiles.
same_graph
Whether two graphs are the same value, and, where they are not, the first difference found, with the path to it.

Type Aliases§

Module
A compiled module’s module: a function of the runtime value it is given, answering its export object or the throw its initialization ended in.