Skip to content

Commit

Permalink
Fix in and not_in assertion methods in ZSH<5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
molovo committed Feb 15, 2017
1 parent a0963ec commit e9e6eba
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions zunit
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,18 @@ function _zunit_assert_in() {
local -a array
array=(${(@)@:2})

local oldIFS=$IFS
IFS=$'\n'

for i in ${(@f)array}; do
[[ $i = $value ]] && found=1
done


[[ $found -eq 1 ]] && return 0

echo "'$value' is not in (${(@f)array})"
IFS=$oldIFS
exit 1
}

Expand All @@ -136,13 +141,17 @@ function _zunit_assert_not_in() {
local -a array
array=(${(@)@:2})

local oldIFS=$IFS
IFS=$'\n'

for i in ${(@f)array}; do
[[ $i = $value ]] && found=1
done

[[ $found -eq 0 ]] && return 0

echo "'$value' is in (${(@f)array})"
IFS=$oldIFS
exit 1
}

Expand Down

0 comments on commit e9e6eba

Please sign in to comment.