| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library initialize.transformer_test; | 4 library initialize.transformer_test; |
| 5 | 5 |
| 6 import 'common.dart'; | 6 import 'common.dart'; |
| 7 import 'package:analyzer/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
| 8 import 'package:dart_style/dart_style.dart'; | 8 import 'package:dart_style/dart_style.dart'; |
| 9 import 'package:initialize/transformer.dart'; | 9 import 'package:initialize/transformer.dart'; |
| 10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 new InitEntry(const i1.DynamicInit(3), const LibraryIdentifier(#web_
foo, null, 'index.dart')), | 186 new InitEntry(const i1.DynamicInit(3), const LibraryIdentifier(#web_
foo, null, 'index.dart')), |
| 187 new InitEntry(const i1.DynamicInit(1.2), const LibraryIdentifier(#we
b_foo, null, 'index.dart')), | 187 new InitEntry(const i1.DynamicInit(1.2), const LibraryIdentifier(#we
b_foo, null, 'index.dart')), |
| 188 new InitEntry(const i1.DynamicInit(true), const LibraryIdentifier(#w
eb_foo, null, 'index.dart')), | 188 new InitEntry(const i1.DynamicInit(true), const LibraryIdentifier(#w
eb_foo, null, 'index.dart')), |
| 189 new InitEntry(const i1.NamedArgInit(1, name: 'Bill'), const LibraryI
dentifier(#web_foo, null, 'index.dart')), | 189 new InitEntry(const i1.NamedArgInit(1, name: 'Bill'), const LibraryI
dentifier(#web_foo, null, 'index.dart')), |
| 190 ]); | 190 ]); |
| 191 | 191 |
| 192 i0.main(); | 192 i0.main(); |
| 193 } | 193 } |
| 194 ''') | 194 ''') |
| 195 }, []); | 195 }, []); |
| 196 |
| 197 testPhases('exported library annotations', phases, { |
| 198 'a|web/index.dart': ''' |
| 199 library web_foo; |
| 200 |
| 201 export 'foo.dart'; |
| 202 ''', |
| 203 'a|web/foo.dart': ''' |
| 204 @constInit |
| 205 library foo; |
| 206 |
| 207 import 'package:test_initializers/common.dart'; |
| 208 |
| 209 @constInit |
| 210 foo() {}; |
| 211 |
| 212 @constInit |
| 213 class Foo {} |
| 214 ''', |
| 215 // Mock out the Initialize package plus some initializers. |
| 216 'initialize|lib/initialize.dart': mockInitialize, |
| 217 'test_initializers|lib/common.dart': commonInitializers, |
| 218 }, { |
| 219 'a|web/index.initialize.dart': formatter.format(''' |
| 220 import 'package:initialize/src/static_loader.dart'; |
| 221 import 'package:initialize/initialize.dart'; |
| 222 import 'index.dart' as i0; |
| 223 import 'foo.dart' as i1; |
| 224 import 'package:test_initializers/common.dart' as i2; |
| 225 |
| 226 main() { |
| 227 initializers.addAll([ |
| 228 new InitEntry(i2.constInit, const LibraryIdentifier(#foo, null, 'foo
.dart')), |
| 229 new InitEntry(i2.constInit, i1.foo), |
| 230 new InitEntry(i2.constInit, i1.Foo), |
| 231 ]); |
| 232 |
| 233 i0.main(); |
| 234 } |
| 235 ''') |
| 236 }, []); |
| 237 |
| 238 testPhases('imports from exported libraries', phases, { |
| 239 'a|web/index.dart': ''' |
| 240 library web_foo; |
| 241 |
| 242 export 'foo.dart'; |
| 243 ''', |
| 244 'a|web/foo.dart': ''' |
| 245 library foo; |
| 246 |
| 247 import 'bar.dart'; |
| 248 ''', |
| 249 'a|web/bar.dart': ''' |
| 250 @constInit |
| 251 library bar; |
| 252 |
| 253 import 'package:test_initializers/common.dart'; |
| 254 |
| 255 @constInit |
| 256 bar() {}; |
| 257 |
| 258 @constInit |
| 259 class Bar {} |
| 260 ''', |
| 261 // Mock out the Initialize package plus some initializers. |
| 262 'initialize|lib/initialize.dart': mockInitialize, |
| 263 'test_initializers|lib/common.dart': commonInitializers, |
| 264 }, { |
| 265 'a|web/index.initialize.dart': formatter.format(''' |
| 266 import 'package:initialize/src/static_loader.dart'; |
| 267 import 'package:initialize/initialize.dart'; |
| 268 import 'index.dart' as i0; |
| 269 import 'bar.dart' as i1; |
| 270 import 'package:test_initializers/common.dart' as i2; |
| 271 |
| 272 main() { |
| 273 initializers.addAll([ |
| 274 new InitEntry(i2.constInit, const LibraryIdentifier(#bar, null, 'bar
.dart')), |
| 275 new InitEntry(i2.constInit, i1.bar), |
| 276 new InitEntry(i2.constInit, i1.Bar), |
| 277 ]); |
| 278 |
| 279 i0.main(); |
| 280 } |
| 281 ''') |
| 282 }, []); |
| 196 } | 283 } |
| 197 | 284 |
| 198 class SkipConstructorsPlugin extends InitializerPlugin { | 285 class SkipConstructorsPlugin extends InitializerPlugin { |
| 199 bool shouldApply(InitializerPluginData data) { | 286 bool shouldApply(InitializerPluginData data) { |
| 200 return data.initializer.annotationElement.element is ConstructorElement; | 287 return data.initializer.annotationElement.element is ConstructorElement; |
| 201 } | 288 } |
| 202 | 289 |
| 203 String apply(_) => null; | 290 String apply(_) => null; |
| 204 } | 291 } |
| 205 | 292 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 initializers.addAll([ | 336 initializers.addAll([ |
| 250 new InitEntry(i2.initMethod, i1.foo), | 337 new InitEntry(i2.initMethod, i1.foo), |
| 251 new InitEntry(i2.initMethod, i0.index), | 338 new InitEntry(i2.initMethod, i0.index), |
| 252 ]); | 339 ]); |
| 253 | 340 |
| 254 i0.main(); | 341 i0.main(); |
| 255 } | 342 } |
| 256 ''') | 343 ''') |
| 257 }, []); | 344 }, []); |
| 258 } | 345 } |
| OLD | NEW |