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

Unified Diff: tests/compiler/dart2js/mirrors/default_value_test.dart

Issue 150693005: Fix ParameterMirror.hasDefaultValue/defaultValue in source mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix handling of external parameters Created 6 years, 10 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/compiler/dart2js/mirrors/default_value_test.dart
diff --git a/tests/compiler/dart2js/mirrors/default_value_test.dart b/tests/compiler/dart2js/mirrors/default_value_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..53b872118c54b6d16a1d59f8afd2373331fa2310
--- /dev/null
+++ b/tests/compiler/dart2js/mirrors/default_value_test.dart
@@ -0,0 +1,62 @@
+// 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.
+
+import "dart:mirrors";
+
+import "package:async_helper/async_helper.dart";
+import "package:expect/expect.dart";
+import "../memory_compiler.dart";
+
+const SOURCE = const {
+ 'main.dart': """
+library main;
+
+class Class {
+ var a, b, c, d, e, f, g, h;
+ Class.optional(this.a, int b, void this.c(),
+ [this.d, int this.e, void this.f(),
+ this.g = 0, int this.h = 0]);
+ Class.named(this.a, int b, void this.c(),
+ {this.d, int this.e, void this.f(),
+ this.g: 0, int this.h: 0});
+ methodOptional(a, int b, void c(),
+ [d, int e, void f(),
+ g = 0, int h = 0]) {}
+ methodNamed(a, int b, void c(),
+ {d, int e, void f(),
+ g: 0, int h: 0}) {}
+}
+""",
+};
+
+main() {
+ asyncTest(() => mirrorSystemFor(SOURCE).then((MirrorSystem mirrors) {
+ LibraryMirror dartCore = mirrors.libraries[Uri.parse('memory:main.dart')];
+ ClassMirror classMirror = dartCore.declarations[#Class];
+ testMethod(classMirror.declarations[#optional]);
+ testMethod(classMirror.declarations[#named]);
+ testMethod(classMirror.declarations[#methodOptional]);
+ testMethod(classMirror.declarations[#methodNamed]);
+ }));
+}
+
+testMethod(MethodMirror mirror) {
+ Expect.equals(8, mirror.parameters.length);
+ for (int i = 0 ; i < 6 ; i++) {
+ testParameter(mirror.parameters[i], false);
+ }
+ for (int i = 6 ; i < 8 ; i++) {
+ testParameter(mirror.parameters[i], true);
+ }
+}
+
+testParameter(ParameterMirror mirror, bool expectDefaultValue) {
+ if (expectDefaultValue) {
+ Expect.isTrue(mirror.hasDefaultValue);
+ Expect.isNotNull(mirror.defaultValue);
+ } else {
+ Expect.isFalse(mirror.hasDefaultValue);
+ Expect.isNull(mirror.defaultValue);
+ }
+}
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/mirrors/mirrors_reader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698