| OLD | NEW |
| 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 import 'package:async_helper/async_helper.dart'; | 5 import 'package:async_helper/async_helper.dart'; |
| 6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 | 9 |
| 10 import 'deferred_class_library.dart' deferred as lib; | 10 import 'deferred_class_library.dart' deferred as lib; |
| 11 | 11 |
| 12 isError(e) => e is Error; | 12 isError(e) => e is Error; |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 var x; | 15 var x; |
| 16 Expect.throws(() { x = new lib.MyClass(); }, isError); | 16 Expect.throws(() { |
| 17 x = new lib.MyClass(); |
| 18 }, isError); |
| 17 Expect.isNull(x); | 19 Expect.isNull(x); |
| 18 int counter = 0; | 20 int counter = 0; |
| 19 asyncStart(); | 21 asyncStart(); |
| 20 lib.loadLibrary().then((_) { | 22 lib.loadLibrary().then((_) { |
| 21 Expect.equals(1, ++counter); | 23 Expect.equals(1, ++counter); |
| 22 print('deferred_class_library was loaded'); | 24 print('deferred_class_library was loaded'); |
| 23 x = new lib.MyClass(); | 25 x = new lib.MyClass(); |
| 24 Expect.equals(42, x.foo(87)); | 26 Expect.equals(42, x.foo(87)); |
| 25 asyncEnd(); | 27 asyncEnd(); |
| 26 }); | 28 }); |
| 27 Expect.equals(0, counter); | 29 Expect.equals(0, counter); |
| 28 Expect.isNull(x); | 30 Expect.isNull(x); |
| 29 asyncStart(); | 31 asyncStart(); |
| 30 lib.loadLibrary().then((_) { | 32 lib.loadLibrary().then((_) { |
| 31 Expect.equals(2, ++counter); | 33 Expect.equals(2, ++counter); |
| 32 print('deferred_class_library was loaded'); | 34 print('deferred_class_library was loaded'); |
| 33 x = new lib.MyClass(); | 35 x = new lib.MyClass(); |
| 34 Expect.equals(42, x.foo(87)); | 36 Expect.equals(42, x.foo(87)); |
| 35 asyncEnd(); | 37 asyncEnd(); |
| 36 }); | 38 }); |
| 37 Expect.equals(0, counter); | 39 Expect.equals(0, counter); |
| 38 Expect.isNull(x); | 40 Expect.isNull(x); |
| 39 Expect.throws(() { x = new lib.MyClass(); }, isError); | 41 Expect.throws(() { |
| 42 x = new lib.MyClass(); |
| 43 }, isError); |
| 40 Expect.isNull(x); | 44 Expect.isNull(x); |
| 41 } | 45 } |
| OLD | NEW |