std/test
test and group, the two functions a .test.trb file calls, with assert doing all of the checking.
Diese Seite gibt es noch nicht auf Deutsch, deshalb steht sie hier auf Englisch. Zur englischen Seite
Die generierte Referenz von std/test zeigt jede öffentliche Deklaration mit Signatur, Doc-Kommentar und Beispielen.
std/test makes a test an ordinary function call. There are no matchers: assert (from std/expression)
takes an Expression<Bool>, so a failure shows the source of the condition and the values it captured. A test fails if
it panics, and the test runner catches that per test.
Import#
use test, group from "std/test"use test from "std/test"
type Vector2 {
x: Float
y: Float
}
test "compares equal to itself" {
const v = Vector2 x: 1.0, y: 2.0
assert(v == v)
}Declarations#
test, group#
native fn test(name: String, body: () => Void)
native fn group(name: String, body: () => Void)group names a closure of test calls; test names a closure whose body is the check. Both are ordinary calls in the
.test.trb files of tests, and nest freely - a group inside a group is how a suite is organized.
Related#
- std/expression -
assert, the one function a test body calls. - The standard library - the other packages.