Skip to content

Commit

Permalink
#2398. Update async tests to avoid false-positive results on web. Lan…
Browse files Browse the repository at this point in the history
…guage and LanguageFeatures tests (#2407)

Update async tests to avoid false-positive results on web, Language and LanguageFeatures tests
  • Loading branch information
sgrekhov committed Dec 1, 2023
1 parent 8d82009 commit a07bdfb
Show file tree
Hide file tree
Showing 39 changed files with 54 additions and 82 deletions.
9 changes: 1 addition & 8 deletions Language/Expressions/Await_Expressions/syntax_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
/// @description Check that it is a compile error if unaryExpression is missing
/// @author a.semenov@unipro.ru

import 'dart:async';
import '../../../Utils/expect.dart';

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

Future test() async {
await;
Expand All @@ -25,6 +19,5 @@ Future test() async {
}

main() {
asyncStart();
test().then( (value) => asyncEnd() );
test();
}
9 changes: 1 addition & 8 deletions Language/Expressions/Await_Expressions/syntax_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
/// @description Check that it is a compile error if unaryExpression is missing
/// @author a.semenov@unipro.ru

import 'dart:async';
import '../../../Utils/expect.dart';

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

Stream test() async* {
await (await);
Expand All @@ -25,6 +19,5 @@ Stream test() async* {
}

main() {
asyncStart();
test().isEmpty.then( (value) => asyncEnd() );
test();
}
2 changes: 0 additions & 2 deletions Language/Expressions/Await_Expressions/syntax_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
/// enclosing await expression is not marked with async, async* or sync*
/// @author a.semenov@unipro.ru

import 'dart:async';
import '../../../Utils/expect.dart';

f() {
return new Future<int>.value(1);
Expand Down
4 changes: 1 addition & 3 deletions Language/Expressions/Await_Expressions/syntax_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
/// enclosing await expression is marked with sync*
/// @author a.semenov@unipro.ru

import 'dart:async';
import '../../../Utils/expect.dart';

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

main() {
Expect.isTrue(test().isEmpty);
test();
}
1 change: 1 addition & 0 deletions Language/Functions/element_type_A01_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/// @description Check a run-time type of a return value of a synchronous
/// generator function
/// @author sgrekhov22@gmail.com
/// @issue 54159
import "dart:async";
import "../../Utils/expect.dart";
Expand Down
1 change: 1 addition & 0 deletions Language/Functions/element_type_A01_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/// return type derives the union-free type `S`, and assume that `S` implements
/// `Iterable<U>`. Then check that the element type of `f` is `U`.
/// @author sgrekhov22@gmail.com
/// @issue 54159
import "dart:async";
import "../../Utils/expect.dart";
Expand Down
1 change: 1 addition & 0 deletions Language/Functions/element_type_A01_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/// return type derives the union-free type `S`, and assume that `S` implements
/// `Iterable<U>`. Then check that the element type of `f` is `U`.
/// @author sgrekhov22@gmail.com
/// @issue 54159
import "dart:async";
import "../../Utils/expect.dart";
Expand Down
4 changes: 4 additions & 0 deletions Language/Functions/element_type_A02_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/// @description Check a run-time type of a returned value of an asynchronous
/// generator function
/// @author sgrekhov22@gmail.com
/// @issue 54159
import "dart:async";
import "../../Utils/expect.dart";
Expand All @@ -27,6 +28,7 @@ void isRuntimeTypeImplementsStream<T>(Object? o) async {
List<T> list = await o.toList();
try {
list.addAll(<T>[]);
asyncEnd();
} on TypeError catch (_) {
throw ExpectException("Expected Stream<$T> but found $o");
}
Expand All @@ -39,7 +41,9 @@ FutureOr<Stream<int>?> foo() async* {
}

main() async {
asyncStart(2);
dynamic d = await foo();
FutureOr<Stream<int>> o = d;
isRuntimeTypeImplementsStream<int>(d);
asyncEnd();
}
4 changes: 4 additions & 0 deletions Language/Functions/element_type_A02_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/// return type derives the union-free type `S`, and assume that `S` implements
/// `Stream<U>`. Then check that the element type of `f` is `U`.
/// @author sgrekhov22@gmail.com
/// @issue 54159
import "dart:async";
import "../../Utils/expect.dart";
Expand All @@ -29,6 +30,7 @@ void isRuntimeTypeImplementsStream<T>(Object? o) async {
List<T> list = await o.toList();
try {
list.addAll(<T>[]);
asyncEnd();
} on TypeError catch (_) {
throw ExpectException("Expected Stream<$T> but found $o");
}
Expand All @@ -41,7 +43,9 @@ FutureOr<Stream<int>?> foo() async* {
}

main() async {
asyncStart(2);
var o = await foo();
o.expectStaticType<Exactly<Stream<int>?>>();
isRuntimeTypeImplementsStream<int>(o);
asyncEnd();
}
2 changes: 1 addition & 1 deletion Language/Functions/element_type_A02_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// return type derives the union-free type `S`, and assume that `S` implements
/// `Stream<U>`. Then check that the element type of `f` is `U`.
/// @author sgrekhov22@gmail.com
/// @issue 53051
/// @issue 53051, 54159
import "dart:async";
import "../../Utils/expect.dart";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import 'dart:async';
import '../../../../Utils/expect.dart';

main() async {
asyncStart();
asyncStart(2);
List<int> log = [];
StreamController sc = StreamController(onCancel: () {
Expect.listEquals([1, 2, 3], log);
Expand All @@ -68,4 +68,5 @@ main() async {
break;
}
}
asyncEnd();
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import 'dart:async';
import '../../../../Utils/expect.dart';

main() async {
asyncStart();
asyncStart(2);
List<int> log = [];
StreamController sc = StreamController(onCancel: () {
Expect.listEquals([1, 2, 3], log);
Expand All @@ -72,4 +72,5 @@ main() async {
}
}
}
asyncEnd();
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ Future test() async {
await null;
ss.resume();
await sc.close();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ Future test() async {
log.add('c');
ss.resume();
await sc.close();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ Future test() async {
await null;
log.add('c');
ss.resume();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ Future test() async {
ss.resume();
await c.future;
await sc.close();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ Future test() async {
ss.resume();
await c.future;
await sc.close();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ Future test() async {
await c.future;
log.add('two');
await sc.close();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ Future test() async {
await c.future;
Expect.listEquals([-1, 1, 'one', 'two', 2], log);
await sc.close();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ Future test() async {
sc.add('b');
sc.add('c');
sc.close();
asyncEnd();
}

main() {
asyncStart();
asyncStart(2);
test();
}
5 changes: 1 addition & 4 deletions LanguageFeatures/nnbd/future_flattening_A01_t57.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ import "dart:async";
import "../../Utils/expect.dart";

main() {
asyncStart();
asyncStart(4);
Future<int?>(() => 1).then((value) => asyncEnd());

asyncStart();
Future<Future<int?>>(() => Future<int?>(() => 1)).then((value) {
value.then((value1) => asyncEnd());
});

asyncStart();
Future<Object?>(() => 1).then((value) => asyncEnd());

asyncStart();
Future<Future<Object?>>(() => Future<Object?>(() => 1)).then((value) {
value.then((value1) => asyncEnd());
});
Expand Down
5 changes: 1 addition & 4 deletions LanguageFeatures/nnbd/future_flattening_A01_t58.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ import "dart:async";
import "../../Utils/expect.dart";

main() {
asyncStart();
asyncStart(4);
Future<int?>(() => null).then((value) => asyncEnd());

asyncStart();
Future<Future<int?>>(() => Future<int?>(() => null)).then((value) {
value.then((value1) => asyncEnd());
});

asyncStart();
Future<Object?>(() => null).then((value) => asyncEnd());

asyncStart();
Future<Future<Object?>>(() => Future<Object?>(() => null)).then((value) {
value.then((value1) => asyncEnd());
});
Expand Down
5 changes: 1 addition & 4 deletions LanguageFeatures/nnbd/future_flattening_A01_t59.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ import "dart:async";
import "../../Utils/expect.dart";

main() {
asyncStart();
asyncStart(4);
Future<int>(() => 1).then((value) => asyncEnd());

asyncStart();
Future<Future<int>>(() => Future<int>(() => 1)).then((value) {
value.then((value1) => asyncEnd());
});

asyncStart();
Future<Object>(() => 1).then((value) => asyncEnd());

asyncStart();
Future<Future<Object>>(() => Future<Object>(() => 1)).then((value) {
value.then((value1) => asyncEnd());
});
Expand Down
3 changes: 1 addition & 2 deletions LanguageFeatures/nnbd/future_flattening_A01_t64.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import "../../Utils/expect.dart";
dynamic getNull() => null;

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

asyncStart();
f = Future<Future<int>>(() => getNull());
f.then((value) { Expect.fail("Should not reach here"); },
onError:(e) => asyncEnd());
Expand Down
3 changes: 1 addition & 2 deletions LanguageFeatures/nnbd/future_flattening_A01_t65.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import "../../Utils/expect.dart";
dynamic getNull() => null;

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

asyncStart();
f = Future<Future<Object>>(() => getNull());
f.then((value) { Expect.fail("Should not reach here!"); },
onError:(e) => asyncEnd());
Expand Down
3 changes: 1 addition & 2 deletions LanguageFeatures/nnbd/future_flattening_A01_t66.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ import "../../Utils/expect.dart";
dynamic getNull() => null;

main() {
asyncStart();
asyncStart(2);
Future f = Future<Object>(() => Future<Object?>(() => getNull()));
f.then((value) => asyncEnd());

asyncStart();
Future f1 = Future<Object?>(() => Future<Object>(() => getNull()));
f1.then((value) { Expect.fail("Should not reach here!"); },
onError:(e) => asyncEnd());
Expand Down
3 changes: 1 addition & 2 deletions LanguageFeatures/nnbd/future_flattening_A01_t75.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import "dart:async";
import "../../Utils/expect.dart";

main() {
asyncStart();
asyncStart(2);
Future<dynamic>(() => 1).then((value) => asyncEnd());

asyncStart();
Future<Future<dynamic>>(() => Future<dynamic>(() => 1)).then((value) {
value.then((value1) => asyncEnd());
});
Expand Down

0 comments on commit a07bdfb

Please sign in to comment.