Tests

Module tests

import tests

What a test is, before anything runs it.

A test is a function carrying Test that returns a prelude.Result. Nothing else is required: there is no registry and no base type, so the runner reaches for reflect and finds tests by reading a module rather than by being told about them.

The other attributes adjust what happens to one. Skip keeps it out of the run, Todo marks it as expected to be unfinished, Only narrows the run to itself, and Comment attaches a note that reporters print.

This module is only the vocabulary. tests.assert writes the assertions, tests.runner finds and runs them, and tests.tap reports what happened.

Contents


Unions

TestCaseDetails

`tests/types.zirr:28`
union TestCaseDetails {
	None
	TestCaseDetailsSkip
	TestCaseDetailsTodo
	TestCaseDetailsOnly
}

Each member says how to be read as an Option, the way prelude’s own Result members do: a union’s attributes are not read off a value of one of its members.

Cases

Case Interpretation
None The absent value.
TestCaseDetailsSkip
TestCaseDetailsTodo
TestCaseDetailsOnly

TestEvent

`tests/types.zirr:39`
union TestEvent {
	Discovered
	Skipped
	Started
	Finished
	Completed
}

Cases

Case Interpretation
Discovered
Skipped
Started
Finished
Completed

Data

Completed

`tests/types.zirr:44`
data Completed {
	report: TestReport
}

Fields

Field Description
report

Discovered

`tests/types.zirr:40`
data Discovered {
	cases: [TestCase]
}

Fields

Field Description
cases

FailureRecord

`tests/types.zirr:54`
data FailureRecord {
	test: TestCase
	error: Err
}

Fields

Field Description
test
error

Finished

`tests/types.zirr:43`
data Finished {
	test: TestCase
	outcome: Result
}

Fields

Field Description
test
outcome

Skipped

`tests/types.zirr:41`
data Skipped {
	test: TestCase
}

Fields

Field Description
test

Started

`tests/types.zirr:42`
data Started {
	test: TestCase
}

Fields

Field Description
test

TestCase

`tests/types.zirr:11`
data TestCase {
	name: String
	impl: fn() -> Result
	skipped: Bool
	comment: String
	details: TestCaseDetails
}

Fields

Field Description
name
impl
skipped
comment
details

TestCaseDetailsOnly

`tests/types.zirr:36`
data TestCaseDetailsOnly

TestCaseDetailsSkip

`tests/types.zirr:32`
data TestCaseDetailsSkip

TestCaseDetailsTodo

`tests/types.zirr:34`
data TestCaseDetailsTodo

TestReport

`tests/types.zirr:47`
data TestReport {
	pass: [TestCase]
	fail: [FailureRecord]
	skip: [TestCase]
	todo: [TestCase]
}

Fields

Field Description
pass
fail
skip
todo

Attributes

Comment

`tests/types.zirr:7`
attr Comment {
	text: String
}

Fields

Field Description
text

Only

`tests/types.zirr:5`
attr Only

Skip

`tests/types.zirr:4`
attr Skip

Test

`tests/types.zirr:3`
attr Test

Todo

`tests/types.zirr:6`
attr Todo