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

Unified Diff: pkg/dev_compiler/test/codegen/lib/mirrors/private_field_test.dart

Issue 2535273002: Better mirrors support for mixins and private fields (Closed)
Patch Set: Address comments Created 4 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
Index: pkg/dev_compiler/test/codegen/lib/mirrors/private_field_test.dart
diff --git a/pkg/dev_compiler/test/codegen/lib/mirrors/private_field_test.dart b/pkg/dev_compiler/test/codegen/lib/mirrors/private_field_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..14c110cbf0ebba9ca18ce94c7783da8823f0b745
--- /dev/null
+++ b/pkg/dev_compiler/test/codegen/lib/mirrors/private_field_test.dart
@@ -0,0 +1,36 @@
+// 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.
+
+library test.mixin;
+
+import 'dart:mirrors';
+
+import 'package:expect/expect.dart';
+
+import 'private_field_helper.dart';
+
+class Foo extends Bar {
+ int _field = 42;
+
+ static int _staticField = 99;
+}
+
+var privateSymbol = #_field;
+var publicSymbol = #field;
+
+main() {
+ Expect.equals(publicSymbol, publicSymbol2);
+ Expect.notEquals(privateSymbol, privateSymbol2);
+
+ var foo = new Foo();
+ var m = reflect(foo);
+ m.setField(privateSymbol, 38);
+ Expect.equals(38, foo._field);
+ m.setField(privateSymbol2, "world");
+ Expect.equals("world", foo.field);
+ Expect.equals("world", m.getField(publicSymbol).reflectee);
+
+ var type = reflectClass(Foo);
+ Expect.equals(99, type.getField(#_staticField).reflectee);
+}

Powered by Google App Engine
This is Rietveld 408576698