2023-04-08 14:35:16 +02:00
|
|
|
use std *
|
2023-03-20 14:57:28 +01:00
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_basic [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert true
|
|
|
|
assert (1 + 2 == 3)
|
|
|
|
assert error { assert false }
|
|
|
|
assert error { assert (1 + 2 == 4) }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_not [] {
|
2023-05-19 11:33:19 +02:00
|
|
|
assert not false
|
|
|
|
assert not (1 + 2 == 4)
|
|
|
|
assert error { assert not true }
|
|
|
|
assert error { assert not (1 + 2 == 3) }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_equal [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert equal (1 + 2) 3
|
2023-09-12 13:02:47 +02:00
|
|
|
assert equal (0.1 + 0.2 | into string | into float) 0.3 # 0.30000000000000004 == 0.3
|
2023-03-20 14:57:28 +01:00
|
|
|
assert error { assert equal 1 "foo" }
|
2023-03-28 20:34:26 +02:00
|
|
|
assert error { assert equal (1 + 2) 4 }
|
2023-03-20 14:57:28 +01:00
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_not_equal [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert not equal (1 + 2) 4
|
|
|
|
assert not equal 1 "foo"
|
2023-03-28 20:34:26 +02:00
|
|
|
assert not equal (1 + 2) "3"
|
2023-03-20 14:57:28 +01:00
|
|
|
assert error { assert not equal 1 1 }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_error [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
let failing_code = {|| missing_code_to_run}
|
|
|
|
assert error $failing_code
|
|
|
|
|
|
|
|
let good_code = {|| }
|
|
|
|
let assert_error_raised = (try { do assert $good_code; false } catch { true })
|
|
|
|
assert $assert_error_raised "The assert error should raise an error if there is no error in the executed code."
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_less [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert less 1 2
|
|
|
|
assert error { assert less 1 1 }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_less_or_equal [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert less or equal 1 2
|
|
|
|
assert less or equal 1 1
|
|
|
|
assert error { assert less or equal 1 0 }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_greater [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert greater 2 1
|
|
|
|
assert error { assert greater 2 2 }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_greater_or_equal [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert greater or equal 1 1
|
|
|
|
assert greater or equal 2 1
|
|
|
|
assert error { assert greater or equal 0 1 }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def assert_length [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert length [0, 0, 0] 3
|
|
|
|
assert error { assert length [0, 0] 3 }
|
|
|
|
}
|
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[ignore]
|
|
|
|
def assert_skip [] {
|
|
|
|
assert true # This test case is skipped on purpose
|
2023-04-06 20:03:10 +02:00
|
|
|
}
|