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

env
Mike Gerwitz 2014-06-10 22:12:09 -04:00
parent 93b6b6d7f5
commit 8a73619b0d
2 changed files with 181 additions and 166 deletions

View File

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

View File

@ -26,13 +26,17 @@ declare -- empty=""
declare -- one="1"' declare -- one="1"'
declare curchk
function setchk() 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 describe = and == operators
it succeeds on string equality it succeeds on string equality
expect setchk var = val expect setchk var = val
@ -72,7 +76,8 @@ describe set
to succeed to succeed
end 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 it fails on a mismatch
expect setchk \ expect setchk \
long =~ fo+ baX baz\$ long =~ fo+ baX baz\$
@ -198,10 +203,11 @@ describe set
# primarily for safety and strict documentation, but no other tests make # primarily for safety and strict documentation, but no other tests make
# sense at the moment # sense at the moment
it fails on unrecognized operators it fails on unrecognized operators
# shell injection (not that this is realistically a problem, because we # shell injection (not that this is realistically a problem, because
# can execute arbitrary shell code anyway) # we can execute arbitrary shell code anyway)
expect setchk var "!= foo -a 1 -eq" 1 expect setchk var "!= foo -a 1 -eq" 1
to fail to fail
end end
end end
done