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

Side by Side Diff: tests/lib/mirrors/constructors_test.dart

Issue 18463003: Implement the invoke methods (invoke, getField, setField, newInstance, apply) as internal natives. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/dart_entry.cc ('K') | « runtime/vm/dart_entry.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.constructors_test; 5 library test.constructors_test;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 8
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 10
11 import 'stringify.dart'; 11 import 'stringify.dart';
12 12
13 class Foo { 13 class Foo {
14 } 14 }
15 15
16 class Bar { 16 class Bar {
17 Bar(); 17 Bar();
18 } 18 }
19 19
20 class Baz { 20 class Baz {
21 Baz.named(); 21 Baz.named();
22 } 22 }
23 23
24 class Biz { 24 class Biz {
25 Biz(); 25 Biz();
26 Biz.named(); 26 Biz.named();
27 } 27 }
28 28
29 class Buz {
30 var x;
31 Buz.generative(this.x);
32 Buz.redirecting(y) : this.generative(y*2);
33 factory Buz.faktory(y) => "Buz $y";
34 factory Buz.redirectingFactory(y) = Buz.faktory;
35 }
36
29 main() { 37 main() {
30 MirrorSystem mirrors = currentMirrorSystem(); 38 MirrorSystem mirrors = currentMirrorSystem();
31 ClassMirror fooMirror = reflectClass(Foo); 39 ClassMirror fooMirror = reflectClass(Foo);
32 Map<Symbol, MethodMirror> fooConstructors = fooMirror.constructors; 40 Map<Symbol, MethodMirror> fooConstructors = fooMirror.constructors;
33 ClassMirror barMirror = reflectClass(Bar); 41 ClassMirror barMirror = reflectClass(Bar);
34 Map<Symbol, MethodMirror> barConstructors = barMirror.constructors; 42 Map<Symbol, MethodMirror> barConstructors = barMirror.constructors;
35 ClassMirror bazMirror = reflectClass(Baz); 43 ClassMirror bazMirror = reflectClass(Baz);
36 Map<Symbol, MethodMirror> bazConstructors = bazMirror.constructors; 44 Map<Symbol, MethodMirror> bazConstructors = bazMirror.constructors;
37 ClassMirror bizMirror = reflectClass(Biz); 45 ClassMirror bizMirror = reflectClass(Biz);
38 Map<Symbol, MethodMirror> bizConstructors = bizMirror.constructors; 46 Map<Symbol, MethodMirror> bizConstructors = bizMirror.constructors;
(...skipping 16 matching lines...) Expand all
55 63
56 expect('[s()]', 64 expect('[s()]',
57 fooConstructors.values.map((m) => m.constructorName).toList()); 65 fooConstructors.values.map((m) => m.constructorName).toList());
58 expect('[s()]', 66 expect('[s()]',
59 barConstructors.values.map((m) => m.constructorName).toList()); 67 barConstructors.values.map((m) => m.constructorName).toList());
60 expect('[s(named)]', 68 expect('[s(named)]',
61 bazConstructors.values.map((m) => m.constructorName).toList()); 69 bazConstructors.values.map((m) => m.constructorName).toList());
62 expect('[s(), s(named)]', 70 expect('[s(), s(named)]',
63 bizConstructors.values.map((m) => m.constructorName).toList() 71 bizConstructors.values.map((m) => m.constructorName).toList()
64 ..sort(compareSymbols)); 72 ..sort(compareSymbols));
73
74 ClassMirror buzMirror = reflectClass(Buz);
75 Expect.equals(7,
76 buzMirror.newInstance(const Symbol('generative'),
77 [7]).reflectee.x);
78 Expect.equals(14,
79 buzMirror.newInstance(const Symbol('redirecting'),
80 [7]).reflectee.x);
81 Expect.equals('Buz 7',
82 buzMirror.newInstance(const Symbol('faktory'),
83 [7]).reflectee);
84 Expect.equals('Buz 7',
85 buzMirror.newInstance(const Symbol('redirectingFactory'),
86 [7]).reflectee);
65 } 87 }
OLDNEW
« runtime/vm/dart_entry.cc ('K') | « runtime/vm/dart_entry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698