Skip to content

Commit a07bdfb

Browse files
authored
#2398. Update async tests to avoid false-positive results on web. Language and LanguageFeatures tests (#2407)
Update async tests to avoid false-positive results on web, Language and LanguageFeatures tests
1 parent 8d82009 commit a07bdfb

39 files changed

+54
-82
lines changed

Language/Expressions/Await_Expressions/syntax_t03.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
/// @description Check that it is a compile error if unaryExpression is missing
1010
/// @author [email protected]
1111
12-
1312
import 'dart:async';
14-
import '../../../Utils/expect.dart';
15-
16-
f() {
17-
return new Future<int>.value(1);
18-
}
1913

2014
Future test() async {
2115
await;
@@ -25,6 +19,5 @@ Future test() async {
2519
}
2620

2721
main() {
28-
asyncStart();
29-
test().then( (value) => asyncEnd() );
22+
test();
3023
}

Language/Expressions/Await_Expressions/syntax_t04.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
/// @description Check that it is a compile error if unaryExpression is missing
1010
/// @author [email protected]
1111
12-
1312
import 'dart:async';
14-
import '../../../Utils/expect.dart';
15-
16-
f() {
17-
return new Future<int>.value(1);
18-
}
1913

2014
Stream test() async* {
2115
await (await);
@@ -25,6 +19,5 @@ Stream test() async* {
2519
}
2620

2721
main() {
28-
asyncStart();
29-
test().isEmpty.then( (value) => asyncEnd() );
22+
test();
3023
}

Language/Expressions/Await_Expressions/syntax_t05.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
/// enclosing await expression is not marked with async, async* or sync*
1212
/// @author [email protected]
1313
14-
1514
import 'dart:async';
16-
import '../../../Utils/expect.dart';
1715

1816
f() {
1917
return new Future<int>.value(1);

Language/Expressions/Await_Expressions/syntax_t06.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
/// enclosing await expression is marked with sync*
1212
/// @author [email protected]
1313
14-
1514
import 'dart:async';
16-
import '../../../Utils/expect.dart';
1715

1816
f() {
1917
return new Future<int>.value(1);
@@ -27,5 +25,5 @@ Iterable test() sync* {
2725
}
2826

2927
main() {
30-
Expect.isTrue(test().isEmpty);
28+
test();
3129
}

Language/Functions/element_type_A01_t03.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/// @description Check a run-time type of a return value of a synchronous
1616
/// generator function
1717
/// @author [email protected]
18+
/// @issue 54159
1819
1920
import "dart:async";
2021
import "../../Utils/expect.dart";

Language/Functions/element_type_A01_t04.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// return type derives the union-free type `S`, and assume that `S` implements
1717
/// `Iterable<U>`. Then check that the element type of `f` is `U`.
1818
/// @author [email protected]
19+
/// @issue 54159
1920
2021
import "dart:async";
2122
import "../../Utils/expect.dart";

Language/Functions/element_type_A01_t06.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// return type derives the union-free type `S`, and assume that `S` implements
1717
/// `Iterable<U>`. Then check that the element type of `f` is `U`.
1818
/// @author [email protected]
19+
/// @issue 54159
1920
2021
import "dart:async";
2122
import "../../Utils/expect.dart";

Language/Functions/element_type_A02_t03.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// @description Check a run-time type of a returned value of an asynchronous
1717
/// generator function
1818
/// @author [email protected]
19+
/// @issue 54159
1920
2021
import "dart:async";
2122
import "../../Utils/expect.dart";
@@ -27,6 +28,7 @@ void isRuntimeTypeImplementsStream<T>(Object? o) async {
2728
List<T> list = await o.toList();
2829
try {
2930
list.addAll(<T>[]);
31+
asyncEnd();
3032
} on TypeError catch (_) {
3133
throw ExpectException("Expected Stream<$T> but found $o");
3234
}
@@ -39,7 +41,9 @@ FutureOr<Stream<int>?> foo() async* {
3941
}
4042

4143
main() async {
44+
asyncStart(2);
4245
dynamic d = await foo();
4346
FutureOr<Stream<int>> o = d;
4447
isRuntimeTypeImplementsStream<int>(d);
48+
asyncEnd();
4549
}

Language/Functions/element_type_A02_t04.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/// return type derives the union-free type `S`, and assume that `S` implements
1818
/// `Stream<U>`. Then check that the element type of `f` is `U`.
1919
/// @author [email protected]
20+
/// @issue 54159
2021
2122
import "dart:async";
2223
import "../../Utils/expect.dart";
@@ -29,6 +30,7 @@ void isRuntimeTypeImplementsStream<T>(Object? o) async {
2930
List<T> list = await o.toList();
3031
try {
3132
list.addAll(<T>[]);
33+
asyncEnd();
3234
} on TypeError catch (_) {
3335
throw ExpectException("Expected Stream<$T> but found $o");
3436
}
@@ -41,7 +43,9 @@ FutureOr<Stream<int>?> foo() async* {
4143
}
4244

4345
main() async {
46+
asyncStart(2);
4447
var o = await foo();
4548
o.expectStaticType<Exactly<Stream<int>?>>();
4649
isRuntimeTypeImplementsStream<int>(o);
50+
asyncEnd();
4751
}

Language/Functions/element_type_A02_t06.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/// return type derives the union-free type `S`, and assume that `S` implements
1818
/// `Stream<U>`. Then check that the element type of `f` is `U`.
1919
/// @author [email protected]
20-
/// @issue 53051
20+
/// @issue 53051, 54159
2121
2222
import "dart:async";
2323
import "../../Utils/expect.dart";

Language/Statements/For/Asynchronous_For_in/execution_A05_t01.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import 'dart:async';
5555
import '../../../../Utils/expect.dart';
5656

5757
main() async {
58-
asyncStart();
58+
asyncStart(2);
5959
List<int> log = [];
6060
StreamController sc = StreamController(onCancel: () {
6161
Expect.listEquals([1, 2, 3], log);
@@ -68,4 +68,5 @@ main() async {
6868
break;
6969
}
7070
}
71+
asyncEnd();
7172
}

Language/Statements/For/Asynchronous_For_in/execution_A05_t02.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import 'dart:async';
5656
import '../../../../Utils/expect.dart';
5757

5858
main() async {
59-
asyncStart();
59+
asyncStart(2);
6060
List<int> log = [];
6161
StreamController sc = StreamController(onCancel: () {
6262
Expect.listEquals([1, 2, 3], log);
@@ -72,4 +72,5 @@ main() async {
7272
}
7373
}
7474
}
75+
asyncEnd();
7576
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A02_t01.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ Future test() async {
5959
await null;
6060
ss.resume();
6161
await sc.close();
62+
asyncEnd();
6263
}
6364

6465
main() {
65-
asyncStart();
66+
asyncStart(2);
6667
test();
6768
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A03_t01.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ Future test() async {
5656
log.add('c');
5757
ss.resume();
5858
await sc.close();
59+
asyncEnd();
5960
}
6061

6162
main() {
62-
asyncStart();
63+
asyncStart(2);
6364
test();
6465
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A03_t02.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ Future test() async {
5252
await null;
5353
log.add('c');
5454
ss.resume();
55+
asyncEnd();
5556
}
5657

5758
main() {
58-
asyncStart();
59+
asyncStart(2);
5960
test();
6061
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A03_t10.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ Future test() async {
7171
ss.resume();
7272
await c.future;
7373
await sc.close();
74+
asyncEnd();
7475
}
7576

7677
main() {
77-
asyncStart();
78+
asyncStart(2);
7879
test();
7980
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A03_t13.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ Future test() async {
7272
ss.resume();
7373
await c.future;
7474
await sc.close();
75+
asyncEnd();
7576
}
7677

7778
main() {
78-
asyncStart();
79+
asyncStart(2);
7980
test();
8081
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A03_t14.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ Future test() async {
6868
await c.future;
6969
log.add('two');
7070
await sc.close();
71+
asyncEnd();
7172
}
7273

7374
main() {
74-
asyncStart();
75+
asyncStart(2);
7576
test();
7677
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A03_t15.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ Future test() async {
7373
await c.future;
7474
Expect.listEquals([-1, 1, 'one', 'two', 2], log);
7575
await sc.close();
76+
asyncEnd();
7677
}
7778

7879
main() {
79-
asyncStart();
80+
asyncStart(2);
8081
test();
8182
}

Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_A04_t01.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ Future test() async {
4848
sc.add('b');
4949
sc.add('c');
5050
sc.close();
51+
asyncEnd();
5152
}
5253

5354
main() {
54-
asyncStart();
55+
asyncStart(2);
5556
test();
5657
}

LanguageFeatures/nnbd/future_flattening_A01_t57.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ import "dart:async";
2626
import "../../Utils/expect.dart";
2727

2828
main() {
29-
asyncStart();
29+
asyncStart(4);
3030
Future<int?>(() => 1).then((value) => asyncEnd());
3131

32-
asyncStart();
3332
Future<Future<int?>>(() => Future<int?>(() => 1)).then((value) {
3433
value.then((value1) => asyncEnd());
3534
});
3635

37-
asyncStart();
3836
Future<Object?>(() => 1).then((value) => asyncEnd());
3937

40-
asyncStart();
4138
Future<Future<Object?>>(() => Future<Object?>(() => 1)).then((value) {
4239
value.then((value1) => asyncEnd());
4340
});

LanguageFeatures/nnbd/future_flattening_A01_t58.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ import "dart:async";
2626
import "../../Utils/expect.dart";
2727

2828
main() {
29-
asyncStart();
29+
asyncStart(4);
3030
Future<int?>(() => null).then((value) => asyncEnd());
3131

32-
asyncStart();
3332
Future<Future<int?>>(() => Future<int?>(() => null)).then((value) {
3433
value.then((value1) => asyncEnd());
3534
});
3635

37-
asyncStart();
3836
Future<Object?>(() => null).then((value) => asyncEnd());
3937

40-
asyncStart();
4138
Future<Future<Object?>>(() => Future<Object?>(() => null)).then((value) {
4239
value.then((value1) => asyncEnd());
4340
});

LanguageFeatures/nnbd/future_flattening_A01_t59.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ import "dart:async";
2626
import "../../Utils/expect.dart";
2727

2828
main() {
29-
asyncStart();
29+
asyncStart(4);
3030
Future<int>(() => 1).then((value) => asyncEnd());
3131

32-
asyncStart();
3332
Future<Future<int>>(() => Future<int>(() => 1)).then((value) {
3433
value.then((value1) => asyncEnd());
3534
});
3635

37-
asyncStart();
3836
Future<Object>(() => 1).then((value) => asyncEnd());
3937

40-
asyncStart();
4138
Future<Future<Object>>(() => Future<Object>(() => 1)).then((value) {
4239
value.then((value1) => asyncEnd());
4340
});

LanguageFeatures/nnbd/future_flattening_A01_t64.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ import "../../Utils/expect.dart";
2828
dynamic getNull() => null;
2929

3030
main() {
31-
asyncStart();
31+
asyncStart(2);
3232
Future f = Future<int>(() => getNull());
3333
f.then((value) { Expect.fail("Should not reach here"); },
3434
onError:(e) => asyncEnd());
3535

36-
asyncStart();
3736
f = Future<Future<int>>(() => getNull());
3837
f.then((value) { Expect.fail("Should not reach here"); },
3938
onError:(e) => asyncEnd());

LanguageFeatures/nnbd/future_flattening_A01_t65.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ import "../../Utils/expect.dart";
2828
dynamic getNull() => null;
2929

3030
main() {
31-
asyncStart();
31+
asyncStart(2);
3232
Future f = Future<Object>(() => getNull());
3333
f.then((value) { Expect.fail("Should not reach here!"); },
3434
onError:(e) => asyncEnd());
3535

36-
asyncStart();
3736
f = Future<Future<Object>>(() => getNull());
3837
f.then((value) { Expect.fail("Should not reach here!"); },
3938
onError:(e) => asyncEnd());

LanguageFeatures/nnbd/future_flattening_A01_t66.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ import "../../Utils/expect.dart";
2828
dynamic getNull() => null;
2929

3030
main() {
31-
asyncStart();
31+
asyncStart(2);
3232
Future f = Future<Object>(() => Future<Object?>(() => getNull()));
3333
f.then((value) => asyncEnd());
3434

35-
asyncStart();
3635
Future f1 = Future<Object?>(() => Future<Object>(() => getNull()));
3736
f1.then((value) { Expect.fail("Should not reach here!"); },
3837
onError:(e) => asyncEnd());

LanguageFeatures/nnbd/future_flattening_A01_t75.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ import "dart:async";
2626
import "../../Utils/expect.dart";
2727

2828
main() {
29-
asyncStart();
29+
asyncStart(2);
3030
Future<dynamic>(() => 1).then((value) => asyncEnd());
3131

32-
asyncStart();
3332
Future<Future<dynamic>>(() => Future<dynamic>(() => 1)).then((value) {
3433
value.then((value1) => asyncEnd());
3534
});

0 commit comments

Comments
 (0)