Skip to content

Commit

Permalink
Reformat tests/language/c*.
Browse files Browse the repository at this point in the history
Change-Id: I94dfcea40566190c6bf153c108b0d0d5dbf27a4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400148
Commit-Queue: Bob Nystrom <[email protected]>
Reviewed-by: Lasse Nielsen <[email protected]>
Auto-Submit: Bob Nystrom <[email protected]>
  • Loading branch information
munificent authored and Commit Queue committed Dec 12, 2024
1 parent 7190cb0 commit 6cc9efe
Show file tree
Hide file tree
Showing 248 changed files with 42,717 additions and 42,738 deletions.
6 changes: 4 additions & 2 deletions tests/language/call/function_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ void main() {
var s = (FooType).toString();
var minified = s != 'FooType'; // dart2js --minify has minified names.
dynamic d = null;
Expect.throws(() => d(),
(e) => e is NoSuchMethodError && (minified || '$e'.contains('call')));
Expect.throws(
() => d(),
(e) => e is NoSuchMethodError && (minified || '$e'.contains('call')),
);
}
33 changes: 21 additions & 12 deletions tests/language/call/implicit_tearoff_assignment_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class Derived extends Base {
}

void testSuperPropertySet() {
Expect.type<void Function()>((super.baseProperty = C())
..expectStaticType<Exactly<void Function()>>());
Expect.type<void Function()>(
(super.baseProperty = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(super._basePropertySetValue);
}
}
Expand All @@ -72,56 +73,64 @@ extension on Extended {
void testExtensionIndexSet() {
Extended e = Extended();
Expect.type<void Function()>(
(e[0] = C())..expectStaticType<Exactly<void Function()>>());
(e[0] = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(e._extensionIndexSetValue);
}

void testExtensionSet() {
Extended e = Extended();
Expect.type<void Function()>((e.extensionProperty = C())
..expectStaticType<Exactly<void Function()>>());
Expect.type<void Function()>(
(e.extensionProperty = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(e._extensionPropertySetValue);
}

void testIndexSet() {
Derived d = Derived();
Expect.type<void Function()>(
(d[0] = C())..expectStaticType<Exactly<void Function()>>());
(d[0] = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(d._indexSetValue);
}

void testInstanceSet() {
Derived d = Derived();
Expect.type<void Function()>(
(d.instanceProperty = C())..expectStaticType<Exactly<void Function()>>());
(d.instanceProperty = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(d._instanceSetValue);
}

void testNullAwarePropertySet() {
Derived? d = Derived() as Derived?; // ignore: unnecessary_cast
Expect.type<void Function()>((d?.instanceProperty = C())
..expectStaticType<Exactly<void Function()?>>());
Expect.type<void Function()>(
(d?.instanceProperty = C())..expectStaticType<Exactly<void Function()?>>(),
);
Expect.type<void Function()>(d!._instanceSetValue);
}

void testStaticSet() {
C._staticPropertySetValue = null;
Expect.type<void Function()>(
(C.staticProperty = C())..expectStaticType<Exactly<void Function()>>());
(C.staticProperty = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(C._staticPropertySetValue);
}

void testTopLevelSet() {
_topLevelPropertySetValue = null;
Expect.type<void Function()>(
(topLevelProperty = C())..expectStaticType<Exactly<void Function()>>());
(topLevelProperty = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(_topLevelPropertySetValue);
}

void testVariableSet() {
void Function() f;
Expect.type<void Function()>(
(f = C())..expectStaticType<Exactly<void Function()>>());
(f = C())..expectStaticType<Exactly<void Function()>>(),
);
Expect.type<void Function()>(f);
}

Expand Down
99 changes: 69 additions & 30 deletions tests/language/call/implicit_tearoff_exceptions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,39 @@ void testConditional() {
// `(bTrue ? c : a)..expectStaticType<...>()`, no implicit tearoff of `c`
// occurs, and the subexpression `bTrue ? c : a` gets assigned a static type
// of `A`.
Expect.throws(() => context<void Function()>(
bFalse ? d : ((bTrue ? c : a)..expectStaticType<Exactly<A>>())));
Expect.throws(() => context<void Function()>(
bFalse ? d : ((bFalse ? a : c)..expectStaticType<Exactly<A>>())));
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((bTrue ? c : a)..expectStaticType<Exactly<A>>()),
),
);
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((bFalse ? a : c)..expectStaticType<Exactly<A>>()),
),
);

// Same as above, but confirm that extra parens around `c` don't change the
// behavior.
Expect.throws(() => context<void Function()>(
bFalse ? d : ((bTrue ? (c) : a)..expectStaticType<Exactly<A>>())));
Expect.throws(() => context<void Function()>(
bFalse ? d : ((bFalse ? a : (c))..expectStaticType<Exactly<A>>())));
Expect.throws(() => context<void Function()>(
bFalse ? d : ((bTrue ? ((c)) : a)..expectStaticType<Exactly<A>>())));
Expect.throws(() => context<void Function()>(
bFalse ? d : ((bFalse ? a : ((c)))..expectStaticType<Exactly<A>>())));
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((bTrue ? (c) : a)..expectStaticType<Exactly<A>>()),
),
);
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((bFalse ? a : (c))..expectStaticType<Exactly<A>>()),
),
);
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((bTrue ? ((c)) : a)..expectStaticType<Exactly<A>>()),
),
);
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((bFalse ? a : ((c)))..expectStaticType<Exactly<A>>()),
),
);
}

