mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:21:07 +00:00
df97aca1fa
Closes https://github.com/dart-lang/sdk/pull/50764 GitOrigin-RevId: ee2fe9a75d50e877f4ad2fe3743acdbc04f186ef Change-Id: Ia73cd22da4e6ec95e84772aa4e1345ce2dbde215 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276360 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Erik Ernst <eernst@google.com>
55 lines
1.3 KiB
Dart
55 lines
1.3 KiB
Dart
// Copyright (c) 2021, 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.
|
|
|
|
import 'package:async_helper/async_helper.dart';
|
|
import "package:expect/expect.dart";
|
|
import 'dart:async' show Completer, runZonedGuarded;
|
|
import '../../language/static_type_helper.dart';
|
|
|
|
void main() {
|
|
testIgnore();
|
|
}
|
|
|
|
void testIgnore() {
|
|
var future = Future<int>.value(42);
|
|
captureStaticType(future.ignore(), <T>(T value) {
|
|
Expect.equals(typeOf<void>(), T);
|
|
});
|
|
|
|
asyncStart();
|
|
// Ignored futures can still be listened to.
|
|
{
|
|
var c = Completer<int>.sync();
|
|
var f = c.future;
|
|
f.ignore();
|
|
asyncStart();
|
|
f.catchError((e) {
|
|
Expect.equals("ERROR1", e);
|
|
asyncEnd();
|
|
return 0;
|
|
});
|
|
c.completeError("ERROR1");
|
|
}
|
|
|
|
// Ignored futures are not uncaught errors.
|
|
{
|
|
asyncStart();
|
|
bool threw = false;
|
|
runZonedGuarded(() {
|
|
var c = Completer<int>.sync();
|
|
var f = c.future;
|
|
f.ignore();
|
|
c.completeError("ERROR2");
|
|
}, (e, s) {
|
|
threw = true;
|
|
Expect.fail("Should not happen: $e");
|
|
});
|
|
Future.delayed(Duration.zero, () {
|
|
if (threw) Expect.fail("Future not ignored.");
|
|
asyncEnd();
|
|
});
|
|
}
|
|
asyncEnd();
|
|
}
|