mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
6c86fc44a6
This reverts commit212d5e3a31
. This reapplies commit3688a4723c
. CoreLibraryReviewExempt: Refactoring and relanding. Change-Id: I9b52ef4073bfff50699919f8a5b85e5ff66d0c3b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258929 Reviewed-by: Nate Bosch <nbosch@google.com> Commit-Queue: Nate Bosch <nbosch@google.com> Auto-Submit: Lasse Nielsen <lrn@google.com>
31 lines
1 KiB
Dart
31 lines
1 KiB
Dart
// Copyright (c) 2022, 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.
|
|
|
|
// Regression test for http://dartbug.com/48493
|
|
//
|
|
// The `Completer.complete` method, given an already completed `_Future`
|
|
// with a value result, will complete the `Completer.future` synchronously.
|
|
|
|
import 'package:async_helper/async_helper.dart';
|
|
import "package:expect/expect.dart";
|
|
import 'dart:async';
|
|
|
|
void main() async {
|
|
asyncStart();
|
|
|
|
var completer = Completer<int>(); // Not synchronous.
|
|
var future = Future<int>.value(4);
|
|
await future; // Ensure future completed.
|
|
bool thenRun = false;
|
|
completer.future.then((_) {
|
|
thenRun = true;
|
|
});
|
|
Expect.isFalse(thenRun, "Sanity check");
|
|
completer.complete(future);
|
|
Expect.isFalse(thenRun, "Ran early"); // Bug would cause this to fail.
|
|
await Future(() {}); // Await timer, all microtasks completed.
|
|
Expect.isTrue(thenRun, "Did not run as microtask");
|
|
|
|
asyncEnd();
|
|
}
|