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

Unified Diff: tests/lib/mirrors/metadata_constructor_arguments_test.dart

Issue 68333007: Handle undefined field/getter access from arguments to const constructors in metadata, and related … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « tests/lib/mirrors/metadata_allowed_values_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/metadata_constructor_arguments_test.dart
diff --git a/tests/lib/mirrors/metadata_constructor_arguments_test.dart b/tests/lib/mirrors/metadata_constructor_arguments_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..59066fa3a9de8db87a77d89ae4631326dacd297d
--- /dev/null
+++ b/tests/lib/mirrors/metadata_constructor_arguments_test.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2013, 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.
+
+// Regression test for Issue 13817.
+
+library test.metadata_constructor_arguments;
+
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+class Tag {
+ final name;
+ const Tag({named}) : this.name = named;
+}
+
+@Tag(named: undefined) /// 01: compile-time error
+class A {}
+
+@Tag(named: 'valid')
+class B {}
+
+@Tag(named: C.STATIC_FIELD)
+class C {
+ static const STATIC_FIELD = 3;
+}
+
+@Tag(named: D.instanceMethod()) /// 02: compile-time error
+class D {
+ instanceMethod() {}
+}
+
+@Tag(named: instanceField) /// 03: compile-time error
+class E {
+ var instanceField;
+}
+
+@Tag(named: F.nonConstStaticField) /// 04: compile-time error
+class F {
+ static var nonConstStaticField = 6;
+}
+
+@Tag(named: instanceMethod) /// 05: compile-time error
+class G {
+ instanceMethod() {}
+}
+
+checkMetadata(DeclarationMirror mirror, List expectedMetadata) {
+ Expect.listEquals(expectedMetadata.map(reflect).toList(), mirror.metadata);
+}
+
+main() {
+ reflectClass(A).metadata;
+ checkMetadata(reflectClass(B), [const Tag(named: 'valid')]);
+ checkMetadata(reflectClass(C), [const Tag(named: C.STATIC_FIELD)]);
+ reflectClass(D).metadata;
+ reflectClass(E).metadata;
+ reflectClass(F).metadata;
+ reflectClass(G).metadata;
+}
« no previous file with comments | « tests/lib/mirrors/metadata_allowed_values_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698