Skip to content

Commit 2f2bdc3

Browse files
munificentCommit Queue
authored andcommitted
Reformat tests/lib/js and /js_interop_unsafe using 3.8 style.
Change-Id: I182e28a3c4b44dd899e5ea30ac5c5c3ba60fd6cc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425333 Reviewed-by: Srujan Gaddam <[email protected]> Commit-Queue: Bob Nystrom <[email protected]> Auto-Submit: Bob Nystrom <[email protected]>
1 parent 9831fc4 commit 2f2bdc3

File tree

54 files changed

+1440
-946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1440
-946
lines changed

tests/lib/js/allowInterop_idempotent_test.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ void main() {
3131
// Should return the same value if the value is already a wrapped function.
3232
Expect.equals(wrappedFunction, allowInterop(wrappedFunction));
3333
Expect.equals(
34-
wrappedFunctionCaptureThis, allowInterop(wrappedFunctionCaptureThis));
34+
wrappedFunctionCaptureThis,
35+
allowInterop(wrappedFunctionCaptureThis),
36+
);
3537
// Passing a non-Dart function to `allowInteropCaptureThis` throws in dart2js,
3638
// so for now, capture the existing semantics. We may want to update DDC to
3739
// match this.
@@ -40,8 +42,10 @@ void main() {
4042
Expect.throws(() => allowInteropCaptureThis(wrappedFunctionCaptureThis));
4143
} else {
4244
Expect.equals(wrappedFunction, allowInteropCaptureThis(wrappedFunction));
43-
Expect.equals(wrappedFunctionCaptureThis,
44-
allowInteropCaptureThis(wrappedFunctionCaptureThis));
45+
Expect.equals(
46+
wrappedFunctionCaptureThis,
47+
allowInteropCaptureThis(wrappedFunctionCaptureThis),
48+
);
4549
}
4650
// Should directly return JS functions without doing anything.
4751
Expect.equals(jsFunction, allowInterop(jsFunction));
@@ -54,5 +58,7 @@ void main() {
5458
// Dart value, should return the previously wrapped function.
5559
Expect.equals(wrappedFunction, allowInterop(dartFunction));
5660
Expect.equals(
57-
wrappedFunctionCaptureThis, allowInteropCaptureThis(dartFunction));
61+
wrappedFunctionCaptureThis,
62+
allowInteropCaptureThis(dartFunction),
63+
);
5864
}

