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

Unified Diff: tests/language/assertion_initializer_const_error2_test.dart

Issue 2962153002: Add assert-in-initializer-list to formal specification. (Closed)
Patch Set: Update status files more. Created 3 years, 5 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 | « pkg/analyzer/lib/source/embedder.dart ('k') | tests/language/assertion_initializer_const_error_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/assertion_initializer_const_error2_test.dart
diff --git a/tests/language/assertion_initializer_const_error2_test.dart b/tests/language/assertion_initializer_const_error2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a58ff670e1c0e94a77ef000bf2bdc94a9316e950
--- /dev/null
+++ b/tests/language/assertion_initializer_const_error2_test.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 201, 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=--assert_initializer
+//
+// Dart test program testing assert statements.
+
+import "package:expect/expect.dart";
+
+class C {
+ final int x;
+ // Const constructors.
+ const C.cc01(this.x, y)
+ : assert(x < y) //# cc01: compile-time error
+ ;
+ const C.cc02(x, y) : x = x,
+ assert(x < y) //# cc02: compile-time error
+ ;
+ const C.cc03(x, y) :
+ assert(x < y), //# cc03: compile-time error
+ x = x;
+ const C.cc04(this.x, y) : super()
+ , assert(x < y) //# cc04: compile-time error
+ ;
+ const C.cc05(this.x, y) :
+ assert(x < y), //# cc05: compile-time error
+ super();
+ const C.cc06(x, y) : x = x, super()
+ , assert(x < y) //# cc06: compile-time error
+ ;
+ const C.cc07(x, y) :
+ assert(x < y), //# cc07: compile-time error
+ super(), x = x;
+ const C.cc08(x, y) :
+ assert(x < y), //# cc08: compile-time error
+ super(), x = x
+ , assert(y > x) //# cc08: continued
+ ;
+ const C.cc09(this.x, y)
+ : assert(x < y, "$x < $y") //# cc09: compile-time error
+ ;
+ const C.cc10(this.x, y)
+ : assert(x < y,) //# cc10: compile-time error
+ ;
+ const C.cc11(this.x, y)
+ : assert(x < y, "$x < $y",) //# cc11: compile-time error
+ ;
+}
+
+
+main() {
+ // Failing assertions in const invociations are compile-time errors.
+ const C.cc01(2, 1); //# cc01: compile-time error
+ const C.cc02(2, 1); //# cc02: compile-time error
+ const C.cc03(2, 1); //# cc03: compile-time error
+ const C.cc04(2, 1); //# cc04: compile-time error
+ const C.cc05(2, 1); //# cc05: compile-time error
+ const C.cc06(2, 1); //# cc06: compile-time error
+ const C.cc07(2, 1); //# cc07: compile-time error
+ const C.cc08(2, 1); //# cc08: compile-time error
+ const C.cc09(2, 1); //# cc09: compile-time error
+ const C.cc10(2, 1); //# cc10: compile-time error
+ const C.cc11(2, 1); //# cc11: compile-time error
+}
« no previous file with comments | « pkg/analyzer/lib/source/embedder.dart ('k') | tests/language/assertion_initializer_const_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698