Test an invoice and packing calculation
The suite checks a decimal invoice total and a whole-box count, then records an offline printer as a skip. Change the expected box count to see the process exit with status 1.
Download the standalone example
Extract the archive and run wren-demo.exe on Windows or ./wren-demo on Linux and macOS. Each archive includes the Blyx source and tests.
Build from source
With Blyx 0.2.1, Rust and a host linker installed, run these commands to edit and rebuild the example.
git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-wren.git cd blyx-wren blyxc native-run project.blyx
Why this framework exists
A test that only prints an error can leave a build green. TAP defines a machine-readable result for each check and a plan stating how many results to expect. Wren couples that output to the number of failures. Test Anything Protocol, TAP 13 specification
Install Wren in your editor
Extension RahulChaube.blyx-wren · 0.1.0
The extension includes a runnable Blyx example, function completions and the framework source. For the modular project, extract the starter, open its folder and run blyxc native-run main.blyx with the native toolchain installed.
Create an empty .blyx file, type blyx-wren-demo and accept the completion. Choose Blyx: Run File to run the example.
For an offline installation, choose Extensions: Install from VSIX for Blyx Language first, then for Wren.
Download the companion Blyx Language VSIXInstall with Conda
Create an environment containing Wren 0.1.0, its Blyx source and a runnable example. Run the second command with Blyx 0.2.1, Rust and a host linker installed.
conda create -y --prefix ./blyx-env --override-channels -c https://rahulchaube1.github.io/blyx-packages blyx-wren=0.1.0=0 blyxc native-run ./blyx-env/share/blyx/wren/main.blyx
To use this package in your application, copy share/blyx/wren/vendor/wren from the environment into your project's vendor directory.
Import into a Blyx project
Install Blyx 0.2.1, Rust 1.85 or newer and a host linker. From the directory containing your entry file, clone this tagged release.
git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-wren.git vendor/wren
Save this as main.blyx beside vendor and run blyxc native-run main.blyx.
use vendor::wren::wren;
fn main() {
let first = wr_record(wr_start(), wr_near(0.1 + 0.2, 0.3, 0.000001, 0.0), false);
let second = wr_record(first, false, true);
let result = wr_record(second, 2 * 2 == 5, false);
println!(at(result, 0));
println!(at(result, 1));
println!(at(result, 2));
println!(wr_exit(result));
}Expected output
3 1 1 1
API and input requirements
Start with wr_begin, pass the returned suite to each check or skip, then call process_exit(wr_end(suite)). The producer emits a trailing TAP plan. Names are truncated at a line break or # to keep the stream unambiguous. Relative tolerance ranges from zero to one. Inputs for measurements and tolerances must be finite.
| API | Use |
|---|---|
wr_begin(), wr_check(suite, passed, label) | Import tap. Start a TAP stream and record numbered checks. |
wr_skip(suite, label, detail), wr_end(suite) | Declare a skip and finish with a plan. wr_end returns 1 when a check failed. |
wr_near(actual, expected, absolute, relative) | Compare using the larger of an absolute tolerance and a tolerance scaled by the larger input magnitude. |
wr_start(), wr_record(suite, passed, skipped), wr_exit(suite) | Track total, failed and skipped cases without writing TAP output. |
Develop and contribute
Open the tagged source to read the implementation and examples. Include the smallest reproducible Blyx program, compiler version and expected result when reporting an issue.
