blob: 205fdb37998e50723f30e4f1b543519368f97b49 [file] [log] [blame]
// Copyright (c) 2011, 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.
/// @assertion Future.delayed(Duration duration, [dynamic computation()])
/// If calling computation throws, the created future will complete with the
/// error.
/// @description Checks that if calling computation() throws,
/// the created future will complete with the error.
/// @author kaigorodov
import "dart:async";
import "../../../Utils/expect.dart";
check(delay, value) {
asyncStart();
new Future.delayed(durationInMilliseconds(delay), () {
throw value;
}).then((v) {
Expect.fail("Created future should complete with error");
}, onError: (error) {
Expect.equals(value, error);
asyncEnd();
});
}
main() {
asyncStart();
check(100, 3);
check(50, '');
check(0, []);
asyncEnd();
}