Skip to content

Commit

Permalink
[tests] Use asyncStart/asyncEnd for two language tests
Browse files Browse the repository at this point in the history
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 #52631
Issue #55865

Change-Id: I790960d7da708de4e36be9197ceb3e89f316a84e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368581
Reviewed-by: Ömer Ağacan <[email protected]>
Commit-Queue: Martin Kustermann <[email protected]>
  • Loading branch information
mkustermann authored and Commit Queue committed Jun 1, 2024
1 parent 51ea22f commit a4d3ee0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/language/async/divergent_flatten_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -142,4 +146,5 @@ void main() async {
} on Divergent {
// Expected throw.
}
asyncEnd();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +56,7 @@ void main() async {
assert(cond); //# 38: compile-time error
[...list]; //# 39: compile-time error
[...?list]; //# 40: ok
asyncEnd();
}

generator() sync* {
Expand Down

0 comments on commit a4d3ee0

Please sign in to comment.