From 0d63c9735829d134758eb0e5a6de0c4d6bc79a27 Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Thu, 2 Jan 2025 03:27:35 -0800 Subject: [PATCH] Reformat files in the top level of tests/language/. Change-Id: I21e39caac0239bfe388e7c7f149723f3deafb87c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400221 Auto-Submit: Bob Nystrom Commit-Queue: Lasse Nielsen Reviewed-by: Lasse Nielsen --- ...licit_type_instantiation_parsing_test.dart | 15 ++++--- tests/language/record_literal_test.dart | 3 ++ tests/language/record_type_test.dart | 3 ++ tests/language/regress_54994_test.dart | 10 +++-- .../static_weak_reference_error_test.dart | 40 +++++++++---------- tests/language/syntax_helper.dart | 27 ++++++++----- 6 files changed, 59 insertions(+), 39 deletions(-) diff --git a/tests/language/explicit_type_instantiation_parsing_test.dart b/tests/language/explicit_type_instantiation_parsing_test.dart index 487bd1d905f9..06750e07455e 100644 --- a/tests/language/explicit_type_instantiation_parsing_test.dart +++ b/tests/language/explicit_type_instantiation_parsing_test.dart @@ -169,8 +169,9 @@ void main() { // Parsed as instantiation, can't access statics on instantiated type literal. expect1(Z.instance); - // ^^^^^^^^ - // [analyzer] unspecified + // ^^^^^^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.CLASS_INSTANTIATION_ACCESS_TO_MEMBER + // ^ // [cfe] Cannot access static member on an instantiated generic class. @@ -260,13 +261,15 @@ void main() { // This would be invalid even if `X` had an `any` member. See next. X.any; // Invalid, Class does not have any static `any` member. - // ^^^ - // [analyzer] unspecified + // [error column 3, length 8] + // [analyzer] COMPILE_TIME_ERROR.CLASS_INSTANTIATION_ACCESS_TO_MEMBER + // ^ // [cfe] Member not found: 'any'. X.instance; // Does have static `instance` member, can't access this way. - // ^^^^^^^^ - // [analyzer] unspecified + // [error column 3, length 13] + // [analyzer] COMPILE_TIME_ERROR.CLASS_INSTANTIATION_ACCESS_TO_MEMBER + // ^ // [cfe] Cannot access static member on an instantiated generic class. // Parse error. diff --git a/tests/language/record_literal_test.dart b/tests/language/record_literal_test.dart index 826324069ade..fb823afb7adf 100644 --- a/tests/language/record_literal_test.dart +++ b/tests/language/record_literal_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// Don't let the formatter remove the trailing commas. +// dart format off + main() { var record1 = (1, 2, a: 3, b: 4); print(record1); diff --git a/tests/language/record_type_test.dart b/tests/language/record_type_test.dart index 5b5a26e90698..a2ae9d898ea2 100644 --- a/tests/language/record_type_test.dart +++ b/tests/language/record_type_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// Don't let the formatter remove the trailing commas. +// dart format off + main() { (int, int) record1 = (1, 2); print(record1); diff --git a/tests/language/regress_54994_test.dart b/tests/language/regress_54994_test.dart index e93365c98c01..49d89b85b0d8 100644 --- a/tests/language/regress_54994_test.dart +++ b/tests/language/regress_54994_test.dart @@ -27,9 +27,10 @@ void test1() { } void test2() { - final B1 a = kTrue - ? (B1() as B1) - : (B2() as B1); + final B1 a = + kTrue + ? (B1() as B1) + : (B2() as B1); Expect.isFalse(a is B2); Expect.isFalse(a is B2); Expect.isFalse(a is B2); // Should be optimized to cid-range check. @@ -85,7 +86,8 @@ class X { kTrue ? B2>() : B1, List>(); Expect.isTrue(a is B2>); // Should be optimized to cid-range check. Expect.isTrue( - a is B2>); // Should be optimized to cid-range check. + a is B2>, + ); // Should be optimized to cid-range check. Expect.isTrue(a is B2>); Expect.isFalse(a is B2>); } diff --git a/tests/language/static_weak_reference_error_test.dart b/tests/language/static_weak_reference_error_test.dart index f29c07488feb..efe6a18c413b 100644 --- a/tests/language/static_weak_reference_error_test.dart +++ b/tests/language/static_weak_reference_error_test.dart @@ -61,8 +61,8 @@ class A { @pragma('weak-tearoff-reference') external T Function()? weakReference12(T Function()? x); -// ^ -// [cfe] Weak reference pragma can be used on a static method only. + // ^ + // [cfe] Weak reference pragma can be used on a static method only. } class B { @@ -83,42 +83,42 @@ void main() { validWeakRef(B.validTarget); // OK validWeakRef(B.new); -//^ -// [cfe] The target of weak reference should be a tearoff of a static method. + // [error column 3] + // [cfe] The target of weak reference should be a tearoff of a static method. validWeakRef(B.bar); -//^ -// [cfe] The target of weak reference should be a tearoff of a static method. + // [error column 3] + // [cfe] The target of weak reference should be a tearoff of a static method. validWeakRef(B.baz); -//^ -// [cfe] The target of weak reference should be a tearoff of a static method. + // [error column 3] + // [cfe] The target of weak reference should be a tearoff of a static method. validWeakRef(B().instanceMethod); -//^ -// [cfe] The target of weak reference should be a tearoff of a static method. + // [error column 3] + // [cfe] The target of weak reference should be a tearoff of a static method. final x = B.validTarget; validWeakRef(x); -//^ -// [cfe] The target of weak reference should be a tearoff of a static method. + // [error column 3] + // [cfe] The target of weak reference should be a tearoff of a static method. const y = B.validTarget; validWeakRef(y); // OK validWeakRef(B.arg1); -//^ -// [cfe] The target of weak reference should not take parameters. + // [error column 3] + // [cfe] The target of weak reference should not take parameters. validWeakRef(B.arg2); -//^ -// [cfe] The target of weak reference should not take parameters. + // [error column 3] + // [cfe] The target of weak reference should not take parameters. validWeakRef(B.arg3); -//^ -// [cfe] The target of weak reference should not take parameters. + // [error column 3] + // [cfe] The target of weak reference should not take parameters. validWeakRef(B.arg4); -//^ -// [cfe] The target of weak reference should not take parameters. + // [error column 3] + // [cfe] The target of weak reference should not take parameters. } diff --git a/tests/language/syntax_helper.dart b/tests/language/syntax_helper.dart index 586edc0ddd8a..76ac5bd6a360 100644 --- a/tests/language/syntax_helper.dart +++ b/tests/language/syntax_helper.dart @@ -28,14 +28,17 @@ String syntax(Object? x) { return '{${x.map(syntax).join(', ')}}'; } else if (x is Map) { if (x.isEmpty) return '{}'; - var entries = x.entries - .map((entry) => '${syntax(entry.key)}: ${syntax(entry.value)}'); + var entries = x.entries.map( + (entry) => '${syntax(entry.key)}: ${syntax(entry.value)}', + ); return '{ ${entries.join(', ')} }'; } else if (x is String) { return json.encode(x); } else { - throw UnimplementedError('Unknown syntax for $x. ' - 'Consider adding to `SyntaxTracker.known`.'); + throw UnimplementedError( + 'Unknown syntax for $x. ' + 'Consider adding to `SyntaxTracker.known`.', + ); } } @@ -58,18 +61,23 @@ class SyntaxTracker { static Map known = { true: 'true', false: 'false', - null: 'null' + null: 'null', }; } /// Extension allowing us to detect the syntax of most operations performed on /// arbitrary types. extension SyntaxTrackingExtension on Object? { - Object? method([Object? x = absent, Object? y = absent]) => SyntaxTracker( - '${syntax(this)}.method${SyntaxTracker.typeArgs(T, U)}${SyntaxTracker.args(x, y)}'); + Object? method([ + Object? x = absent, + Object? y = absent, + ]) => SyntaxTracker( + '${syntax(this)}.method${SyntaxTracker.typeArgs(T, U)}${SyntaxTracker.args(x, y)}', + ); Object? call([Object? x = absent, Object? y = absent]) => SyntaxTracker( - '${syntax(this)}${SyntaxTracker.typeArgs(T, U)}${SyntaxTracker.args(x, y)}'); + '${syntax(this)}${SyntaxTracker.typeArgs(T, U)}${SyntaxTracker.args(x, y)}', + ); Object? get getter => SyntaxTracker('${syntax(this)}.getter'); @@ -131,6 +139,7 @@ void checkSyntax(Object? x, String expectedSyntax) { } Object? f([Object? x = absent, Object? y = absent]) => SyntaxTracker( - 'f${SyntaxTracker.typeArgs(T, U)}${SyntaxTracker.args(x, y)}'); + 'f${SyntaxTracker.typeArgs(T, U)}${SyntaxTracker.args(x, y)}', +); Object? x = SyntaxTracker('x');