[tests] Use asyncStart/asyncEnd for two language tests

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 <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann 2024-06-01 21:51:11 +00:00 committed by Commit Queue
parent 51ea22f13f
commit a4d3ee054d
2 changed files with 8 additions and 0 deletions

View file

@ -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<T> = Object
implements Future<Divergent<Divergent<T>>>;
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();
}

View file

@ -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* {