# Author:       Li Junhao       l@x-cmd.com                     # xrc
# shellcheck    shell=sh        disable=SC2039,SC1001,SC3043

x log init assert
alias _assert:return='eval "___x_cmd_assert_loginner && return"'        # Notice: Must use "&&" or "||" instead of ";"
___x_cmd_assert_loginner(){ assert:error "$M"; }

xrc is

xrc:mod:lib     assert          isfile is func lefteq var ypart
#isfile is exec other

___x_cmd_assert___main(){
    case "$1" in
        var)                    shift; ___x_cmd_assert_var "$@" ;;
        is-*)                   ___x_cmd_assert___main_is       "$@"    ;;


        \=*)                    ___x_cmd_assert___main_lefteq   "$@"    ;;
        *)                      ___x_cmd_assert___main_func     "$@"    ;;
    esac
}


# TODO: Replace this function with the combinations of assert utilities
___x_cmd____assert_true_or_exit(){
    local code
    "$@"
    code=$?
    if [ $code -ne 0 ]; then
        [ -z "$___X_CMD_TEST_ASSERT_ERREXIT" ] || exit $code
    fi
    return "$code"
}

