OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test that parameters keep their names in the output. | 4 // Test that parameters keep their names in the output. |
5 | 5 |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'memory_compiler.dart'; | 9 import 'memory_compiler.dart'; |
10 | 10 |
11 const String TEST_BASIC= r""" | 11 const String TEST_BASIC = r""" |
12 library main; | 12 library main; |
13 | 13 |
14 int a = 2; | 14 int a = 2; |
15 | 15 |
16 class c { | 16 class c { |
17 final int m; | 17 final int m; |
18 c(this.m) { | 18 c(this.m) { |
19 () {} (); // TODO (sigurdm): Empty closure, hack to avoid inlining. | 19 () {} (); // TODO (sigurdm): Empty closure, hack to avoid inlining. |
20 a = 1; | 20 a = 1; |
21 } | 21 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 await jsonTest(TEST_CLOSURES, (map) { | 134 await jsonTest(TEST_CLOSURES, (map) { |
135 var functions = map['elements']['function'].values; | 135 var functions = map['elements']['function'].values; |
136 Expect.isTrue(functions.any((fn) { | 136 Expect.isTrue(functions.any((fn) { |
137 return fn['name'] == 'bar' && fn['children'].length == 11; | 137 return fn['name'] == 'bar' && fn['children'].length == 11; |
138 })); | 138 })); |
139 Expect.isTrue(functions.any((fn) { | 139 Expect.isTrue(functions.any((fn) { |
140 return fn['name'] == 'foo' && fn['children'].length == 10; | 140 return fn['name'] == 'foo' && fn['children'].length == 10; |
141 })); | 141 })); |
142 }); | 142 }); |
143 | 143 |
144 await jsonTest(TEST_STATICS, (map) { | 144 await jsonTest(TEST_STATICS, (map) { |
145 var functions = map['elements']['function'].values; | 145 var functions = map['elements']['function'].values; |
146 var classes = map['elements']['class'].values; | 146 var classes = map['elements']['class'].values; |
147 Expect.isTrue(functions.any((fn) { | 147 Expect.isTrue(functions.any((fn) { |
148 return fn['name'] == 'does_something'; | 148 return fn['name'] == 'does_something'; |
149 })); | 149 })); |
150 Expect.isTrue(classes.any((cls) { | 150 Expect.isTrue(classes.any((cls) { |
151 return cls['name'] == 'ContainsStatics' && | 151 return cls['name'] == 'ContainsStatics' && cls['children'].length >= 1; |
152 cls['children'].length >= 1; | |
153 })); | 152 })); |
154 }); | 153 }); |
155 | 154 |
156 await jsonTest(TEST_INLINED_1, (map) { | 155 await jsonTest(TEST_INLINED_1, (map) { |
157 var functions = map['elements']['function'].values; | 156 var functions = map['elements']['function'].values; |
158 var classes = map['elements']['class'].values; | 157 var classes = map['elements']['class'].values; |
159 Expect.isTrue(functions.any((fn) { | 158 Expect.isTrue(functions.any((fn) { |
160 return fn['name'] == 'double' && | 159 return fn['name'] == 'double' && fn['inlinedCount'] == 1; |
161 fn['inlinedCount'] == 1; | |
162 })); | 160 })); |
163 Expect.isTrue(classes.any((cls) { | 161 Expect.isTrue(classes.any((cls) { |
164 return cls['name'] == 'Doubler' && | 162 return cls['name'] == 'Doubler' && cls['children'].length >= 1; |
165 cls['children'].length >= 1; | |
166 })); | 163 })); |
167 }); | 164 }); |
168 | 165 |
169 await jsonTest(TEST_INLINED_2, (map) { | 166 await jsonTest(TEST_INLINED_2, (map) { |
170 var functions = map['elements']['function'].values; | 167 var functions = map['elements']['function'].values; |
171 var deps = map['holding']; | 168 var deps = map['holding']; |
172 var main_ = functions.firstWhere((v) => v['name'] == 'main'); | 169 var main_ = functions.firstWhere((v) => v['name'] == 'main'); |
173 var fn1 = functions.firstWhere((v) => v['name'] == 'funcA'); | 170 var fn1 = functions.firstWhere((v) => v['name'] == 'funcA'); |
174 var fn2 = functions.firstWhere((v) => v['name'] == 'funcB'); | 171 var fn2 = functions.firstWhere((v) => v['name'] == 'funcB'); |
175 Expect.isTrue(main_ != null); | 172 Expect.isTrue(main_ != null); |
176 Expect.isTrue(fn1 != null); | 173 Expect.isTrue(fn1 != null); |
177 Expect.isTrue(fn2 != null); | 174 Expect.isTrue(fn2 != null); |
178 Expect.isTrue(deps.containsKey(main_['id'])); | 175 Expect.isTrue(deps.containsKey(main_['id'])); |
179 Expect.isTrue(deps.containsKey(fn1['id'])); | 176 Expect.isTrue(deps.containsKey(fn1['id'])); |
180 Expect.isTrue(deps.containsKey(fn2['id'])); | 177 Expect.isTrue(deps.containsKey(fn2['id'])); |
181 Expect.isTrue(deps[main_['id']].any((dep) => dep['id'] == fn1['id'])); | 178 Expect.isTrue(deps[main_['id']].any((dep) => dep['id'] == fn1['id'])); |
182 Expect.isTrue(deps[fn1['id']].any((dep) => dep['id'] == fn2['id'])); | 179 Expect.isTrue(deps[fn1['id']].any((dep) => dep['id'] == fn2['id'])); |
183 }); | 180 }); |
184 } | 181 } |
OLD | NEW |