Xen / examples v0.1.0-demo.2
Test a function
This topic is not available in the selected language or version. Showing the start of this section.
Test a function
Run from the repository or distribution root. Put xen on PATH, or substitute ./bin/xen.
xen test examples/testing.xenExpected output
Section titled “Expected output”PASS testing.doubles_a_numberPASS testing.empty_vector2 passed; 0 failedComplete source
Section titled “Complete source”// SPDX-License-Identifier: MIT OR Apache-2.0fn doubled(value: Int) -> Int { return value * 2;}
test fn doubles_a_number() { assert(doubled(3) == 6);}
test fn empty_vector() { let values: Vec<Int> = []; assert_msg(values.len() == 0, "an empty vector has no items");}