blob: 381a81e12a707dc34f60a900bb0c0bbce08b669d [file] [edit]
import 'package:matcher/expect.dart';
import 'package:test/scaffolding.dart';
void main() {
test('throwsFormatException', () {
// This check succeeds.
expect(
() => Error.throwWithStackTrace(
const FormatException('bad input'),
StackTrace.empty,
),
throwsFormatException,
);
// This check fails, the function returned instead of throwing.
expect(() => 42, throwsFormatException);
// Expected: throws <Instance of 'FormatException'>
// Actual: <Closure: () => int>
// Which: returned <42>
});
}