-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.spl
More file actions
72 lines (61 loc) · 1.56 KB
/
test.spl
File metadata and controls
72 lines (61 loc) · 1.56 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// test.spl
// basic test suite for a subset of language features
include "lib/common.spl"
let test_count = 0;
let test_passed = 0;
let test_failed = 0;
fn test_init -> none {
store64 @test_count 0;
store64 @test_passed 0;
store64 @test_failed 0;
}
fn assert_equal(a: u64, b: u64, message: cstr) -> none {
store64 @test_count + 1 test_count;
if neq a b {
let args: any = (a, b, message);
dprintf(STDERR_FILENO, "assert_equal (%d != %d): %s\n", @args);
store64 @test_failed + 1 test_failed;
}
else {
store64 @test_passed + 1 test_passed;
}
}
fn assert_not_equal(a: u64, b: u64, message: cstr) -> none {
store64 @test_count + 1 test_count;
if eq a b {
let args: any = (a, b, message);
dprintf(STDERR_FILENO, "assert_not_equal failed (%d == %d): %s\n", @args);
store64 @test_failed + 1 test_failed;
}
else {
store64 @test_passed + 1 test_passed;
}
}
include "tests/core/arith.spl"
include "tests/core/sizeof.spl"
include "tests/core/bitwise.spl"
include "tests/core/function.spl"
include "tests/core/struct.spl"
include "tests/core/array.spl"
include "tests/core/const.spl"
include "tests/lib/common.spl"
fn test_start -> none {
printf("running tests...\n", null);
test_arith();
test_sizeof();
test_bitwise();
test_function();
test_struct();
test_array();
test_const();
test_lib_common();
}
fn test_finalize -> none {
let args: any = test_passed, test_failed, test_count;
printf("tests complete: %d passed, %d failed, %d total\n", @args);
}
fn main -> none {
test_init();
test_start();
test_finalize();
}