-module(dream_test@matchers@boolean). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/dream_test/matchers/boolean.gleam"). -export([be_true/1, be_false/1]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Boolean matchers for dream_test.\n" "\n" " These matchers check boolean values and are re-exported through\n" " `dream_test/matchers`.\n" "\n" " Use them in a matcher chain when you want to assert a boolean condition.\n" "\n" " ## Example\n" "\n" " ```gleam\n" " True\n" " |> should\n" " |> be_true()\n" " |> or_fail_with(\"expected True\")\n" " ```\n" ). -file("src/dream_test/matchers/boolean.gleam", 53). -spec check_is_true(boolean()) -> dream_test@types:match_result(boolean()). check_is_true(Actual) -> case Actual of true -> {match_ok, true}; false -> Payload = {boolean_failure, false, true}, {match_failed, {assertion_failure, <<"be_true"/utf8>>, <<""/utf8>>, {some, Payload}}} end. -file("src/dream_test/matchers/boolean.gleam", 44). ?DOC( " Assert that a value is `True`.\n" "\n" " Use this when your value is expected to be `True` and you want a useful\n" " failure payload when it isn't.\n" "\n" " ## Example\n" "\n" " ```gleam\n" " True\n" " |> should\n" " |> be_true()\n" " |> or_fail_with(\"expected True\")\n" " ```\n" "\n" " ## Parameters\n" "\n" " - `value_or_result`: the `MatchResult(Bool)` produced by `should` (or a previous matcher)\n" "\n" " ## Returns\n" "\n" " A `MatchResult(Bool)` preserving the boolean for further chaining.\n" ). -spec be_true(dream_test@types:match_result(boolean())) -> dream_test@types:match_result(boolean()). be_true(Value_or_result) -> case Value_or_result of {match_failed, Failure} -> {match_failed, Failure}; {match_ok, Actual} -> check_is_true(Actual) end. -file("src/dream_test/matchers/boolean.gleam", 99). -spec check_is_false(boolean()) -> dream_test@types:match_result(boolean()). check_is_false(Actual) -> case Actual of false -> {match_ok, false}; true -> Payload = {boolean_failure, true, false}, {match_failed, {assertion_failure, <<"be_false"/utf8>>, <<""/utf8>>, {some, Payload}}} end. -file("src/dream_test/matchers/boolean.gleam", 90). ?DOC( " Assert that a value is `False`.\n" "\n" " Use this when your value is expected to be `False` and you want a useful\n" " failure payload when it isn't.\n" "\n" " ## Example\n" "\n" " ```gleam\n" " False\n" " |> should\n" " |> be_false()\n" " |> or_fail_with(\"expected False\")\n" " ```\n" "\n" " ## Parameters\n" "\n" " - `value_or_result`: the `MatchResult(Bool)` produced by `should` (or a previous matcher)\n" "\n" " ## Returns\n" "\n" " A `MatchResult(Bool)` preserving the boolean for further chaining.\n" ). -spec be_false(dream_test@types:match_result(boolean())) -> dream_test@types:match_result(boolean()). be_false(Value_or_result) -> case Value_or_result of {match_failed, Failure} -> {match_failed, Failure}; {match_ok, Actual} -> check_is_false(Actual) end.