mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 04:38:16 +00:00
testing: Strip ; from test runner.
This commit is contained in:
+19
-19
@@ -4,7 +4,7 @@ import "core:fmt"
|
||||
import "core:io"
|
||||
|
||||
// IMPORTANT NOTE: Compiler requires this layout
|
||||
Test_Signature :: proc(^T);
|
||||
Test_Signature :: proc(^T)
|
||||
|
||||
// IMPORTANT NOTE: Compiler requires this layout
|
||||
Internal_Test :: struct {
|
||||
@@ -31,53 +31,53 @@ T :: struct {
|
||||
|
||||
|
||||
error :: proc(t: ^T, args: ..any, loc := #caller_location) {
|
||||
fmt.wprintf(t.w, "%v: ", loc);
|
||||
fmt.wprintln(t.w, ..args);
|
||||
t.error_count += 1;
|
||||
fmt.wprintf(t.w, "%v: ", loc)
|
||||
fmt.wprintln(t.w, ..args)
|
||||
t.error_count += 1
|
||||
}
|
||||
|
||||
errorf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) {
|
||||
fmt.wprintf(t.w, "%v: ", loc);
|
||||
fmt.wprintf(t.w, format, ..args);
|
||||
fmt.wprintln(t.w);
|
||||
t.error_count += 1;
|
||||
fmt.wprintf(t.w, "%v: ", loc)
|
||||
fmt.wprintf(t.w, format, ..args)
|
||||
fmt.wprintln(t.w)
|
||||
t.error_count += 1
|
||||
}
|
||||
|
||||
fail :: proc(t: ^T) {
|
||||
error(t, "FAIL");
|
||||
t.error_count += 1;
|
||||
error(t, "FAIL")
|
||||
t.error_count += 1
|
||||
}
|
||||
|
||||
fail_now :: proc(t: ^T) {
|
||||
fail(t);
|
||||
fail(t)
|
||||
if t._fail_now != nil {
|
||||
t._fail_now();
|
||||
t._fail_now()
|
||||
}
|
||||
}
|
||||
|
||||
failed :: proc(t: ^T) -> bool {
|
||||
return t.error_count != 0;
|
||||
return t.error_count != 0
|
||||
}
|
||||
|
||||
log :: proc(t: ^T, args: ..any, loc := #caller_location) {
|
||||
fmt.wprintln(t.w, ..args);
|
||||
fmt.wprintln(t.w, ..args)
|
||||
}
|
||||
|
||||
logf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) {
|
||||
fmt.wprintf(t.w, format, ..args);
|
||||
fmt.wprintln(t.w);
|
||||
fmt.wprintf(t.w, format, ..args)
|
||||
fmt.wprintln(t.w)
|
||||
}
|
||||
|
||||
|
||||
// cleanup registers a procedure and user_data, which will be called when the test, and all its subtests, complete
|
||||
// cleanup proceduers will be called in LIFO (last added, first called) order.
|
||||
cleanup :: proc(t: ^T, procedure: proc(rawptr), user_data: rawptr) {
|
||||
append(&t.cleanups, Internal_Cleanup{procedure, user_data});
|
||||
append(&t.cleanups, Internal_Cleanup{procedure, user_data})
|
||||
}
|
||||
|
||||
expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bool {
|
||||
if !ok {
|
||||
error(t=t, args={msg}, loc=loc);
|
||||
error(t=t, args={msg}, loc=loc)
|
||||
}
|
||||
return ok;
|
||||
return ok
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user