| 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:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 | 7 |
| 8 @lazy import 'deferred_class_library.dart'; | 8 @lazy import 'deferred_class_library.dart'; |
| 9 | 9 |
| 10 const lazy = const DeferredLibrary('deferred_class_library'); | 10 const lazy = const DeferredLibrary('deferred_class_library'); |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 var x; | 13 var x; |
| 14 // TODO(ahe): What are the semantics of this: | 14 Expect.isNull(const MyClass()); |
| 15 // x = const MyClass(); | 15 Expect.isNull(const Constant(42)); |
| 16 Expect.isNull(const [const Constant(42)]); |
| 16 Expect.isNull(x); | 17 Expect.isNull(x); |
| 17 int counter = 0; | 18 int counter = 0; |
| 18 lazy.load().then((bool didLoad) { | 19 lazy.load().then((bool didLoad) { |
| 19 Expect.isTrue(didLoad); | 20 Expect.isTrue(didLoad); |
| 20 Expect.equals(1, ++counter); | 21 Expect.equals(1, ++counter); |
| 21 print('deferred_class_library was loaded'); | 22 print('deferred_class_library was loaded'); |
| 22 x = const MyClass(); | 23 x = const MyClass(); |
| 23 Expect.equals(42, x.foo(87)); | 24 Expect.equals(42, x.foo(87)); |
| 25 Expect.listEquals(const [const Constant(42)], [new Constant(42)]); |
| 24 }); | 26 }); |
| 25 Expect.equals(0, counter); | 27 Expect.equals(0, counter); |
| 26 Expect.isNull(x); | 28 Expect.isNull(x); |
| 27 lazy.load().then((bool didLoad) { | 29 lazy.load().then((bool didLoad) { |
| 28 Expect.isFalse(didLoad); | 30 Expect.isFalse(didLoad); |
| 29 Expect.equals(2, ++counter); | 31 Expect.equals(2, ++counter); |
| 30 print('deferred_class_library was loaded'); | 32 print('deferred_class_library was loaded'); |
| 31 x = const MyClass(); | 33 x = const MyClass(); |
| 32 Expect.equals(42, x.foo(87)); | 34 Expect.equals(42, x.foo(87)); |
| 35 Expect.listEquals(const [const Constant(42)], [new Constant(42)]); |
| 33 }); | 36 }); |
| 34 Expect.equals(0, counter); | 37 Expect.equals(0, counter); |
| 35 Expect.isNull(x); | 38 Expect.isNull(x); |
| 36 // TODO(ahe): What are the semantics of this: | 39 Expect.isNull(const Constant(42)); |
| 37 // x = const MyClass(); | 40 Expect.isNull(const [const Constant(42)]); |
| 38 Expect.isNull(x); | 41 Expect.isNull(x); |
| 39 } | 42 } |
| OLD | NEW |