Reference
Assert
Assert equal
| Input | The actual value and the expected value. |
|---|---|
| Output | True if the two values are equal. Throws an assertion error otherwise. |
Signature
assert_equal(a: Equatable, b: Equatable): BooleanExample
assert_equal(1 + 1, 2) // returns true
assert_equal(3, 2) // Assertion error: "assert_equal" failed: expected 2, actual 3Assert not equal
| Input | The actual value and the value it must differ from. |
|---|---|
| Output | True if the two values differ. Throws an assertion error otherwise. |
Signature
assert_notEqual(a: Equatable, b: Equatable): BooleanExample
assert_notEqual(1, 2) // returns true
assert_notEqual(1, 1) // Assertion error: "assert_notEqual" failed: expected not 1, actual 1Assert true
| Input | A boolean condition. |
|---|---|
| Output | True if the condition is true. Throws an assertion error otherwise. |
Signature
assert_true(a: Boolean): BooleanExample
assert_true(str_startsWith("abc", "a")) // returns true
assert_true(false) // Assertion error: "assert_true" failed: expected true, actual falseAssert false
| Input | A boolean condition. |
|---|---|
| Output | True if the condition is false. Throws an assertion error otherwise. |
Signature
assert_false(a: Boolean): BooleanExample
assert_false(str_isEmpty("abc")) // returns true
assert_false(true) // Assertion error: "assert_false" failed: expected false, actual trueAssert throws
| Input | An expression expected to raise an error. |
|---|---|
| Output | True if evaluating the expression raises a runtime error. Throws an assertion error otherwise. |
Signature
assert_throws(a: Any): BooleanExample
assert_throws(to_number("not a number")) // returns true
assert_throws(42) // Assertion error: "assert_throws" failed: expected a thrown error, actual 42