feat(nix/runTestsuite): add assertDoesNotThrow
assertDoesNotThrow is like assertThrows, but fails if the expression throws. In that case the new unexpected-throw branch of AssertErrorContext is returned. Change-Id: I7195eb5df8965456e9ab9b69e35ec96b33f00a35 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2476 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
00f79da358
commit
fde23c5d0a
1 changed files with 7 additions and 0 deletions
|
@ -61,6 +61,7 @@ let
|
|||
should-throw = struct "should-throw" {
|
||||
expr = any;
|
||||
};
|
||||
unexpected-throw = struct "unexpected-throw" { };
|
||||
};
|
||||
|
||||
# The result of an assert,
|
||||
|
@ -119,6 +120,11 @@ let
|
|||
in
|
||||
assertBoolContext context desc (throws expr));
|
||||
|
||||
# assert that the expression does not throw when `deepSeq`-ed
|
||||
assertDoesNotThrow = defun [ string any AssertResult ]
|
||||
(desc: expr:
|
||||
assertBoolContext { unexpected-throw = { }; } desc (!(throws expr)));
|
||||
|
||||
# Annotate a bunch of asserts with a descriptive name
|
||||
it = desc: asserts: {
|
||||
it-desc = desc;
|
||||
|
@ -171,6 +177,7 @@ in {
|
|||
inherit
|
||||
assertEq
|
||||
assertThrows
|
||||
assertDoesNotThrow
|
||||
it
|
||||
runTestsuite
|
||||
;
|
||||
|
|
Loading…
Reference in a new issue