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

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

Issue 2999373002: Migrated test block 218 to Dart 2.0. (Closed)
Patch Set: Addressed Bob's comments. Created 3 years, 3 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
« no previous file with comments | « tests/lib/mirrors/closure_mirror_import2.dart ('k') | tests/lib_2/lib_2.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 library test.constructor_test;
6
7 @MirrorsUsed(targets: const [A])
8 import 'dart:mirrors';
9 import 'package:expect/expect.dart';
10
11 class A {
12 factory A([x, y]) = B;
13 factory A.more([x, y]) = B.more;
14 factory A.oneMore(x, [y]) = B.more;
15 }
16
17 class B implements A {
18 final _x, _y, _z;
19
20 B([x = 'x', y = 'y'])
21 : _x = x,
22 _y = y,
23 _z = null;
24
25 B.more([x = 'x', y = 'y', z = 'z'])
26 : _x = x,
27 _y = y,
28 _z = z;
29
30 toString() => 'B(x=$_x, y=$_y, z=$_z)';
31 }
32
33 main() {
34 var d1 = new A(1);
35 Expect.equals('B(x=1, y=y, z=null)', '$d1', 'direct 1');
36
37 var d2 = new A.more(1);
38 Expect.equals('B(x=1, y=y, z=z)', '$d2', 'direct 2');
39
40 ClassMirror cm = reflectClass(A);
41
42 var v1 = cm.newInstance(const Symbol(''), []).reflectee;
43 var v2 = cm.newInstance(const Symbol(''), [1]).reflectee;
44 var v3 = cm.newInstance(const Symbol(''), [2, 3]).reflectee;
45
46 Expect.equals('B(x=x, y=y, z=null)', '$v1', 'unnamed 1');
47 Expect.equals('B(x=1, y=y, z=null)', '$v2', 'unnamed 2');
48 Expect.equals('B(x=2, y=3, z=null)', '$v3', 'unnamed 3');
49
50 var m1 = cm.newInstance(const Symbol('more'), []).reflectee;
51 var m2 = cm.newInstance(const Symbol('more'), [1]).reflectee;
52 var m3 = cm.newInstance(const Symbol('more'), [2, 3]).reflectee;
53
54 Expect.equals('B(x=x, y=y, z=z)', '$m1', 'more 1');
55 Expect.equals('B(x=1, y=y, z=z)', '$m2', 'more 2');
56 Expect.equals('B(x=2, y=3, z=z)', '$m3', 'more 3');
57
58 var o1 = cm.newInstance(const Symbol('oneMore'), [1]).reflectee;
59 var o2 = cm.newInstance(const Symbol('oneMore'), [2, 3]).reflectee;
60
61 Expect.equals('B(x=1, y=y, z=z)', '$o1', 'oneMore one arg');
62 Expect.equals('B(x=2, y=3, z=z)', '$o2', 'oneMore two args');
63 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/closure_mirror_import2.dart ('k') | tests/lib_2/lib_2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698