| Index: pkg/expect/lib/expect.dart
|
| diff --git a/pkg/expect/lib/expect.dart b/pkg/expect/lib/expect.dart
|
| index 3becc94b9dbbb66fb4c1d0636130a6a2ad613cab..22449c12d4b2bd97f6fca16912d30f12fde2d3db 100644
|
| --- a/pkg/expect/lib/expect.dart
|
| +++ b/pkg/expect/lib/expect.dart
|
| @@ -503,3 +503,28 @@ class TrustTypeAnnotations {
|
| class AssumeDynamic {
|
| const AssumeDynamic();
|
| }
|
| +
|
| +/// Is true iff type assertions are enabled.
|
| +final bool typeAssertionsEnabled = (() {
|
| + try {
|
| + var i = 42;
|
| + String s = i;
|
| + } on TypeError catch (e) {
|
| + return true;
|
| + }
|
| + return false;
|
| +})();
|
| +
|
| +/// Is true iff `assert` statements are enabled.
|
| +final bool assertStatementsEnabled = (() {
|
| + try {
|
| + assert(false);
|
| + } on AssertionError catch (e) {
|
| + return true;
|
| + }
|
| + return false;
|
| +})();
|
| +
|
| +/// Is true iff checked mode is enabled.
|
| +final bool checkedModeEnabled =
|
| + typeAssertionsEnabled && assertStatementsEnabled;
|
|
|