|
|
@ -6,8 +6,8 @@
|
|
|
|
# <condition>
|
|
|
|
# <condition>
|
|
|
|
# --to-be-false exit status is falsy
|
|
|
|
# --to-be-false exit status is falsy
|
|
|
|
# --to-be-true exit status is truthy
|
|
|
|
# --to-be-true exit status is truthy
|
|
|
|
# --to-contain <actual> value exists in <expected> list
|
|
|
|
# --to-contain <actual> values exist in <expected> list
|
|
|
|
# --to-no-contain <actual> value does not exist in <expected> list
|
|
|
|
# --to-no-contain <actual> values does not exist in <expected> list
|
|
|
|
# --to-equal <actual> value equals <expected> value
|
|
|
|
# --to-equal <actual> value equals <expected> value
|
|
|
|
# <actual>
|
|
|
|
# <actual>
|
|
|
|
#
|
|
|
|
#
|
|
|
@ -29,15 +29,18 @@ function expect
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
set -l expected $argv[1..-3]
|
|
|
|
for i in (seq (count $argv))
|
|
|
|
set -l condition $argv[-2]
|
|
|
|
if [ (echo $argv[$i] | grep '\-\-') ] # Expectation argument found
|
|
|
|
set -l actual $argv[-1]
|
|
|
|
set -g condition $argv[$i]
|
|
|
|
set -l result 0
|
|
|
|
set -g expected $argv[1..(math "$i - 1")]
|
|
|
|
|
|
|
|
|
|
|
|
if [ (echo "$actual" | grep '\-\-') ]
|
|
|
|
# No comparison required e.g. --to-be-true
|
|
|
|
set expected $argv[1..-2]
|
|
|
|
if not [ (count $argv) = $i ]
|
|
|
|
set condition $actual
|
|
|
|
set -g actual $argv[(math "$i + 1")..-1]
|
|
|
|
set actual ""
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Test conditions and save success/fail $status to return later.
|
|
|
|
# Test conditions and save success/fail $status to return later.
|
|
|
@ -49,9 +52,19 @@ function expect
|
|
|
|
eval "$expected"
|
|
|
|
eval "$expected"
|
|
|
|
test $status -eq 0
|
|
|
|
test $status -eq 0
|
|
|
|
case --to-contain
|
|
|
|
case --to-contain
|
|
|
|
contains -- "$actual" $expected
|
|
|
|
set result 0
|
|
|
|
|
|
|
|
for item in $actual
|
|
|
|
|
|
|
|
contains -- "$item" $expected
|
|
|
|
|
|
|
|
or set result $status
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test $result -eq 0
|
|
|
|
case --to-not-contain
|
|
|
|
case --to-not-contain
|
|
|
|
not contains -- "$actual" $expected
|
|
|
|
set result 0
|
|
|
|
|
|
|
|
for item in $actual
|
|
|
|
|
|
|
|
not contains -- "$item" $expected
|
|
|
|
|
|
|
|
or set result $status
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test $result -eq 0
|
|
|
|
case --to-eq\*
|
|
|
|
case --to-eq\*
|
|
|
|
test "$expected" = "$actual"
|
|
|
|
test "$expected" = "$actual"
|
|
|
|
end
|
|
|
|
end
|
|
|
|