Initial `and' declaration support
parent
ca527165aa
commit
d2e8d21ac5
16
src/spec
16
src/spec
|
@ -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
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue