File tree Expand file tree Collapse file tree 3 files changed +31
-8
lines changed
Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ We provide assertions for these checks.
55Below is their documentation.
66
77## assert_true
8- > ` assert_true bool `
8+ > ` assert_true bool|function|command `
99
10- Reports an error if the ` bool ` is truthy ` true ` or ` 0 ` .
10+ Reports an error if the argument result in a truthy value: ` true ` or ` 0 ` .
1111
1212- [ assert_false] ( #assert-false ) is similar but different.
1313
@@ -16,19 +16,30 @@ Reports an error if the `bool` is truthy `true` or `0`.
1616function test_success() {
1717 assert_true true
1818 assert_true 0
19+ assert_true " eval return 0"
20+ assert_true mock_true
1921}
2022
2123function test_failure() {
2224 assert_true false
2325 assert_true 1
26+ assert_true " eval return 1"
27+ assert_true mock_false
2428}
2529```
30+ ``` bash [globals.sh]
31+ function mock_true() {
32+ return 0
33+ }
34+ function mock_false() {
35+ return 1
36+ }
2637:::
2738
2839# # assert_false
29- > ` assert_false bool `
40+ > ` assert_false bool| function | command `
3041
31- Reports an error if the ` bool ` is falsy ` false ` or ` 1 ` .
42+ Reports an error if the argument result in a falsy value: ` false` or ` 1` .
3243
3344- [assert_true](# assert-true) is similar but different.
3445
@@ -37,11 +48,23 @@ Reports an error if the `bool` is falsy `false` or `1`.
3748function test_success() {
3849 assert_false false
3950 assert_false 1
51+ assert_false " eval return 1"
52+ assert_false mock_false
4053}
4154
4255function test_failure() {
4356 assert_false true
4457 assert_false 0
58+ assert_false " eval return 0"
59+ assert_false mock_true
60+ }
61+ ` ` `
62+ ` ` ` bash [globals.sh]
63+ function mock_true() {
64+ return 0
65+ }
66+ function mock_false() {
67+ return 1
4568}
4669` ` `
4770:::
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ function assert_true() {
2323 local exit_code=$?
2424
2525 if [[ $exit_code -ne 0 ]]; then
26- handle_bool_assertion_failure " valid command, function, or true/0 " " exit code: $exit_code "
26+ handle_bool_assertion_failure " command or function with zero exit code " " exit code: $exit_code "
2727 else
2828 state::add_assertions_passed
2929 fi
Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ function test_unsuccessful_assert_true_on_function() {
4040 assert_same\
4141 " $( console_results::print_failed_test\
4242 " Unsuccessful assert true on function" \
43- " valid command, function, or true/0 " \
44- " but got " " exit code: 127 " ) " \
45- " $( assert_true " $( return 1 ) " ) "
43+ " command or function with zero exit code " \
44+ " but got " " exit code: 2 " ) " \
45+ " $( assert_true " eval return 2 " ) "
4646}
4747
4848# data_provider provider_successful_assert_false
You can’t perform that action at this time.
0 commit comments