Doc tests for gleam! ✨
gleam add --dev testament
More info on Writing Tests 🔗
////Example Module doc test
////```gleam
////: assert 1 + 1 == 2
////```
///Example function doc test
///adds two Ints
///```gleam
///: assert example.add(1, 2) == 3
///: assert example.add(1, -1) == 0
///```
pub fn add(a: Int, b: Int) -> Int {
a + b
}
import gleeunit
import testament
pub fn main() -> Nil {
testament.test_main(gleeunit.main)
}
gleam test
Compiling example
Compiled in 0.44s
Running example_test.main
.
1 test, no failures
(these should get deleted after the run)
echo -e "\ntest/testament/*" >> .gitignore
[javascript.deno]
allow_read = true
allow_write = true
allow_env = ["TESTAMENT_WITH_DOCS", "PATHEXT", "PATH"]
allow_run = ["gleam"]