tests/lib/js/array_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ testArrayConstructor() {
2929

3030
// We could return a reified type here, but currently does not to match
3131
// dart2js, and because the Array is being returned to JS.
32-
Expect.isFalse(list2 is List<int>,
33-
'$list2 should not have a reified generic type (it was allocated by JS)');
32+
Expect.isFalse(
33+
list2 is List<int>,
34+
'$list2 should not have a reified generic type (it was allocated by JS)',
35+
);
3436

3537
list2.addAll([1, 2, 3]);
3638
Expect.listEquals(list, list2);

tests/lib/js/call_utils.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ dynamic confuse(dynamic x) => x;
1414
external dynamic eval(String script);
1515

1616
void injectJS() {
17-
eval(
18-
'''
17+
eval('''
1918
self.jsFunction = function(s) {
2019
if (this == null) {
2120
throw "`this` is null or undefined";
@@ -46,8 +45,7 @@ void injectJS() {
4645
}
4746
}
4847
self.jsClass = new NamedClass();
49-
''',
50-
);
48+
''');
5149
}
5250

5351
bool jsThisIsNullCheck(e) =>

tests/lib/js/export/functional_test.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ void testOverrides(WrapperCreator creator) {
172172
setProperty(overrides, 'getSet', 'derivedSetter');
173173

174174
expect(callMethod(overrides, 'method', []), dartOverrides.method());
175-
expect(callMethod(overrides, 'nonOverriddenMethod', []),
176-
dartOverrides.nonOverriddenMethod());
175+
expect(
176+
callMethod(overrides, 'nonOverriddenMethod', []),
177+
dartOverrides.nonOverriddenMethod(),
178+
);
177179
}
178180

179181
// Test case where some members are overridden by members not marked for export,
@@ -239,7 +241,10 @@ void testArity(WrapperCreator creator) {
239241
// Test that the transformation occurs in other js_util calls.
240242
void testNestedJsUtil(WrapperCreator creator) {
241243
setProperty(
242-
globalThis, 'export', creator.createExportAll(ExportAll.constructor()));
244+
globalThis,
245+
'export',
246+
creator.createExportAll(ExportAll.constructor()),
247+
);
243248
expect(hasProperty(globalThis, 'export'), true);
244249
expect(hasProperty(getProperty(globalThis, 'export'), 'field'), true);
245250
}

tests/lib/js/export/inheritance_collision_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class InheritanceRenameOneCollision extends SuperclassCollision
104104
// [web] The following class members collide with the same export 'finalField': MixinCollision.finalFieldMixin, SuperclassCollision.finalFieldSuper.
105105
// [web] The following class members collide with the same export 'getSet': MixinCollision.getSetMixin, MixinCollision.getSetMixin, SuperclassCollision.getSetSuper, SuperclassCollision.getSetSuper.
106106
// [web] The following class members collide with the same export 'method': MixinCollision.methodMixin, SuperclassCollision.methodSuper.
107-
with
107+
with
108108
MixinCollision {}
109109

110110
@JSExport()
@@ -114,7 +114,7 @@ class InheritanceRenameTwoCollisions extends SuperclassCollision
114114
// [web] The following class members collide with the same export 'finalField': MixinCollision.finalFieldMixin, MixinCollision2.finalFieldMixin2, SuperclassCollision.finalFieldSuper.
115115
// [web] The following class members collide with the same export 'getSet': MixinCollision.getSetMixin, MixinCollision.getSetMixin, MixinCollision2.getSetMixin2, MixinCollision2.getSetMixin2, SuperclassCollision.getSetSuper, SuperclassCollision.getSetSuper.
116116
// [web] The following class members collide with the same export 'method': MixinCollision.methodMixin, MixinCollision2.methodMixin2, SuperclassCollision.methodSuper.
117-
with
117+
with
118118
MixinCollision,
119119
MixinCollision2 {}
120120

@@ -125,7 +125,7 @@ class InheritanceRenameThreeCollisions extends SuperclassCollision
125125
// [web] The following class members collide with the same export 'finalField': InheritanceRenameThreeCollisions.finalFieldDerived, MixinCollision.finalFieldMixin, MixinCollision2.finalFieldMixin2, SuperclassCollision.finalFieldSuper.
126126
// [web] The following class members collide with the same export 'getSet': InheritanceRenameThreeCollisions.getSetDerived, InheritanceRenameThreeCollisions.getSetDerived, MixinCollision.getSetMixin, MixinCollision.getSetMixin, MixinCollision2.getSetMixin2, MixinCollision2.getSetMixin2, SuperclassCollision.getSetSuper, SuperclassCollision.getSetSuper.
127127
// [web] The following class members collide with the same export 'method': InheritanceRenameThreeCollisions.methodDerived, MixinCollision.methodMixin, MixinCollision2.methodMixin2, SuperclassCollision.methodSuper.
128-
with
128+
with
129129
MixinCollision,
130130
MixinCollision2 {
131131
@JSExport('field')

tests/lib/js/export/static_interop_mock/extension_conflict_test.dart

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ void testSameKindConflict() {
4343
// No error as one of the extension members are implemented for each export
4444
// name.
4545
createStaticInteropMock<SameKindConflict, DartSameKindConflict>(
46-
DartSameKindConflict());
46+
DartSameKindConflict(),
47+
);
4748
// Error as none of them are implemented for each export name.
4849
createStaticInteropMock<SameKindConflict, IncorrectDartSameKindConflict>(
49-
//^
50-
// [web] Dart class 'IncorrectDartSameKindConflict' does not have any members that implement any of the following extension member(s) with export name 'getter': E1.getter (FunctionType(int Function())), E2.getter (FunctionType(String Function())).
51-
// [web] Dart class 'IncorrectDartSameKindConflict' does not have any members that implement any of the following extension member(s) with export name 'method': E1.method (FunctionType(int Function())), E2.method (FunctionType(String Function())).
52-
// [web] Dart class 'IncorrectDartSameKindConflict' does not have any members that implement any of the following extension member(s) with export name 'setter': E1.setter= (FunctionType(void Function(int))), E2.setter= (FunctionType(void Function(int))).
53-
IncorrectDartSameKindConflict());
50+
// [error column 3]
51+
// [web] Dart class 'IncorrectDartSameKindConflict' does not have any members that implement any of the following extension member(s) with export name 'getter': E1.getter (FunctionType(int Function())), E2.getter (FunctionType(String Function())).
52+
// [web] Dart class 'IncorrectDartSameKindConflict' does not have any members that implement any of the following extension member(s) with export name 'method': E1.method (FunctionType(int Function())), E2.method (FunctionType(String Function())).
53+
// [web] Dart class 'IncorrectDartSameKindConflict' does not have any members that implement any of the following extension member(s) with export name 'setter': E1.setter= (FunctionType(void Function(int))), E2.setter= (FunctionType(void Function(int))).
54+
IncorrectDartSameKindConflict(),
55+
);
5456
}
5557

5658
@JS()
@@ -86,19 +88,23 @@ class ImplementMethod {
8688
void testDifferentKindConflict() {
8789
// Missing setter error.
8890
createStaticInteropMock<DifferentKindConflict, ImplementGetter>(
89-
//^
90-
// [web] Dart class 'ImplementGetter' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'getSet': E3.getSet= (FunctionType(void Function(int))).
91-
ImplementGetter());
91+
// [error column 3]
92+
// [web] Dart class 'ImplementGetter' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'getSet': E3.getSet= (FunctionType(void Function(int))).
93+
ImplementGetter(),
94+
);
9295
// Missing getter error.
9396
createStaticInteropMock<DifferentKindConflict, ImplementSetter>(
94-
//^
95-
// [web] Dart class 'ImplementSetter' has a setter, but does not have a getter to implement any of the following extension member(s) with export name 'getSet': E3.getSet (FunctionType(int Function())).
96-
ImplementSetter());
97+
// [error column 3]
98+
// [web] Dart class 'ImplementSetter' has a setter, but does not have a getter to implement any of the following extension member(s) with export name 'getSet': E3.getSet (FunctionType(int Function())).
99+
ImplementSetter(),
100+
);
97101
// No error as both getter and setter are there, and we've satisfied an export
98102
// for `getSet`.
99103
createStaticInteropMock<DifferentKindConflict, ImplementBoth>(
100-
ImplementBoth());
104+
ImplementBoth(),
105+
);
101106
// No error as we've satisfied an export for `getSet`.
102107
createStaticInteropMock<DifferentKindConflict, ImplementMethod>(
103-
ImplementMethod());
108+
ImplementMethod(),
109+
);
104110
}

