From 712ae1c5ac73493498aa8e5076d91a6558337117 Mon Sep 17 00:00:00 2001 From: FourteenBrush Date: Thu, 25 Jan 2024 10:08:09 +0100 Subject: [PATCH 1/4] Add testing.expectf --- core/testing/testing.odin | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/testing/testing.odin b/core/testing/testing.odin index 1ba05315c..e6518b249 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -91,6 +91,14 @@ expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bo } return ok } + +expectf :: proc(t: ^T, ok: bool, format: string, args: ..any, loc := #caller_location) -> bool { + if !ok { + errorf(t, format, args) + } + return ok +} + expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> bool where intrinsics.type_is_comparable(T) { ok := value == expected || reflect.is_nil(value) && reflect.is_nil(expected) if !ok { From 3a5d80b291139bc3789eda28081efdd95743838b Mon Sep 17 00:00:00 2001 From: FourteenBrush Date: Thu, 25 Jan 2024 10:20:23 +0100 Subject: [PATCH 2/4] Forgot to include loc param --- core/testing/testing.odin | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/testing/testing.odin b/core/testing/testing.odin index e6518b249..cd6051de3 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -94,7 +94,7 @@ expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bo expectf :: proc(t: ^T, ok: bool, format: string, args: ..any, loc := #caller_location) -> bool { if !ok { - errorf(t, format, args) + errorf(t, format, args, loc=loc) } return ok } @@ -108,7 +108,6 @@ expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> boo } - set_fail_timeout :: proc(t: ^T, duration: time.Duration, loc := #caller_location) { _fail_timeout(t, duration, loc) } From 895ebb95d5646c61a45df1cafc835cb96057c19e Mon Sep 17 00:00:00 2001 From: FourteenBrush Date: Thu, 25 Jan 2024 11:44:53 +0100 Subject: [PATCH 3/4] Need to unpack args --- core/testing/testing.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/testing/testing.odin b/core/testing/testing.odin index cd6051de3..e68fb121a 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -94,7 +94,7 @@ expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bo expectf :: proc(t: ^T, ok: bool, format: string, args: ..any, loc := #caller_location) -> bool { if !ok { - errorf(t, format, args, loc=loc) + errorf(t, format, ..args, loc=loc) } return ok } From 766d6aa94624b15192413d549f91427957b96f19 Mon Sep 17 00:00:00 2001 From: FourteenBrush Date: Thu, 25 Jan 2024 12:05:19 +0100 Subject: [PATCH 4/4] Fix typo --- core/testing/testing.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/testing/testing.odin b/core/testing/testing.odin index e68fb121a..ce6a47159 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -80,7 +80,7 @@ logf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) { // 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 procedures 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}) }