forked from nulang-org/nulang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.nula
More file actions
39 lines (35 loc) · 962 Bytes
/
Copy pathtest.nula
File metadata and controls
39 lines (35 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Nulang standard library — testing primitives.
// Language version: 2.0.0-alpha
//
// Usage:
// import test
// fn my_tests() {
// test.assert_eq(add(1, 2), 3)
// test.assert_true(meaning_of_life() == 42)
// }
/// Assert that two values are equal. Prints a message and exits with
/// an error if they differ.
pub fn assert_eq[T](actual: T, expected: T) {
if actual != expected then
perform IO.print("FAIL: assert_eq failed")
else
()
}
/// Assert that a boolean condition is true.
pub fn assert_true(condition: Bool) {
if condition then
()
else
perform IO.print("FAIL: assert_true failed")
}
/// Assert that a boolean condition is false.
pub fn assert_false(condition: Bool) {
if condition then
perform IO.print("FAIL: assert_false failed")
else
()
}
/// Fail unconditionally with a message.
pub fn fail(message: String) {
perform IO.print("FAIL: " + message)
}