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

Unified Diff: tests/lib_strong/mirrors/field_metadata2_test.dart

Issue 2861503002: fix #29530, field metadata generation (Closed)
Patch Set: wip Created 3 years, 8 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/lib_strong/mirrors/field_metadata2_test.dart
diff --git a/tests/lib_strong/mirrors/field_metadata2_test.dart b/tests/lib_strong/mirrors/field_metadata2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e3dc834ac194460e243c528be01523bc7160e1d7
--- /dev/null
+++ b/tests/lib_strong/mirrors/field_metadata2_test.dart
@@ -0,0 +1,26 @@
+// compile options: --emit-metadata
+// Copyright (c) 2017, 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.
+
+// Run essentially the same test, but with emit-metadata compile option,
+// which allows us to reflect on the fields.
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+import 'field_metadata_test.dart' as field_metadata_test;
+import 'field_metadata_test.dart' show Foo, Bar;
+
+void main() {
+ // Make sure the other test still works.
+ field_metadata_test.main();
+
+ // Check that we can now reflect on the annotations.
+ dynamic f = new Foo();
+ var members = reflect(f).type.declarations;
+ var bar = members[#x].metadata.first.reflectee as Bar;
+ Expect.equals(bar.name, 'bar');
+
+ var baz = members[#y].metadata.first.reflectee as Bar;
+ Expect.equals(baz.name, 'baz');
+}
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart ('k') | tests/lib_strong/mirrors/field_metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698