From a4d3ee054d088bd51a311328b44e992a042ccca9 Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Sat, 1 Jun 2024 21:51:11 +0000 Subject: [PATCH] [tests] Use asyncStart/asyncEnd for two language tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order for asynchronous tests to work on the web, they have to tell the test runner that * the test is async * when the async test has finished running This is done via calling asyncStart/asyncEnd. Issue https://github.com/dart-lang/sdk/issues/52631 Issue https://github.com/dart-lang/sdk/issues/55865 Change-Id: I790960d7da708de4e36be9197ceb3e89f316a84e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368581 Reviewed-by: Ömer Ağacan Commit-Queue: Martin Kustermann --- tests/language/async/divergent_flatten_test.dart | 5 +++++ .../nnbd/static_errors/unchecked_use_of_nullable_test.dart | 3 +++ 2 files changed, 8 insertions(+) diff --git a/tests/language/async/divergent_flatten_test.dart b/tests/language/async/divergent_flatten_test.dart index 9d0dcc19a10..cfce60ab234 100644 --- a/tests/language/async/divergent_flatten_test.dart +++ b/tests/language/async/divergent_flatten_test.dart @@ -6,7 +6,10 @@ // when applied to interfaces that have `Future` as a superinterface. import 'dart:async'; + +import 'package:async_helper/async_helper.dart'; import 'package:expect/expect.dart'; + import '../static_type_helper.dart'; mixin Base { @@ -39,6 +42,7 @@ class Divergent = Object implements Future>>; void main() async { + asyncStart(); // ----- Test the static types of await on the non-standard futures. bool obscureFalse = DateTime.now().millisecondsSinceEpoch < 0; @@ -142,4 +146,5 @@ void main() async { } on Divergent { // Expected throw. } + asyncEnd(); } diff --git a/tests/language/nnbd/static_errors/unchecked_use_of_nullable_test.dart b/tests/language/nnbd/static_errors/unchecked_use_of_nullable_test.dart index 5c9aafaae2d..7ede4dc74ec 100644 --- a/tests/language/nnbd/static_errors/unchecked_use_of_nullable_test.dart +++ b/tests/language/nnbd/static_errors/unchecked_use_of_nullable_test.dart @@ -2,9 +2,11 @@ // 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'; // Test that it is an error to use nullable types in unsound ways. void main() async { + asyncStart(); int? x; bool? cond; List? list; @@ -54,6 +56,7 @@ void main() async { assert(cond); //# 38: compile-time error [...list]; //# 39: compile-time error [...?list]; //# 40: ok + asyncEnd(); } generator() sync* {