tests/lib/js/export/static_interop_mock/functional_test_lib.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ extension on Methods {
2424
String nonExternal() => 'nonExternal';
2525
@JS('_rename')
2626
external String rename();
27-
external String optionalConcat(String foo, String bar,
28-
[String boo, String? baz]);
27+
external String optionalConcat(
28+
String foo,
29+
String bar, [
30+
String boo,
31+
String? baz,
32+
]);
2933
}
3034

3135
@JSExport()
@@ -141,8 +145,10 @@ class ParamsImpl<S extends JSObject, T extends JSObject, U extends Supertype> {
141145
}
142146

143147
void test([Object? proto]) {
144-
var jsMethods =
145-
createStaticInteropMock<Methods, MethodsDart>(MethodsDart(), proto);
148+
var jsMethods = createStaticInteropMock<Methods, MethodsDart>(
149+
MethodsDart(),
150+
proto,
151+
);
146152
expect(jsMethods.concat('a', 'b'), 'ab');
147153
expect(jsMethods.nonExternal(), 'nonExternal');
148154
expect(jsMethods.rename(), 'initialized');

tests/lib/js/export/static_interop_mock/incorrect_type_arguments_test.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ class Dart {
3232
void main() {
3333
createStaticInteropMock<StaticInterop, Dart>(Dart());
3434
createStaticInteropMock<Dart, StaticInterop>(StaticInterop());
35-
//^
36-
// [web] Type argument 'Dart' needs to be a `@staticInterop` type.
37-
// [web] Type argument 'StaticInterop' needs to be a non-JS interop type.
35+
// [error column 3]
36+
// [web] Type argument 'Dart' needs to be a `@staticInterop` type.
37+
// [web] Type argument 'StaticInterop' needs to be a non-JS interop type.
3838
createStaticInteropMock<Dart, Js>(Js());
39-
//^
40-
// [web] Type argument 'Dart' needs to be a `@staticInterop` type.
41-
// [web] Type argument 'Js' needs to be a non-JS interop type.
39+
// [error column 3]
40+
// [web] Type argument 'Dart' needs to be a `@staticInterop` type.
41+
// [web] Type argument 'Js' needs to be a non-JS interop type.
4242
createStaticInteropMock<Dart, Anonymous>(Anonymous());
43-
//^
44-
// [web] Type argument 'Anonymous' needs to be a non-JS interop type.
45-
// [web] Type argument 'Dart' needs to be a `@staticInterop` type.
43+
// [error column 3]
44+
// [web] Type argument 'Anonymous' needs to be a non-JS interop type.
45+
// [web] Type argument 'Dart' needs to be a `@staticInterop` type.
4646
createStaticInteropMock<StaticInterop, void Function()>(() {});
47-
//^
48-
// [web] Type argument 'void Function()' needs to be an interface type.
47+
// [error column 3]
48+
// [web] Type argument 'void Function()' needs to be an interface type.
4949
createStaticInteropMock(Dart());
50-
//^
51-
// [web] Type argument 'Object' needs to be a `@staticInterop` type.
50+
// [error column 3]
51+
// [web] Type argument 'Object' needs to be a `@staticInterop` type.
5252
}

tests/lib/js/export/static_interop_mock/proto_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ void main() {
3535
// Test that everything still works the same.
3636
functional_test.test(windowProto);
3737
// Test instanceof/is checks.
38-
var jsMock =
39-
createStaticInteropMock<JSWindow, DartWindow>(DartWindow(), windowProto);
38+
var jsMock = createStaticInteropMock<JSWindow, DartWindow>(
39+
DartWindow(),
40+
windowProto,
41+
);
4042
expect(jsMock is Window, true);
4143
expect(instanceof(jsMock, windowType), true);
4244
}

tests/lib/js/export/static_interop_mock/subtype_overrides_test.dart

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ extension on IncorrectDart {
5555
void testMissingOverrides() {
5656
createStaticInteropMock<StaticInterop, CorrectDart>(CorrectDart());
5757
createStaticInteropMock<StaticInterop, IncorrectDart>(IncorrectDart());
58-
//^
59-
// [web] Dart class 'IncorrectDart' does not have any members that implement any of the following extension member(s) with export name 'finalField': <unnamed>.finalField (FunctionType(int Function())).
60-
// [web] Dart class 'IncorrectDart' does not have any members that implement any of the following extension member(s) with export name 'method': <unnamed>.method (FunctionType(void Function())).
61-
// [web] Dart class 'IncorrectDart' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'field': <unnamed>.field= (FunctionType(void Function(int))).
62-
// [web] Dart class 'IncorrectDart' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'getSet2': <unnamed>.getSet2= (FunctionType(void Function(int))).
63-
// [web] Dart class 'IncorrectDart' has a setter, but does not have a getter to implement any of the following extension member(s) with export name 'getSet1': <unnamed>.getSet1 (FunctionType(int Function())).
58+
// [error column 3]
59+
// [web] Dart class 'IncorrectDart' does not have any members that implement any of the following extension member(s) with export name 'finalField': <unnamed>.finalField (FunctionType(int Function())).
60+
// [web] Dart class 'IncorrectDart' does not have any members that implement any of the following extension member(s) with export name 'method': <unnamed>.method (FunctionType(void Function())).
61+
// [web] Dart class 'IncorrectDart' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'field': <unnamed>.field= (FunctionType(void Function(int))).
62+
// [web] Dart class 'IncorrectDart' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'getSet2': <unnamed>.getSet2= (FunctionType(void Function(int))).
63+
// [web] Dart class 'IncorrectDart' has a setter, but does not have a getter to implement any of the following extension member(s) with export name 'getSet1': <unnamed>.getSet1 (FunctionType(int Function())).
6464
}
6565

6666
// Set up a simple type hierarchy.
@@ -114,7 +114,8 @@ class SubtypeSimpleDart {
114114

115115
void testSimpleSubtyping() {
116116
createStaticInteropMock<SimpleInterop, SubtypeSimpleDart>(
117-
SubtypeSimpleDart());
117+
SubtypeSimpleDart(),
118+
);
118119
}
119120

120121
// Implement using supertypes (which shouldn't work).
@@ -130,12 +131,13 @@ class SupertypeSimpleDart {
130131

131132
void testIncorrectSimpleSubtyping() {
132133
createStaticInteropMock<SimpleInterop, SupertypeSimpleDart>(
133-
//^
134-
// [web] Dart class 'SupertypeSimpleDart' does not have any members that implement any of the following extension member(s) with export name 'finalField': SimpleInteropExtension.finalField (FunctionType(B Function())).
135-
// [web] Dart class 'SupertypeSimpleDart' does not have any members that implement any of the following extension member(s) with export name 'method': SimpleInteropExtension.method (FunctionType(B Function(B))).
136-
// [web] Dart class 'SupertypeSimpleDart' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'getSet': SimpleInteropExtension.getSet= (FunctionType(void Function(B))).
137-
// [web] Dart class 'SupertypeSimpleDart' has a setter, but does not have a getter to implement any of the following extension member(s) with export name 'field': SimpleInteropExtension.field (FunctionType(B Function())).
138-
SupertypeSimpleDart());
134+
// [error column 3]
135+
// [web] Dart class 'SupertypeSimpleDart' does not have any members that implement any of the following extension member(s) with export name 'finalField': SimpleInteropExtension.finalField (FunctionType(B Function())).
136+
// [web] Dart class 'SupertypeSimpleDart' does not have any members that implement any of the following extension member(s) with export name 'method': SimpleInteropExtension.method (FunctionType(B Function(B))).
137+
// [web] Dart class 'SupertypeSimpleDart' has a getter, but does not have a setter to implement any of the following extension member(s) with export name 'getSet': SimpleInteropExtension.getSet= (FunctionType(void Function(B))).
138+
// [web] Dart class 'SupertypeSimpleDart' has a setter, but does not have a getter to implement any of the following extension member(s) with export name 'field': SimpleInteropExtension.field (FunctionType(B Function())).
139+
SupertypeSimpleDart(),
140+
);
139141
}
140142

141143
@JS()
@@ -157,8 +159,10 @@ class ComplexAndOptionalDart {
157159
}
158160

159161
void testComplexSubtyping() {
160-
createStaticInteropMock<ComplexAndOptionalInteropMethods,
161-
ComplexAndOptionalDart>(ComplexAndOptionalDart());
162+
createStaticInteropMock<
163+
ComplexAndOptionalInteropMethods,
164+
ComplexAndOptionalDart
165+
>(ComplexAndOptionalDart());
162166
}
163167

164168
@JSExport()
@@ -174,12 +178,13 @@ class IncorrectComplexAndOptionalDart {
174178

175179
void testIncorrectComplexSubtyping() {
176180
createStaticInteropMock<
177-
//^
178-
// [web] Dart class 'IncorrectComplexAndOptionalDart' does not have any members that implement any of the following extension member(s) with export name 'nestedTypes': ComplexAndOptionalInteropMethodsExtension.nestedTypes (FunctionType(B Function(B) Function(List<B>, Map<Set<B>, B>))).
179-
// [web] Dart class 'IncorrectComplexAndOptionalDart' does not have any members that implement any of the following extension member(s) with export name 'optional': ComplexAndOptionalInteropMethodsExtension.optional (FunctionType(B Function(B, [B?]))).
180-
// [web] Dart class 'IncorrectComplexAndOptionalDart' does not have any members that implement any of the following extension member(s) with export name 'optionalSubtype': ComplexAndOptionalInteropMethodsExtension.optionalSubtype (FunctionType(B Function(B, [B]))).
181-
ComplexAndOptionalInteropMethods,
182-
IncorrectComplexAndOptionalDart>(IncorrectComplexAndOptionalDart());
181+
// [error column 3]
182+
// [web] Dart class 'IncorrectComplexAndOptionalDart' does not have any members that implement any of the following extension member(s) with export name 'nestedTypes': ComplexAndOptionalInteropMethodsExtension.nestedTypes (FunctionType(B Function(B) Function(List<B>, Map<Set<B>, B>))).
183+
// [web] Dart class 'IncorrectComplexAndOptionalDart' does not have any members that implement any of the following extension member(s) with export name 'optional': ComplexAndOptionalInteropMethodsExtension.optional (FunctionType(B Function(B, [B?]))).
184+
// [web] Dart class 'IncorrectComplexAndOptionalDart' does not have any members that implement any of the following extension member(s) with export name 'optionalSubtype': ComplexAndOptionalInteropMethodsExtension.optionalSubtype (FunctionType(B Function(B, [B]))).
185+
ComplexAndOptionalInteropMethods,
186+
IncorrectComplexAndOptionalDart
187+
>(IncorrectComplexAndOptionalDart());
183188
}
184189

185190
void testSubtyping() {

0 commit comments

Comments
 (0)