void testIfNull() {
Expand All @@ -90,30 +108,51 @@ void testIfNull() {
// appropriate). So, in
// `(c ?? a)..expectStaticType<...>()`, no implicit tearoff of `c` occurs, and
// the subexpression `c ?? a` gets assigned a static type of `A`.
Expect.throws(() => context<void Function()>(bFalse
? d
: ((c ?? a) // ignore: dead_null_aware_expression
..expectStaticType<Exactly<A>>())));
Expect.throws(
() => context<void Function()>(
bFalse
? d
: ((c ?? a) // ignore: dead_null_aware_expression
..expectStaticType<Exactly<A>>()),
),
);

// In `(aq ?? c)..expectStaticType<...>()`, the situation is similar, but the
// context for `c` is (non-nullable) `void Function()`.
Expect.throws(() => context<void Function()>(
bFalse ? d : ((aq ?? c)..expectStaticType<Exactly<A>>())));
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((aq ?? c)..expectStaticType<Exactly<A>>()),
),
);

// Same as above, but confirm that extra parens around `c` don't change the
// behavior.
Expect.throws(() => context<void Function()>(bFalse
? d
: (((c) ?? a) // ignore: dead_null_aware_expression
..expectStaticType<Exactly<A>>())));
Expect.throws(() => context<void Function()>(
bFalse ? d : ((aq ?? (c))..expectStaticType<Exactly<A>>())));
Expect.throws(() => context<void Function()>(bFalse
? d
: ((((c)) ?? a) // ignore: dead_null_aware_expression
..expectStaticType<Exactly<A>>())));
Expect.throws(() => context<void Function()>(
bFalse ? d : ((aq ?? ((c)))..expectStaticType<Exactly<A>>())));
Expect.throws(
() => context<void Function()>(
bFalse
? d
: (((c) ?? a) // ignore: dead_null_aware_expression
..expectStaticType<Exactly<A>>()),
),
);
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((aq ?? (c))..expectStaticType<Exactly<A>>()),
),
);
Expect.throws(
() => context<void Function()>(
bFalse
? d
: ((((c)) ?? a) // ignore: dead_null_aware_expression
..expectStaticType<Exactly<A>>()),
),
);
Expect.throws(
() => context<void Function()>(
bFalse ? d : ((aq ?? ((c)))..expectStaticType<Exactly<A>>()),
),
);
}

main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ void testTypeVariablePromotedToNullableCallableClass<T>(T t) {
}

void testTypeVariableExtendsNullableTypeVariable<T extends U?, U extends C>(
T t) {
T t,
) {
context<void Function()>(t);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ main() {
Expect.equals(d2(1), 2);
// Cannot invoke with the wrong signature.
c2();
//^
// [cfe] Too few positional arguments: 1 required, 0 given.
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
//^^
// [cfe] Too few positional arguments: 1 required, 0 given.
c2(3, 4);
//^
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
//^^^^^^
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ main() {
// Implicitly invokes d2.call(1)
Expect.equals(d2(1), 2);
// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ main() {
// Implicitly invokes d2.call(1)
Expect.equals(d2(1), 2);
// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ main() {
// Implicitly invokes d2.call(1)

// Cannot invoke with the wrong signature.


}
8 changes: 4 additions & 4 deletions tests/language/call/method_implicit_invoke_local_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ main() {
Expect.equals(d1(1), 2);
// Cannot invoke with the wrong signature.
c1();
//^
// [cfe] Too few positional arguments: 1 required, 0 given.
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
//^^
// [cfe] Too few positional arguments: 1 required, 0 given.
c1(3, 4);
//^
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
//^^^^^^
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ main() {
// supertype of the target type. Since we no longer allow implicit downcasts,
// this is a static error.
void Function([int]) f = i;
// ^
// [cfe] A value of type 'void Function()' can't be assigned to a variable of type 'void Function([int])'.
// ^
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ main() {
check(c);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] unspecified
// [cfe] Can't tear off method 'call' from a potentially null value.
}
16 changes: 8 additions & 8 deletions tests/language/call/non_method_field_error_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class Hest extends Fisk {}
main() {
Fisk x1 = new Fisk();
x1.i();
//^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] 'i' isn't a function or method and can't be invoked.
// [error column 3, length 4]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] 'i' isn't a function or method and can't be invoked.

Hest x2 = new Hest();
x2.i();
//^^^^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] 'i' isn't a function or method and can't be invoked.
// [error column 3, length 4]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] 'i' isn't a function or method and can't be invoked.
}
8 changes: 4 additions & 4 deletions tests/language/call/object_has_no_call_method_error_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
void test(dynamic d, Object o, Function f) {
d();
o();
//^
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// ^
// [cfe] The method 'call' isn't defined for the class 'Object'.
// [error column 3, length 1]
// [analyzer] COMPILE_TIME_ERROR.INVOCATION_OF_NON_FUNCTION_EXPRESSION
// [error column 4]
// [cfe] The method 'call' isn't defined for the class 'Object'.
f();
d.call;
o.call;
Expand Down
Loading

0 comments on commit 6cc9efe

Please sign in to comment.