Added `declare` as an alias for `set` expectation

master
Mike Gerwitz 2014-06-10 22:12:09 -04:00
parent 7597677086
commit 331a1161b2
2 changed files with 181 additions and 166 deletions

View File

@ -64,3 +64,12 @@ _expect--set()
esac
}
##
# Alias for `set`
#
_expect--declare()
{
_expect--set "$@"
}

View File

@ -26,13 +26,17 @@ declare -- empty=""
declare -- one="1"'
declare curchk
function setchk()
{
_expect--set 0 4 <(:) <( echo "$stubenv" ) "$@"
_expect--$curchk 0 4 <(:) <( echo "$stubenv" ) "$@"
}
describe set
for name in set declare; do
curchk=$name
describe set
describe = and == operators
it succeeds on string equality
expect setchk var = val
@ -72,7 +76,8 @@ describe set
to succeed
end
# note that this also ensures that *all* arguments are part of the match
# note that this also ensures that *all* arguments are part of the
# match
it fails on a mismatch
expect setchk \
long =~ fo+ baX baz\$
@ -198,10 +203,11 @@ describe set
# primarily for safety and strict documentation, but no other tests make
# sense at the moment
it fails on unrecognized operators
# shell injection (not that this is realistically a problem, because we
# can execute arbitrary shell code anyway)
# shell injection (not that this is realistically a problem, because
# we can execute arbitrary shell code anyway)
expect setchk var "!= foo -a 1 -eq" 1
to fail
end
end
end
done