| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Dart2js can take a long time to compile dart code, so we increase the timeout | 5 // Dart2js can take a long time to compile dart code, so we increase the timeout |
| 6 // to cope with that. | 6 // to cope with that. |
| 7 @Timeout.factor(3) | 7 @Timeout.factor(3) |
| 8 | 8 |
| 9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 | 10 |
| 11 import '../descriptor.dart' as d; | 11 import '../descriptor.dart' as d; |
| 12 import '../test_pub.dart'; | 12 import '../test_pub.dart'; |
| 13 | 13 |
| 14 const MAIN = """ | 14 const MAIN = """ |
| 15 import 'dart:async'; | 15 import 'dart:async'; |
| 16 | 16 |
| 17 import 'a.dart' deferred as a; | 17 import 'a.dart' deferred as a; |
| 18 import 'b.dart' deferred as b; | 18 import 'b.dart' deferred as b; |
| 19 | 19 |
| 20 void main() { | 20 void main() { |
| 21 Future.wait([lazyA.loadLibrary(), lazyB.loadLibrary()]).then((_) { | 21 Future.wait([lazyA.loadLibrary(), lazyB.loadLibrary()]).then((_) { |
| 22 a.fn(); | 22 a.fn(); |
| 23 b.fn(); | 23 b.fn(); |
| 24 }); | 24 }); |
| 25 } | 25 } |
| 26 """; | 26 """; |
| 27 | 27 |
| 28 const A = """ | 28 const A = """ |
| 29 library a; | |
| 30 | |
| 31 fn() => print("a"); | 29 fn() => print("a"); |
| 32 """; | 30 """; |
| 33 | 31 |
| 34 const B = """ | 32 const B = """ |
| 35 library b; | |
| 36 | |
| 37 fn() => print("b"); | 33 fn() => print("b"); |
| 38 """; | 34 """; |
| 39 | 35 |
| 40 main() { | 36 main() { |
| 41 integration("compiles deferred libraries to separate outputs", () { | 37 integration("compiles deferred libraries to separate outputs", () { |
| 42 d.dir(appPath, [ | 38 d.dir(appPath, [ |
| 43 d.appPubspec(), | 39 d.appPubspec(), |
| 44 d.dir('web', [ | 40 d.dir('web', [ |
| 45 d.file('main.dart', MAIN), | 41 d.file('main.dart', MAIN), |
| 46 d.file('a.dart', A), | 42 d.file('a.dart', A), |
| 47 d.file('b.dart', B) | 43 d.file('b.dart', B) |
| 48 ]) | 44 ]) |
| 49 ]).create(); | 45 ]).create(); |
| 50 | 46 |
| 51 pubGet(); | 47 pubGet(); |
| 52 schedulePub(args: ["build"], | 48 schedulePub(args: ["build"], |
| 53 output: new RegExp(r'Built 3 files to "build".')); | 49 output: new RegExp(r'Built 3 files to "build".')); |
| 54 | 50 |
| 55 d.dir(appPath, [ | 51 d.dir(appPath, [ |
| 56 d.dir('build', [ | 52 d.dir('build', [ |
| 57 d.dir('web', [ | 53 d.dir('web', [ |
| 58 d.matcherFile('main.dart.js', isNot(isEmpty)), | 54 d.matcherFile('main.dart.js', isNot(isEmpty)), |
| 59 d.matcherFile('main.dart.js_1.part.js', isNot(isEmpty)), | 55 d.matcherFile('main.dart.js_1.part.js', isNot(isEmpty)), |
| 60 d.matcherFile('main.dart.js_2.part.js', isNot(isEmpty)), | 56 d.matcherFile('main.dart.js_2.part.js', isNot(isEmpty)), |
| 61 ]) | 57 ]) |
| 62 ]) | 58 ]) |
| 63 ]).validate(); | 59 ]).validate(); |
| 64 }); | 60 }); |
| 65 } | 61 } |
| OLD | NEW |