Logo

index : 0x2lib

Library extension for Jai

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/0x2lib.git/html/tests/assertion.jai blob: 7f3c5decc5d2c9f5e8c7db0014c1d30742ed48c0 [raw] [clear marker]

        
0
1
2
3ASS_CODE :: #code {
4 log_error("\n%: Test failed", loc);
5 log_error("-------------------");
6 log_error(":Subject A\n%\n\n", a);
7 log_error(":Subject B\n%\n\n", b);
8 `return false;
9}
10
11
12ass :: (comp: bool, loc := #caller_location) #expand {
13 if !comp {
14 log_error("\n%: Test failed", loc);
15 `return false;
16 }
17}
18
19ass :: (a: $T, b: T, $code := ASS_CODE, loc := #caller_location) #expand {
20 if a != b {
21 #insert,scope() code;
22 }
23}
24
25/** Cannot use `[]$T, []T` here, because Jai cannot resolve the overloads then */
26ass :: (a: []int, b: []int, $code := ASS_CODE, loc := #caller_location) #expand {
27 if a.count != b.count {
28 #insert,scope() code;
29 }
30
31 for a if it != b[it_index] {
32 #insert,scope() code;
33 }
34}
35
36
37#scope_file
38
39
40using,only(log_error) Basic :: #import "Basic";
41
42
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit