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

Unified Diff: tests/standalone/fixed_precision_double_test.dart

Issue 2215143002: Update new test to check asserts only if they are enabled and remove VM option. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/fixed_precision_double_test.dart
diff --git a/tests/standalone/fixed_precision_double_test.dart b/tests/standalone/fixed_precision_double_test.dart
index 16fed504efd169ea6845c77d476afc8326b74efe..350bbc3605a23f02b91ea483eec77902bf4b9c17 100644
--- a/tests/standalone/fixed_precision_double_test.dart
+++ b/tests/standalone/fixed_precision_double_test.dart
@@ -1,7 +1,6 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// VMOptions=--enable_asserts
import "package:expect/expect.dart";
@@ -36,6 +35,16 @@ assertP(double d) {
assert(d == d.p);
}
+bool assertionsEnabled() {
+ try {
+ assert(false);
+ return false;
+ } on AssertionError catch (e) {
+ return true;
+ }
+ return false;
+}
+
main() {
// The getter p keeps only 20 (by default) bits after the decimal point.
Expect.equals(0.0, 0.0.p); // 0.0 has no 1-bit after the decimal point.
@@ -63,9 +72,11 @@ main() {
Expect.isTrue(double.NEGATIVE_INFINITY.p.isNegative);
// Check use of assert to verify precision.
- assertP(1.5);
- assertP(1.1.p);
- Expect.throws(() => assertP(1.1), (e) => e is AssertionError);
- assertP(1.23456789.p);
- Expect.throws(() => assertP(1.23456789), (e) => e is AssertionError);
+ if (assertionsEnabled()) {
+ assertP(1.5);
+ assertP(1.1.p);
+ Expect.throws(() => assertP(1.1), (e) => e is AssertionError);
+ assertP(1.23456789.p);
+ Expect.throws(() => assertP(1.23456789), (e) => e is AssertionError);
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698