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

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

Issue 2770063002: Revert "Format all multitests" (Closed)
Patch Set: Created 3 years, 9 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/parameter_is_const_test.dart ('k') | tests/lib/mirrors/raw_type_test.dart » ('j') | 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 // This tests uses the multi-test "ok" feature: 5 // This tests uses the multi-test "ok" feature:
6 // none: Desired behaviour, passing on the VM. 6 // none: Desired behaviour, passing on the VM.
7 // 01: Trimmed version for dart2js. 7 // 01: Trimmed version for dart2js.
8 // 8 //
9 // TODO(rmacnak,ahe): Remove multi-test when VM and dart2js are on par. 9 // TODO(rmacnak,ahe): Remove multi-test when VM and dart2js are on par.
10 10
11 /** Test of [ParameterMirror]. */ 11 /** Test of [ParameterMirror]. */
12 library test.parameter_test; 12 library test.parameter_test;
13 13
14 @MirrorsUsed( 14 @MirrorsUsed(targets: const ['test.parameter_test', 'dart.core.int'], override: '*')
15 targets: const ['test.parameter_test', 'dart.core.int'], override: '*')
16 import 'dart:mirrors'; 15 import 'dart:mirrors';
17 16
18 import 'package:expect/expect.dart'; 17 import 'package:expect/expect.dart';
19 import 'stringify.dart'; 18 import 'stringify.dart';
20 19
21 class B { 20 class B {
22 B(); 21 B();
23 B.foo(int x); 22 B.foo(int x);
24 B.bar(int z, x); 23 B.bar(int z, x);
25 24
26 // TODO(6490): Currently only supported by the VM. 25 // TODO(6490): Currently only supported by the VM.
27 B.baz(final int x, int y, final int z); 26 B.baz(final int x, int y, final int z);
28 B.qux(int x, [int y = 3 + 1]); 27 B.qux(int x, [int y= 3 + 1]);
29 B.quux(int x, {String str: "foo"}); 28 B.quux(int x, {String str: "foo"});
30 B.corge({int x: 3 * 17, String str: "bar"}); 29 B.corge({int x: 3 * 17, String str: "bar"});
31 30
32 var _x; 31 var _x;
33 get x => _x; 32 get x => _x;
34 set x(final value) { 33 set x(final value) { _x = value; }
35 _x = value;
36 }
37 34
38 grault([int x]) {} 35 grault([int x]) {}
39 garply({int y}) {} 36 garply({int y}) {}
40 waldo(int z) {} 37 waldo(int z) {}
41 } 38 }
42 39
43 class C<S extends int, T> { 40 class C <S extends int, T> {
44 // TODO(6490): Currently only supported by the VM. 41 // TODO(6490): Currently only supported by the VM.
45 foo(int a, S b) => b; 42 foo(int a, S b) => b;
46 bar(S a, T b, num c) {} 43 bar(S a, T b, num c) {}
47 } 44 }
48 45
49 main() { 46 main() {
50 ClassMirror cm = reflectClass(B); 47 ClassMirror cm = reflectClass(B);
51 var constructors = new Map<Symbol, MethodMirror>(); 48 var constructors = new Map<Symbol, MethodMirror>();
52 cm.declarations.forEach((k, v) { 49 cm.declarations.forEach((k, v) {
53 if (v is MethodMirror && v.isConstructor) constructors[k] = v; 50 if (v is MethodMirror && v.isConstructor) constructors[k] = v;
54 }); 51 });
55 52
56 List<Symbol> constructorKeys = [ 53 List<Symbol> constructorKeys =
57 #B, 54 [#B, #B.bar, #B.baz, #B.foo, #B.quux, #B.qux, #B.corge];
58 #B.bar,
59 #B.baz,
60 #B.foo,
61 #B.quux,
62 #B.qux,
63 #B.corge
64 ];
65 Expect.setEquals(constructorKeys, constructors.keys); 55 Expect.setEquals(constructorKeys, constructors.keys);
66 56
67 MethodMirror unnamedConstructor = constructors[#B]; 57 MethodMirror unnamedConstructor = constructors[#B];
68 expect('Method(s(B) in s(B), constructor)', unnamedConstructor); 58 expect('Method(s(B) in s(B), constructor)', unnamedConstructor);
69 expect('[]', unnamedConstructor.parameters); 59 expect('[]', unnamedConstructor.parameters);
70 expect('Class(s(B) in s(test.parameter_test), top-level)', 60 expect('Class(s(B) in s(test.parameter_test), top-level)',
71 unnamedConstructor.returnType); 61 unnamedConstructor.returnType);
72 62
73 MethodMirror fooConstructor = constructors[#B.foo]; 63 MethodMirror fooConstructor = constructors[#B.foo];
74 expect('Method(s(B.foo) in s(B), constructor)', fooConstructor); 64 expect('Method(s(B.foo) in s(B), constructor)', fooConstructor);
75 expect( 65 expect('[Parameter(s(x) in s(B.foo),'
76 '[Parameter(s(x) in s(B.foo),' 66 ' type = Class(s(int) in s(dart.core), top-level))]',
77 ' type = Class(s(int) in s(dart.core), top-level))]', 67 fooConstructor.parameters);
78 fooConstructor.parameters);
79 expect('Class(s(B) in s(test.parameter_test), top-level)', 68 expect('Class(s(B) in s(test.parameter_test), top-level)',
80 fooConstructor.returnType); 69 fooConstructor.returnType);
81 70
82 MethodMirror barConstructor = constructors[#B.bar]; 71 MethodMirror barConstructor = constructors[#B.bar];
83 expect('Method(s(B.bar) in s(B), constructor)', barConstructor); 72 expect('Method(s(B.bar) in s(B), constructor)', barConstructor);
84 expect( 73 expect('[Parameter(s(z) in s(B.bar),'
85 '[Parameter(s(z) in s(B.bar),' 74 ' type = Class(s(int) in s(dart.core), top-level)), '
86 ' type = Class(s(int) in s(dart.core), top-level)), ' 75 'Parameter(s(x) in s(B.bar),'
87 'Parameter(s(x) in s(B.bar),' 76 ' type = Type(s(dynamic), top-level))]',
88 ' type = Type(s(dynamic), top-level))]', 77 barConstructor.parameters);
89 barConstructor.parameters);
90 expect('Class(s(B) in s(test.parameter_test), top-level)', 78 expect('Class(s(B) in s(test.parameter_test), top-level)',
91 barConstructor.returnType); 79 barConstructor.returnType);
92 80
93 // dart2js stops testing here. 81 // dart2js stops testing here.
94 return; // //# 01: ok 82 return; // //# 01: ok
95 83
96 MethodMirror bazConstructor = constructors[#B.baz]; 84 MethodMirror bazConstructor = constructors[#B.baz];
97 expect('Method(s(B.baz) in s(B), constructor)', bazConstructor); 85 expect('Method(s(B.baz) in s(B), constructor)', bazConstructor);
98 expect( 86 expect('[Parameter(s(x) in s(B.baz), final,'
99 '[Parameter(s(x) in s(B.baz), final,' 87 ' type = Class(s(int) in s(dart.core), top-level)), '
100 ' type = Class(s(int) in s(dart.core), top-level)), ' 88 'Parameter(s(y) in s(B.baz),'
101 'Parameter(s(y) in s(B.baz),' 89 ' type = Class(s(int) in s(dart.core), top-level)), '
102 ' type = Class(s(int) in s(dart.core), top-level)), ' 90 'Parameter(s(z) in s(B.baz), final,'
103 'Parameter(s(z) in s(B.baz), final,' 91 ' type = Class(s(int) in s(dart.core), top-level))]',
104 ' type = Class(s(int) in s(dart.core), top-level))]', 92 bazConstructor.parameters);
105 bazConstructor.parameters);
106 expect('Class(s(B) in s(test.parameter_test), top-level)', 93 expect('Class(s(B) in s(test.parameter_test), top-level)',
107 bazConstructor.returnType); 94 bazConstructor.returnType);
108 95
109 MethodMirror quxConstructor = constructors[#B.qux]; 96 MethodMirror quxConstructor = constructors[#B.qux];
110 expect('Method(s(B.qux) in s(B), constructor)', quxConstructor); 97 expect('Method(s(B.qux) in s(B), constructor)', quxConstructor);
111 expect( 98 expect('[Parameter(s(x) in s(B.qux),'
112 '[Parameter(s(x) in s(B.qux),' 99 ' type = Class(s(int) in s(dart.core), top-level)), '
113 ' type = Class(s(int) in s(dart.core), top-level)), ' 100 'Parameter(s(y) in s(B.qux), optional,'
114 'Parameter(s(y) in s(B.qux), optional,' 101 ' value = Instance(value = 4),'
115 ' value = Instance(value = 4),' 102 ' type = Class(s(int) in s(dart.core), top-level))]',
116 ' type = Class(s(int) in s(dart.core), top-level))]', 103 quxConstructor.parameters);
117 quxConstructor.parameters);
118 expect('Class(s(B) in s(test.parameter_test), top-level)', 104 expect('Class(s(B) in s(test.parameter_test), top-level)',
119 quxConstructor.returnType); 105 quxConstructor.returnType);
120 106
121 MethodMirror quuxConstructor = constructors[#B.quux]; 107 MethodMirror quuxConstructor = constructors[#B.quux];
122 expect('Method(s(B.quux) in s(B), constructor)', quuxConstructor); 108 expect('Method(s(B.quux) in s(B), constructor)', quuxConstructor);
123 expect( 109 expect('[Parameter(s(x) in s(B.quux),'
124 '[Parameter(s(x) in s(B.quux),' 110 ' type = Class(s(int) in s(dart.core), top-level)), '
125 ' type = Class(s(int) in s(dart.core), top-level)), ' 111 'Parameter(s(str) in s(B.quux), optional, named,'
126 'Parameter(s(str) in s(B.quux), optional, named,' 112 ' value = Instance(value = foo),'
127 ' value = Instance(value = foo),' 113 ' type = Class(s(String) in s(dart.core), top-level))]',
128 ' type = Class(s(String) in s(dart.core), top-level))]', 114 quuxConstructor.parameters);
129 quuxConstructor.parameters);
130 expect('Class(s(B) in s(test.parameter_test), top-level)', 115 expect('Class(s(B) in s(test.parameter_test), top-level)',
131 quuxConstructor.returnType); 116 quuxConstructor.returnType);
132 117
133 MethodMirror corgeConstructor = constructors[#B.corge]; 118 MethodMirror corgeConstructor = constructors[#B.corge];
134 expect('Method(s(B.corge) in s(B), constructor)', corgeConstructor); 119 expect('Method(s(B.corge) in s(B), constructor)', corgeConstructor);
135 expect( 120 expect('[Parameter(s(x) in s(B.corge), optional, named,'
136 '[Parameter(s(x) in s(B.corge), optional, named,' 121 ' value = Instance(value = 51),'
137 ' value = Instance(value = 51),' 122 ' type = Class(s(int) in s(dart.core), top-level)), '
138 ' type = Class(s(int) in s(dart.core), top-level)), ' 123 'Parameter(s(str) in s(B.corge), optional, named,'
139 'Parameter(s(str) in s(B.corge), optional, named,' 124 ' value = Instance(value = bar),'
140 ' value = Instance(value = bar),' 125 ' type = Class(s(String) in s(dart.core), top-level))]',
141 ' type = Class(s(String) in s(dart.core), top-level))]', 126 corgeConstructor.parameters);
142 corgeConstructor.parameters);
143 expect('Class(s(B) in s(test.parameter_test), top-level)', 127 expect('Class(s(B) in s(test.parameter_test), top-level)',
144 corgeConstructor.returnType); 128 corgeConstructor.returnType);
145 129
146 MethodMirror xGetter = cm.declarations[#x]; 130 MethodMirror xGetter = cm.declarations[#x];
147 expect('Method(s(x) in s(B), getter)', xGetter); 131 expect('Method(s(x) in s(B), getter)', xGetter);
148 expect('[]', xGetter.parameters); 132 expect('[]', xGetter.parameters);
149 133
150 MethodMirror xSetter = cm.declarations[const Symbol('x=')]; 134 MethodMirror xSetter = cm.declarations[const Symbol('x=')];
151 expect('Method(s(x=) in s(B), setter)', xSetter); 135 expect('Method(s(x=) in s(B), setter)', xSetter);
152 expect( 136 expect('[Parameter(s(value) in s(x=), final,'
153 '[Parameter(s(value) in s(x=), final,' 137 ' type = Type(s(dynamic), top-level))]',
154 ' type = Type(s(dynamic), top-level))]', 138 xSetter.parameters);
155 xSetter.parameters);
156 139
157 MethodMirror grault = cm.declarations[#grault]; 140 MethodMirror grault = cm.declarations[#grault];
158 expect('Method(s(grault) in s(B))', grault); 141 expect('Method(s(grault) in s(B))', grault);
159 expect( 142 expect('[Parameter(s(x) in s(grault), optional,'
160 '[Parameter(s(x) in s(grault), optional,' 143 ' type = Class(s(int) in s(dart.core), top-level))]',
161 ' type = Class(s(int) in s(dart.core), top-level))]', 144 grault.parameters);
162 grault.parameters);
163 expect('Instance(value = <null>)', grault.parameters[0].defaultValue); 145 expect('Instance(value = <null>)', grault.parameters[0].defaultValue);
164 146
165 MethodMirror garply = cm.declarations[#garply]; 147 MethodMirror garply = cm.declarations[#garply];
166 expect('Method(s(garply) in s(B))', garply); 148 expect('Method(s(garply) in s(B))', garply);
167 expect( 149 expect('[Parameter(s(y) in s(garply), optional, named,'
168 '[Parameter(s(y) in s(garply), optional, named,' 150 ' type = Class(s(int) in s(dart.core), top-level))]',
169 ' type = Class(s(int) in s(dart.core), top-level))]', 151 garply.parameters);
170 garply.parameters);
171 expect('Instance(value = <null>)', garply.parameters[0].defaultValue); 152 expect('Instance(value = <null>)', garply.parameters[0].defaultValue);
172 153
173 MethodMirror waldo = cm.declarations[#waldo]; 154 MethodMirror waldo = cm.declarations[#waldo];
174 expect('Method(s(waldo) in s(B))', waldo); 155 expect('Method(s(waldo) in s(B))', waldo);
175 expect( 156 expect('[Parameter(s(z) in s(waldo),'
176 '[Parameter(s(z) in s(waldo),' 157 ' type = Class(s(int) in s(dart.core), top-level))]',
177 ' type = Class(s(int) in s(dart.core), top-level))]', 158 waldo.parameters);
178 waldo.parameters);
179 expect('<null>', waldo.parameters[0].defaultValue); 159 expect('<null>', waldo.parameters[0].defaultValue);
180 160
181 cm = reflectClass(C); 161 cm = reflectClass(C);
182 162
183 MethodMirror fooInC = cm.declarations[#foo]; 163 MethodMirror fooInC = cm.declarations[#foo];
184 expect('Method(s(foo) in s(C))', fooInC); 164 expect('Method(s(foo) in s(C))', fooInC);
185 expect( 165 expect('[Parameter(s(a) in s(foo),'
186 '[Parameter(s(a) in s(foo),' 166 ' type = Class(s(int) in s(dart.core), top-level)), '
187 ' type = Class(s(int) in s(dart.core), top-level)), ' 167 'Parameter(s(b) in s(foo),'
188 'Parameter(s(b) in s(foo),' 168 ' type = TypeVariable(s(S) in s(C),'
189 ' type = TypeVariable(s(S) in s(C),' 169 ' upperBound = Class(s(int) in s(dart.core), top-level)))]',
190 ' upperBound = Class(s(int) in s(dart.core), top-level)))]', 170 fooInC.parameters);
191 fooInC.parameters);
192 171
193 MethodMirror barInC = cm.declarations[#bar]; 172 MethodMirror barInC = cm.declarations[#bar];
194 expect('Method(s(bar) in s(C))', barInC); 173 expect('Method(s(bar) in s(C))', barInC);
195 expect( 174 expect('[Parameter(s(a) in s(bar),'
196 '[Parameter(s(a) in s(bar),' 175 ' type = TypeVariable(s(S) in s(C),'
197 ' type = TypeVariable(s(S) in s(C),' 176 ' upperBound = Class(s(int) in s(dart.core), top-level))), '
198 ' upperBound = Class(s(int) in s(dart.core), top-level))), ' 177 'Parameter(s(b) in s(bar),'
199 'Parameter(s(b) in s(bar),' 178 ' type = TypeVariable(s(T) in s(C),'
200 ' type = TypeVariable(s(T) in s(C),' 179 ' upperBound = Class(s(Object) in s(dart.core), top-level))), '
201 ' upperBound = Class(s(Object) in s(dart.core), top-level))), ' 180 'Parameter(s(c) in s(bar),'
202 'Parameter(s(c) in s(bar),' 181 ' type = Class(s(num) in s(dart.core), top-level))]',
203 ' type = Class(s(num) in s(dart.core), top-level))]', 182 barInC.parameters);
204 barInC.parameters);
205 } 183 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/parameter_is_const_test.dart ('k') | tests/lib/mirrors/raw_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698