Initial `and' declaration support

stderr
Mike Gerwitz 2014-05-09 21:48:09 -04:00
parent ca527165aa
commit d2e8d21ac5
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
2 changed files with 57 additions and 0 deletions

View File

@ -174,6 +174,22 @@ to()
}
##
# Declares additional expectations for the preceding premise
and()
{
__spec_caller="$(caller)"
# the most recently popped value should be an expect premise, implying
# that an expectation declaration implicitly popped it
_sstack-unpop
_sstack-assert-within :expect and $(caller) \
"follow an expectation as part of"
"$@"
}
##
# Outputs failure details and exits
#

View File

@ -208,5 +208,46 @@ describe expect
'; to succeed
end
end
describe and
# technically, we want this to be permitted after any declaration, but
# we do not yet support any others
it must appear after a "'to'" declaration
expect test-run <<< '
describe foo
it should fail
expect true
# missing "to"
and to succeed
end
end
'; to fail
end
it adds additional expectations to preceding declaration
# impossible condition
expect test-run <<< '
describe foo
it should fail
expect true
to succeed
and to fail
end
end
'; to fail
# redundant to demonstrate that it does not always fail
expect test-run <<< '
describe foo
it should fail
expect true
to succeed
and to succeed
end
end
'; to succeed
end
end
end