testbldr

Types

A test has a name and a body (a function which returns a TestOutcome)

pub type Test =
  #(String, fn() -> TestOutcome)

A test can either pass or fail with a given reason

pub type TestOutcome {
  Pass
  Fail(msg: String)
}

Constructors

  • Pass
  • Fail(msg: String)

The list of tests to run

pub type TestSuite =
  List(Test)

Constants

pub const new: List(#(String, fn() -> TestOutcome)) = []

New test suite is just an empty list

Functions

pub fn fail(msg: String) -> TestOutcome

Let a test fail

pub fn named(name: String, new_test: fn() -> TestOutcome) -> #(
  String,
  fn() -> TestOutcome,
)

Creates a new test with the given name

pub fn pass() -> TestOutcome

Let a test pass

pub fn run(input: List(#(String, fn() -> TestOutcome))) -> Nil

Run the tests and print the test run output

pub fn test(input: List(#(String, fn() -> TestOutcome)), name: String, new_test: fn() ->
    TestOutcome) -> List(#(String, fn() -> TestOutcome))

Add a single test to the test suite

pub fn tests(input: List(#(String, fn() -> TestOutcome)), new_tests: List(
    #(String, fn() -> TestOutcome),
  )) -> List(#(String, fn() -> TestOutcome))

Add a list of tests to the test suite

Search Document