Skip to content

65 Tests ​

@Test associates doublesSeven with double.function. require checks the behavior; norm test discovers and runs the test separately.

norm
import std.testing.Test

Integer double(Integer number) {
  return number * 2
}

@Test(functions: [double.function])
Void doublesSeven() {
  require(condition: double(number: 7) == 14, message: "doubles seven")
}

main() {
  printLine(double(number: 7))
}

Expected output:

text
14

Run the test from the repository root:

sh
norm test norm/tests/docs/tour/testing.norm --format json

The JSON result reports one discovered and one passing test.

Try it: Change expected value 14 to 15 and run norm test to inspect the failure.

Precise rules: Reference.

Norm 0.25