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

Unified Diff: test_reflectable/test/new_instance_default_values_test.dart

Issue 1181413005: Implement newInstance in the transformer. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Created 5 years, 6 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: test_reflectable/test/new_instance_default_values_test.dart
diff --git a/test_reflectable/test/new_instance_default_values_test.dart b/test_reflectable/test/new_instance_default_values_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..83f7f0cbcfbd9e93da452fb60f1eb7cf8b78721d
--- /dev/null
+++ b/test_reflectable/test/new_instance_default_values_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2015, the Dart Team. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+
+// File being transformed by the reflectable transformer.
+// Uses `invoke`.
+
+library reflectable.test.to_be_transformed.new_instance_test;
eernst 2015/06/18 13:35:41 Looks like the separation I suggested in .status h
sigurdm 2015/06/19 07:50:54 No - this is an example of a default value that we
+
+import 'package:reflectable/reflectable.dart';
+import 'package:unittest/unittest.dart';
+
+class MyReflectable extends Reflectable {
+ const MyReflectable() : super(invokeConstructorsCapability);
+}
+
+const myReflectable = const MyReflectable();
+
+@myReflectable
+class A {
+ static const localConstant = 10;
+ A.optional([int z = localConstant]) : f = z;
+ int f = 0;
+}
+
+main() {
+ ClassMirror classMirror = myReflectable.reflectType(A);
+ test('newInstance named arguments default argument, local constant', () {
+ expect((classMirror.newInstance("optional", [], {}) as A).f, 10);
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698