mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
Change variable testing behaviour
When checking for emptyness of a variable (In order to support conditionnals), also check that the variable does not start by "false"
This commit is contained in:
parent
ea76dc468b
commit
ba1ad0dca3
9
mo
9
mo
@ -775,15 +775,14 @@ moStandaloneDenied() {
|
|||||||
|
|
||||||
|
|
||||||
# Internal: Determines if the named thing is a function or if it is a
|
# Internal: Determines if the named thing is a function or if it is a
|
||||||
# non-empty environment variable.
|
# non-empty, not false environment variable.
|
||||||
#
|
#
|
||||||
# Do not use variables without prefixes here if possible as this needs to
|
# Do not use variables without prefixes here if possible as this needs to
|
||||||
# check if any name exists in the environment
|
# check if any name exists in the environment
|
||||||
#
|
#
|
||||||
# $1 - Name of environment variable or function
|
# $1 - Name of environment variable or function
|
||||||
# $2 - Current value (our context)
|
|
||||||
#
|
#
|
||||||
# Returns 0 if the name is not empty, 1 otherwise.
|
# Returns 0 if the name is not empty nor false, 1 otherwise.
|
||||||
moTest() {
|
moTest() {
|
||||||
# Test for functions
|
# Test for functions
|
||||||
moIsFunction "$1" && return 0
|
moIsFunction "$1" && return 0
|
||||||
@ -792,8 +791,8 @@ moTest() {
|
|||||||
# Arrays must have at least 1 element
|
# Arrays must have at least 1 element
|
||||||
eval '[[ "${#'"$1"'[@]}" -gt 0 ]]' && return 0
|
eval '[[ "${#'"$1"'[@]}" -gt 0 ]]' && return 0
|
||||||
else
|
else
|
||||||
# Environment variables must not be empty
|
# Environment variables must not be empty nor false
|
||||||
[[ ! -z "${!1}" ]] && return 0
|
[[ ! -z "${!1}" ]] && eval '[[ "$'"$1"'" != "false" ]]' && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
@ -1 +1,2 @@
|
|||||||
person=""
|
person=""
|
||||||
|
falsy=false
|
||||||
|
@ -2,3 +2,6 @@ Shown.
|
|||||||
{{#person}}
|
{{#person}}
|
||||||
Never shown!
|
Never shown!
|
||||||
{{/person}}
|
{{/person}}
|
||||||
|
{{#falsy}}
|
||||||
|
As well !
|
||||||
|
{{/falsy}}
|
||||||
|
Loading…
Reference in New Issue
Block a user