Skip to content
Xen / docs

Search documentation

English · v0.1.0-demo.2

Type to search the documentation.

    한국어
    Xen / examples v0.1.0-demo.2

    Test a function

    Test a function

    Run from the repository or distribution root. Put xen on PATH, or substitute ./bin/xen.

    Terminal window
    xen test examples/testing.xen
    PASS testing.doubles_a_number
    PASS testing.empty_vector
    2 passed; 0 failed
    testing.xen
    // SPDX-License-Identifier: MIT OR Apache-2.0
    fn 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");
    }

    Download file