LearnAdvanced formsTesting and running

Testing and running

Check files and run package tests.

Tests turn examples into promises. A small test says what should keep working.

let Testing := import "@std/testing";

export let test () :=
  Testing.it("adds values", Testing.toBe(1 + 2, 3));

Run checks often while learning. A check gives fast feedback before a mistake spreads through many files.

music check index.ms
musi check
musi test

Use one-file checks for small experiments. Use package checks and tests when code has imports, exports, or test files.

A good test is like a receipt. It records what you expected, so you can compare it later.

Check before run

Use checks to catch syntax and type problems before runtime behavior matters.

let total := 42;
total;

A check should prove that names resolve, types line up, and expressions have the expected shape.

Test behavior

Write small checks around public functions and rules.

let choosePort (configured : Int) : Int := configured;

let keepsConfiguredPort := choosePort(8080) = 8080;

Keep checks small. One check should explain one behavior.