diff --git a/zunit b/zunit index aa2eea6..c6bf926 100755 --- a/zunit +++ b/zunit @@ -116,12 +116,20 @@ function _zunit_assert_does_not_match() { function _zunit_assert_in() { local i found=0 value=$1 local -a array + local oldIFS=$IFS + IFS=$'\n' + array=(${(@)@:2}) + echo $value + echo ${#array} for i in ${(@f)array}; do + echo $i [[ $i = $value ]] && found=1 done + IFS=$oldIFS + [[ $found -eq 1 ]] && return 0 echo "'$value' is not in (${(@f)array})" @@ -134,12 +142,17 @@ function _zunit_assert_in() { function _zunit_assert_not_in() { local i found=0 value=$1 local -a array + local oldIFS=$IFS + IFS=$'\n' + array=(${(@)@:2}) for i in ${(@f)array}; do [[ $i = $value ]] && found=1 done + IFS=$oldIFS + [[ $found -eq 0 ]] && return 0 echo "'$value' is in (${(@f)array})" @@ -305,7 +318,7 @@ function run() { output=$("${cmd[@]}" 2>&1) # Get the process exit state - state="$?" + state=$? # Store individual lines of output in an array IFS=$'\n'