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

Unified Diff: tests/language/deferred_constraints_constants_test.dart

Issue 195983006: Constrain constant references from deferred libraries (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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: tests/language/deferred_constraints_constants_test.dart
diff --git a/tests/language/deferred_constraints_constants_test.dart b/tests/language/deferred_constraints_constants_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..be446424d67a309b17d019136cb1bb6a95f15015
--- /dev/null
+++ b/tests/language/deferred_constraints_constants_test.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2014, 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.
+
+import "dart:async";
+import 'package:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+
+@lazy import "deferred_constraints_constants_lib.dart" as lib;
+
+const lazy = const DeferredLibrary('lib');
+
+const myConst1 =
+ lib.constantInstance; /// reference1: compile-time error
+ /* /// reference1: continued
+ 499;
+ */ /// reference1: continued
+const myConst2 =
+ lib.Const.instance; /// reference2: compile-time error
+ /* /// reference2: continued
+ 499;
+ */ /// reference2: continued
+
+void f1({a:
+ const lib.Const() /// default_argument1: compile-time error
+ /* /// default_argument1: continued
+ 499
+ */ /// default_argument1: continued
+}) {}
+
+void f2({a:
+ lib.constantInstance /// default_argument2: compile-time error
+ /* /// default_argument2: continued
+ 499
+ */ /// default_argument2: continued
+}) {}
+
+@lib.Const() /// metadata1: compile-time error
+class H1 {}
+@lib.Const.instance /// metadata2: compile-time error
+class H2 {}
+@lib.Const.namedConstructor() /// metadata3: compile-time error
+class H3 {}
+
+void main() {
+ var a1 = myConst1;
+ var a2 = myConst2;
+
+ asyncStart();
+ lazy.load().then((_) {
+ var instance = lib.constantInstance;
+ var c1 = const lib.Const(); /// constructor1: compile-time error
+ var c2 = const lib.Const.namedConstructor(); /// constructor2: compile-time error
+ f1();
+ f2();
+ var constInstance = lib.constantInstance; /// reference_after_load: ok
+ var h1 = new H1();
+ var h2 = new H2();
+ var h3 = new H3();
+ asyncEnd();
+ });
+}
+
« no previous file with comments | « tests/language/deferred_constraints_constants_lib.dart ('k') | tests/language/deferred_constraints_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698