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

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

Issue 23020025: Implement ParameterMirror.{isFinal,hasDefaultValue,defaultValue}. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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/mirrors/parameter_dart_test.dart
diff --git a/tests/lib/mirrors/parameter_test.dart b/tests/lib/mirrors/parameter_dart_test.dart
similarity index 26%
copy from tests/lib/mirrors/parameter_test.dart
copy to tests/lib/mirrors/parameter_dart_test.dart
index aa5cdeea525215e3e88fe89d6a1c28597df13410..1c216d6581fa3543830e21f2dacbbd453fa232e6 100644
--- a/tests/lib/mirrors/parameter_test.dart
+++ b/tests/lib/mirrors/parameter_dart_test.dart
@@ -8,36 +8,46 @@ library test.parameter_test;
@MirrorsUsed(targets: 'test.parameter_test', override: '*')
import 'dart:mirrors';
+import 'package:expect/expect.dart';
import 'stringify.dart';
class B {
B();
B.foo(int x);
B.bar(int z, x);
+
+ // TODO(6490): Currently only supported by the VM.
+ B.baz(final int x, int y, final int z);
+ B.qux(int x, [int y= 3 + 1]);
+ B.quux(int x, {String str: "foo"});
+ B.corge({int x: 3 * 17, String str: "bar"});
rmacnak 2013/08/23 23:15:27 Include tests of parameters of getters and setters
Michael Lippautz (Google) 2013/08/24 00:17:21 Done.
}
main() {
- var constructors = reflectClass(B).constructors;
-
- expect('{B: Method(s(B) in s(B), constructor), '
- 'B.bar: Method(s(B.bar) in s(B), constructor), '
- 'B.foo: Method(s(B.foo) in s(B), constructor)}',
- constructors);
+ Map<Symbol, MethodMirror> constructors = reflectClass(B).constructors;
- var unnamedConstructor = constructors[new Symbol('B')];
+ List<Symbol> constructorKeys = [
+ const Symbol('B'), const Symbol('B.bar'), const Symbol('B.baz'),
+ const Symbol('B.foo'), const Symbol('B.quux'), const Symbol('B.qux'),
+ const Symbol('B.corge')];
+ Expect.setEquals(constructorKeys, constructors.keys);
+ MethodMirror unnamedConstructor = constructors[const Symbol('B')];
+ expect('Method(s(B) in s(B), constructor)', unnamedConstructor);
expect('[]', unnamedConstructor.parameters);
expect('Class(s(B) in s(test.parameter_test), top-level)',
unnamedConstructor.returnType);
- var fooConstructor = constructors[new Symbol('B.foo')];
+ MethodMirror fooConstructor = constructors[const Symbol('B.foo')];
+ expect('Method(s(B.foo) in s(B), constructor)', fooConstructor);
expect('[Parameter(s(x) in s(B.foo),'
' type = Class(s(int) in s(dart.core), top-level))]',
fooConstructor.parameters);
expect('Class(s(B) in s(test.parameter_test), top-level)',
fooConstructor.returnType);
- var barConstructor = constructors[new Symbol('B.bar')];
+ MethodMirror barConstructor = constructors[const Symbol('B.bar')];
+ expect('Method(s(B.bar) in s(B), constructor)', barConstructor);
expect('[Parameter(s(z) in s(B.bar),'
' type = Class(s(int) in s(dart.core), top-level)), '
'Parameter(s(x) in s(B.bar),'
@@ -46,5 +56,49 @@ main() {
expect('Class(s(B) in s(test.parameter_test), top-level)',
barConstructor.returnType);
- print(constructors);
+ MethodMirror bazConstructor = constructors[const Symbol('B.baz')];
+ expect('Method(s(B.baz) in s(B), constructor)', bazConstructor);
+ expect('[Parameter(s(x) in s(B.baz), final,'
+ ' type = Class(s(int) in s(dart.core), top-level)), '
+ 'Parameter(s(y) in s(B.baz),'
+ ' type = Class(s(int) in s(dart.core), top-level)), '
+ 'Parameter(s(z) in s(B.baz), final,'
+ ' type = Class(s(int) in s(dart.core), top-level))]',
+ bazConstructor.parameters);
+ expect('Class(s(B) in s(test.parameter_test), top-level)',
+ bazConstructor.returnType);
+
+ MethodMirror quxConstructor = constructors[const Symbol('B.qux')];
+ expect('Method(s(B.qux) in s(B), constructor)', quxConstructor);
+ expect('[Parameter(s(x) in s(B.qux),'
+ ' type = Class(s(int) in s(dart.core), top-level)), '
+ 'Parameter(s(y) in s(B.qux), optional,'
+ ' value = Instance(value = 4),'
+ ' type = Class(s(int) in s(dart.core), top-level))]',
+ quxConstructor.parameters);
+ expect('Class(s(B) in s(test.parameter_test), top-level)',
+ quxConstructor.returnType);
+
+ MethodMirror quuxConstructor = constructors[const Symbol('B.quux')];
+ expect('Method(s(B.quux) in s(B), constructor)', quuxConstructor);
+ expect('[Parameter(s(x) in s(B.quux),'
+ ' type = Class(s(int) in s(dart.core), top-level)), '
+ 'Parameter(s(str) in s(B.quux), optional, named,'
+ ' value = Instance(value = foo),'
+ ' type = Class(s(String) in s(dart.core), top-level))]',
+ quuxConstructor.parameters);
+ expect('Class(s(B) in s(test.parameter_test), top-level)',
+ quuxConstructor.returnType);
+
+ MethodMirror corgeConstructor = constructors[const Symbol('B.corge')];
+ expect('Method(s(B.corge) in s(B), constructor)', corgeConstructor);
+ expect('[Parameter(s(x) in s(B.corge), optional, named,'
+ ' value = Instance(value = 51),'
+ ' type = Class(s(int) in s(dart.core), top-level)), '
+ 'Parameter(s(str) in s(B.corge), optional, named,'
+ ' value = Instance(value = bar),'
+ ' type = Class(s(String) in s(dart.core), top-level))]',
+ corgeConstructor.parameters);
+ expect('Class(s(B) in s(test.parameter_test), top-level)',
+ corgeConstructor.returnType);
}

Powered by Google App Engine
This is Rietveld 408576698