Skip to content

Commit

Permalink
Reformat tests/language/a*.
Browse files Browse the repository at this point in the history
(There are so many subdirectories under language/ that I figure going a
letter at a time is easier to review than going a subdirectory at a time
and sending out a huge flurry of tiny CLs.)

Change-Id: Ie899b93c5a5f502ca67953b722cecb68c5c6d233
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400146
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
  • Loading branch information
munificent authored and Commit Queue committed Dec 20, 2024
1 parent 1a8afa6 commit a2c7cd6
Show file tree
Hide file tree
Showing 86 changed files with 1,326 additions and 1,064 deletions.
6 changes: 4 additions & 2 deletions tests/language/async/and_or_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ testEvaluation(Future<void> fn()) async {
test2() async {
await testEvaluation(() async {
Expect.isFalse(
await confuse(traceA(false)) && await confuse(traceB(false)));
await confuse(traceA(false)) && await confuse(traceB(false)),
);
Expect.equals("a", trace);
});
await testEvaluation(() async {
Expand All @@ -65,7 +66,8 @@ test2() async {

await testEvaluation(() async {
Expect.isFalse(
await confuse(traceA(false)) || await confuse(traceB(false)));
await confuse(traceA(false)) || await confuse(traceB(false)),
);
Expect.equals("ab", trace);
});
await testEvaluation(() async {
Expand Down
21 changes: 12 additions & 9 deletions tests/language/async/await_foreign_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ class ForeignFuture implements Future<Null> {

Future<S> then<S>(FutureOr<S> onValue(Null _), {Function? onError}) {
assert(_future != null);
return _future!.then((_) {
_future = null;
return onValue(null);
}, onError: (error, trace) {
_future = null;
if (onError != null) {
onError(error, trace);
}
});
return _future!.then(
(_) {
_future = null;
return onValue(null);
},
onError: (error, trace) {
_future = null;
if (onError != null) {
onError(error, trace);
}
},
);
}

Stream<Null> asStream() {
Expand Down
74 changes: 37 additions & 37 deletions tests/language/async/await_incompatible_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ extension type SFE2(SFE _) implements SFE {}
void main() async {
// 1 (use rule 1).
await N(Future<int>.value(1));
//^^^^^
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^^^^^^^^^^^^^^^^^^^^^^^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.
// [error column 3, length 5]
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.
await F(Future<int>.value(1));

N n = N(Future<int>.value(1));
Expand All @@ -50,10 +50,10 @@ void main() async {

// 2.1 (use rule 2 which in turn uses rule 1).
await nq;
//^^^^^
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.
// [error column 3, length 5]
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.

await fq;

Expand All @@ -70,34 +70,34 @@ void main() async {
await fofq;

var fut = Future<int>.value(1);
foo<Object?, N, F, N?, F?, FutureOr<N>, FutureOr<F>, FutureOr<N>?,
FutureOr<F>?>(
fut,
N(fut),
F(fut),
null,
null,
N(fut),
F(fut),
N(fut),
F(fut),
);
foo<
Object?,
N,
F,
N?,
F?,
FutureOr<N>,
FutureOr<F>,
FutureOr<N>?,
FutureOr<F>?
>(fut, N(fut), F(fut), null, null, N(fut), F(fut), N(fut), F(fut));

var sfe2 = SFE2(SFE(SF()));
await sfe2;
}

// Test type parameter types.
void foo<
X,
XN extends N,
XF extends F,
XNQ extends N?,
XFQ extends F?,
XFoN extends FutureOr<N>,
XFoF extends FutureOr<F>,
XFoNQ extends FutureOr<N>?,
XFoFQ extends FutureOr<F>?>(
X,
XN extends N,
XF extends F,
XNQ extends N?,
XFQ extends F?,
XFoN extends FutureOr<N>,
XFoF extends FutureOr<F>,
XFoNQ extends FutureOr<N>?,
XFoFQ extends FutureOr<F>?
>(
X x,
XN xn,
XF xf,
Expand All @@ -112,10 +112,10 @@ void foo<

// 4.1.
await xn;
//^^^^^
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.
// [error column 3, length 5]
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.

await xf;
await xfon;
Expand All @@ -125,10 +125,10 @@ void foo<

// 4.2.
await xnq;
//^^^^^
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^^^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.
// [error column 3, length 5]
// [analyzer] COMPILE_TIME_ERROR.AWAIT_OF_INCOMPATIBLE_TYPE
// ^
// [cfe] The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.

await xfq;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ class CustomFuture2<S, T> implements Future<T> {

void main() async {
bool seenError = false;
runZoned(() {
foo(CustomFuture1());
}, onError: (e, st) {
seenError = true;
});
runZoned(
() {
foo(CustomFuture1());
},
onError: (e, st) {
seenError = true;
},
);
Expect.listEquals(<String>['Checkpoint 1', 'Checkpoint 2'], executionTrace);
Expect.isTrue(seenError);

Expand Down
2 changes: 0 additions & 2 deletions tests/language/async/congruence_local_runtime_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,10 @@ main() {
// `Future<Object>` but not `Future<int>`.
Future<Object> v1 = f_inferred_futureObject();


// Check that f_inferred_A's static return type is `Future<A>`, by verifying
// that its return value can be assigned to `Future<A>` but not
// `Future<B>`.
Future<A> v3 = f_inferred_A();

}

checkFutureObject(f_inferred_futureObject);
Expand Down
2 changes: 0 additions & 2 deletions tests/language/async/congruence_local_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ main() {
Future<int> v2 = f_inferred_futureObject();
// ^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
// [cfe] A value of type 'Future<Object>' can't be assigned to a variable of type 'Future<int>'.

// Check that f_inferred_A's static return type is `Future<A>`, by verifying
Expand All @@ -111,7 +110,6 @@ main() {
Future<B> v4 = f_inferred_A();
// ^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
// [cfe] A value of type 'Future<A>' can't be assigned to a variable of type 'Future<B>'.
}

Expand Down
1 change: 0 additions & 1 deletion tests/language/async/congruence_method_runtime_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void checkStaticTypes(C c) {
// that its return value can be assigned to `Future<A>` but not
// `Future<B>`.
Future<A> v1 = c.f_inferred_A();

}

void checkDynamic(dynamic tearoff) {
Expand Down
2 changes: 0 additions & 2 deletions tests/language/async/congruence_unnamed_runtime_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ main() {
// `Future<Object>` but not `Future<int>`.
Future<Object> v1 = f_inferred_futureObject();


// Check that f_inferred_A's static return type is `Future<A>`, by verifying
// that its return value can be assigned to `Future<A>` but not
// `Future<B>`.
Future<A> v3 = f_inferred_A();

}

checkFutureObject(f_inferred_futureObject);
Expand Down
3 changes: 2 additions & 1 deletion tests/language/async/control_structures_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ asyncTryCatchLoop() async {
}

asyncImplicitReturn() async {
try {} catch (e) {} finally {}
try {} catch (e) {
} finally {}
}

main() {
Expand Down
Loading

0 comments on commit a2c7cd6

Please sign in to comment.