Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: dart/tests/lib/async/deferred/deferred_api_test.dart

Issue 11784018: Skeleton API for lazy library loading. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Dummy implementations and tests of basic API, but not functionality Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/tests/lib/async/deferred/deferred_api_test.dart
diff --git a/dart/tests/lib/async/deferred/deferred_api_test.dart b/dart/tests/lib/async/deferred/deferred_api_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a144468bcc8285e70b311cddfecd844b3104c65f
--- /dev/null
+++ b/dart/tests/lib/async/deferred/deferred_api_test.dart
@@ -0,0 +1,37 @@
+// 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 '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);
+}

Powered by Google App Engine
This is Rietveld 408576698