package core:testing

⌘K
Ctrl+K
or
/

    Index

    Constants (0)

    This section is empty.

    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Internal_Cleanup ¶

    Internal_Cleanup :: struct {
    	procedure: proc(_: rawptr),
    	user_data: rawptr,
    	ctx:       runtime.Context,
    }

    Internal_Test ¶

    Internal_Test :: struct {
    	pkg:  string,
    	name: string,
    	p:    Test_Signature,
    }
     

    IMPORTANT NOTE: Compiler requires this layout

    T ¶

    T :: struct {
    	error_count:      int,
    	// If your test needs to perform random operations, it's advised to use
    	// this value to seed a local random number generator rather than relying
    	// on the non-thread-safe global one.
    	// 
    	// This way, your results will be deterministic.
    	// 
    	// This value is chosen at startup of the test runner, logged, and may be
    	// specified by the user. It is the same for all tests of a single run.
    	seed:             u64,
    	channel:          sync_chan.Chan($T, $D=0),
    	cleanups:         [dynamic]Internal_Cleanup,
    	// This allocator is shared between the test runner and its threads for
    	// cloning log strings, so they can outlive the lifetime of individual
    	// tests during channel transmission.
    	_log_allocator:   runtime.Allocator,
    	_fail_now_called: bool,
    }
    Related Procedures With Parameters

    Test_Signature ¶

    Test_Signature :: proc(_: ^T)
     

    IMPORTANT NOTE: Compiler requires this layout

    Constants

    This section is empty.

    Variables

    This section is empty.

    Procedures

    cleanup ¶

    cleanup :: proc(t: ^T, procedure: proc(_: rawptr), user_data: rawptr) {…}
     

    cleanup registers a procedure and user_data, which will be called when the test, and all its subtests, complete. Cleanup procedures will be called in LIFO (last added, first called) order.

    Each procedure will use a copy of the context at the time of registering, and if the test failed due to a timeout, failed assertion, panic, bounds-checking error, memory access violation, or any other signal-based fault, this procedure will run with greater privilege in the test runner's main thread.

    That means that any cleanup procedure absolutely must not fail in the same way, or it will take down the entire test runner with it. This is for when you need something to run no matter what, if a test failed.

    For almost every usual case, defer should be preferable and sufficient.

    error ¶

    error :: proc(t: ^T, .. args: ..any, loc := #caller_location) {…}

    errorf ¶

    errorf :: proc(t: ^T, format: string, .. args: ..any, loc := #caller_location) {…}

    expect ¶

    expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bool {…}

    expect_value ¶

    expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> bool {…}

    expectf ¶

    expectf :: proc(t: ^T, ok: bool, format: string, .. args: ..any, loc := #caller_location) -> bool {…}

    fail ¶

    fail :: proc(t: ^T, loc := #caller_location) {…}

    fail_now ¶

    fail_now :: proc(t: ^T, msg: string = "", loc := #caller_location) -> ! {…}
     

    fail_now will cause a test to immediately fail and abort, much in the same way a failed assertion or panic call will stop a thread.

    It is for when you absolutely need a test to fail without calling any of its deferred statements. It will be cleaner than a regular assert or panic, as the test runner will know to expect the signal this procedure will raise.

    failed ¶

    failed :: proc(t: ^T) -> bool {…}

    log ¶

    log :: proc(t: ^T, .. args: ..any, loc := #caller_location) {…}

    logf ¶

    logf :: proc(t: ^T, format: string, .. args: ..any, loc := #caller_location) {…}

    set_fail_timeout ¶

    set_fail_timeout :: proc(t: ^T, duration: time.Duration, loc := #caller_location) {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-07 (vendor "odin") Windows_amd64 @ 2024-07-26 21:10:25.134858800 +0000 UTC