Manuscript Documentation
v2026.12.0

Testing and shipping#

The invoice rules are the part where a mistake costs money, so they get tests. A test block sits in the same file as the code, and ms test runs it.

totals.ms
import (
    check, ints, lists from "@std/test/property.ms",
    expect_equal from "@std/test/test.ms",
)

fn shipping(subtotal Int) Int {
    if subtotal >= 4000 {
        return 0
    }
    return 500
}

fn order_total(prices List[Int]) Int {
    subtotal := prices.sum()
    return subtotal + shipping(subtotal)
}

test "small orders pay shipping" {
    expect_equal(order_total([1250, 800]), 2550)?
}

test "big orders ship free" {
    expect_equal(order_total([2500, 2500]), 5000)?
}

test "the order of items never changes the total" {
    check(
        "any order",
        lists(ints(0, 5000), 0, 20),
        prices => expect_equal(
            order_total(prices.reversed()),
            order_total(prices),
        ),
    )?
}
text
3 tests, 0 failed

Save it as totals.ms and run ms test totals.ms.

What to notice#

  • A test is a block with a name. expect_equal(actual, expected)? fails it on a mismatch and prints both values.
  • The third test is a property test. check generates up to 100 lists of prices, runs the rule on each, and if one fails it shrinks it to a small counterexample with a seed you can replay.
  • ms test totals.ms --fuzz 30s keeps generating fresh cases for 30 seconds per property, which turns the same test into a fuzzer.

Ship it#

ms run and ms test use fast Cranelift Debug builds; ms build defaults to an optimized LLVM Release executable that runs without Manuscript installed:

sh
ms build ms.toml

ms check --test runs the checker, the formatter check, lint, and the tests and returns one exit code.

Next: Working with an agent . Exact rules: Testing and benchmarking , Build levels .