8fd6d0aafd
Committed: https://code.google.com/p/dart/source/detail?r=19755 Reverted: http://code.google.com/p/dart/source/detail?r=19756 Review URL: https://codereview.chromium.org//12212016 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20996 260f80e4-7a28-3924-810f-c04153c831b5
39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Test that that the basic API for deferred/lazy loading works. This
|
|
// test deliberately does not test that the deferred elements throw a
|
|
// NoSuchMethodError before the deferred library is loaded. This
|
|
// makes it possible to pass this test without having implemented
|
|
// deferred loading correctly.
|
|
|
|
import "package:expect/expect.dart";
|
|
import 'dart:async';
|
|
|
|
@lazy
|
|
import 'deferred_api_library.dart';
|
|
|
|
const lazy = const DeferredLibrary('deferred_api_library');
|
|
|
|
main() {
|
|
print('unittest-suite-wait-for-done');
|
|
|
|
int counter = 0;
|
|
lazy.load().then((bool didLoad) {
|
|
Expect.isTrue(didLoad);
|
|
Expect.equals(1, ++counter);
|
|
Expect.equals(42, foo('b'));
|
|
print('lazy was loaded');
|
|
});
|
|
Expect.equals(0, counter);
|
|
lazy.load().then((bool didLoad) {
|
|
Expect.isFalse(didLoad);
|
|
Expect.equals(2, ++counter);
|
|
Expect.equals(42, foo('b'));
|
|
print('lazy was loaded');
|
|
print('unittest-suite-success');
|
|
});
|
|
Expect.equals(0, counter);
|
|
}
|