A scripting language for people who enjoy the simpler things in life.

Version 0.9.35

Unit Tests

Pyro has builtin support for unit tests using the test command:

$ pyro test --help

Usage: pyro test [files]

  This command runs unit tests. Each input file is
  executed in a new VM instance.

  [files]              Files to test.

  -h, --help           Print this help text and exit.
  -v, --verbose        Show error output.

Specify a single file to test:

$ pyro test script.pyro

Specify multiple files to test:

$ pyro test *.pyro

Test Functions

For each input file specified, Pyro first executes the file, then runs any test functions it contains, i.e. functions whose name begins with $test_. A test function passes if it executes without panicking.

You can use an assert statement to make a test function panic if the test fails, e.g.

def $test_addition() {
    assert 1 + 2 == 3;

The syntax is:

assert <expression>;

An assert statement passes if its operand expression evaluates as truthy or fails if it evaluates as falsey.

(In Pyro, the values false, null, and err are falsey; all other values are truthy.)

Note that test functions take no arguments.

Module-Level Tests

You don't need to use test functions for simple tests — you can put assert statements at global-scope in a file, e.g.

assert "foo" + "bar" == "foobar";

The test command will register the file as passing if it executes without panicking, or as failing if any of the assert statements at global-scope fail.