Programming Language

Nocter

A self-contained systems language built around simplicity, encapsulation, and foolproof design.

/development/std/testing.nct

testing.nct

//! Assertions for native Nocter tests.
//!
//! These are ordinary fallible functions. Assertion failure therefore uses the same Error
//! propagation, process cleanup, and reporting path as application failures.

use std/error.Error

pub func assert(condition: bool): void! {
    if !condition {
        return Error.new("std.testing.assertion_failed", "assertion failed")
    }
    return
}

pub func assert_eq_bool(actual: bool, expected: bool): void! {
    if actual != expected {
        return Error.new("std.testing.not_equal", "boolean values are not equal")
    }
    return
}

pub func assert_eq_i32(actual: i32, expected: i32): void! {
    if actual != expected {
        return Error.new("std.testing.not_equal", "i32 values are not equal")
    }
    return
}

pub func assert_eq_usize(actual: usize, expected: usize): void! {
    if actual != expected {
        return Error.new("std.testing.not_equal", "usize values are not equal")
    }
    return
}

pub func assert_eq_u8(actual: u8, expected: u8): void! {
    if actual != expected {
        return Error.new("std.testing.not_equal", "u8 values are not equal")
    }
    return
}

pub func assert_eq_str(actual: &str, expected: &str): void! {
    if actual != expected {
        return Error.new("std.testing.not_equal", "text values are not equal")
    }
    return
}