returnsNormally method
Expects that the function returns without throwing.
If the function runs without exception, return a Subject to check further expecations on the returned value.
If the function throws synchronously, this expectation will fail.
Implementation
Subject<T> returnsNormally() {
return context.nest<T>(() => ['returns a value'], (actual) {
try {
return Extracted.value(actual());
} catch (e, st) {
return Extracted.rejection(actual: [
'a function that throws'
], which: [
...prefixFirst('threw ', literal(e)),
...st.toString().split('\n')
]);
}
});
}