Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: pkg/expect/lib/expect.dart

Issue 2879153005: Add support to dart2js for option --enable-asserts. (Closed)
Patch Set: Formatting Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/expect/lib/expect.dart
diff --git a/pkg/expect/lib/expect.dart b/pkg/expect/lib/expect.dart
index 8e312063943e96fc9f47f741e98234673b6e60c4..d25e3e065517a2274164bcc56b27955ce62a5874 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;

Powered by Google App Engine
This is Rietveld 408576698