-module(startest@expect). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([to_equal/2, to_not_equal/2, to_be_true/1, to_be_false/1, to_be_ok/1, to_be_error/1, to_be_some/1, to_be_none/1, to_throw/1, to_not_throw/1]). -spec to_equal(NNH, NNH) -> nil. to_equal(Actual, Expected) -> case Actual =:= Expected of true -> nil; false -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(Actual), <<" to equal "/utf8>>, gleam@string:inspect(Expected)] ), gleam@string:inspect(Actual), gleam@string:inspect(Expected)}, startest@assertion_error:raise(_pipe) end. -spec to_not_equal(NNI, NNI) -> nil. to_not_equal(Actual, Expected) -> case Actual /= Expected of true -> nil; false -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(Actual), <<" to not equal "/utf8>>, gleam@string:inspect(Expected)] ), gleam@string:inspect(Actual), gleam@string:inspect(Expected)}, startest@assertion_error:raise(_pipe) end. -spec to_be_true(boolean()) -> nil. to_be_true(Actual) -> _pipe = Actual, to_equal(_pipe, true). -spec to_be_false(boolean()) -> nil. to_be_false(Actual) -> _pipe = Actual, to_equal(_pipe, false). -spec to_be_ok({ok, NNJ} | {error, any()}) -> NNJ. to_be_ok(Actual) -> case Actual of {ok, Value} -> Value; {error, _} -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(Actual), <<" to be Ok"/utf8>>] ), gleam@string:inspect(Actual), <<"Ok(_)"/utf8>>}, startest@assertion_error:raise(_pipe) end. -spec to_be_error({ok, any()} | {error, NNO}) -> NNO. to_be_error(Actual) -> case Actual of {error, Error} -> Error; {ok, _} -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(Actual), <<" to be Error"/utf8>>] ), gleam@string:inspect(Actual), <<"Error(_)"/utf8>>}, startest@assertion_error:raise(_pipe) end. -spec to_be_some(gleam@option:option(NNR)) -> NNR. to_be_some(Actual) -> case Actual of {some, Value} -> Value; none -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(Actual), <<" to be Some"/utf8>>] ), gleam@string:inspect(Actual), <<"Some(_)"/utf8>>}, startest@assertion_error:raise(_pipe) end. -spec to_be_none(gleam@option:option(any())) -> nil. to_be_none(Actual) -> case Actual of none -> nil; {some, _} -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(Actual), <<" to be None"/utf8>>] ), gleam@string:inspect(Actual), <<"None"/utf8>>}, startest@assertion_error:raise(_pipe) end. -spec to_throw(fun(() -> any())) -> nil. to_throw(F) -> case exception_ffi:rescue(F) of {error, _} -> nil; {ok, Value} -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(F), <<" to throw an error"/utf8>>] ), gleam@string:inspect(Value), gleam@string:inspect(nil)}, startest@assertion_error:raise(_pipe) end. -spec to_not_throw(fun(() -> NNW)) -> NNW. to_not_throw(F) -> case exception_ffi:rescue(F) of {ok, Value} -> Value; {error, Exception} -> _pipe = {assertion_error, gleam@string:concat( [<<"Expected "/utf8>>, gleam@string:inspect(F), <<" to not throw an error"/utf8>>] ), gleam@string:inspect(nil), gleam@string:inspect(Exception)}, startest@assertion_error:raise(_pipe) end.