-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge c78ad94 into dev
- Loading branch information
Showing
7 changed files
with
165 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
pkg/linter/test/rules/always_declare_return_types_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// 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. | ||
|
||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../rule_test_support.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(AlwaysDeclareReturnTypesTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class AlwaysDeclareReturnTypesTest extends LintRuleTest { | ||
@override | ||
String get lintRule => 'always_declare_return_types'; | ||
|
||
test_augmentationClass() async { | ||
var a = newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'b.dart'; | ||
class A { } | ||
'''); | ||
|
||
var b = newFile('$testPackageLibPath/b.dart', r''' | ||
augment library 'a.dart'; | ||
augment class A { | ||
f() { } | ||
} | ||
'''); | ||
|
||
result = await resolveFile(a.path); | ||
await assertNoDiagnosticsIn(errors); | ||
|
||
result = await resolveFile(b.path); | ||
await assertDiagnosticsIn(errors, [ | ||
lint(47, 1), | ||
]); | ||
} | ||
|
||
test_augmentationTopLevelFunction() async { | ||
var a = newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'b.dart'; | ||
'''); | ||
|
||
var b = newFile('$testPackageLibPath/b.dart', r''' | ||
augment library 'a.dart'; | ||
f() { } | ||
'''); | ||
|
||
result = await resolveFile(a.path); | ||
await assertNoDiagnosticsIn(errors); | ||
|
||
result = await resolveFile(b.path); | ||
await assertDiagnosticsIn(errors, [ | ||
lint(27, 1), | ||
]); | ||
} | ||
|
||
/// Augmentation target chain variations tested in `augmentedTopLevelFunction{*}`. | ||
test_augmentedMethod() async { | ||
var a = newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'b.dart'; | ||
class A { | ||
f() { } | ||
} | ||
'''); | ||
|
||
var b = newFile('$testPackageLibPath/b.dart', r''' | ||
augment library 'a.dart'; | ||
augment class A { | ||
augment f() { } | ||
} | ||
'''); | ||
|
||
result = await resolveFile(a.path); | ||
await assertDiagnosticsIn(errors, [ | ||
lint(38, 1), | ||
]); | ||
|
||
result = await resolveFile(b.path); | ||
await assertNoDiagnosticsIn(errors); | ||
} | ||
|
||
test_augmentedTopLevelFunction() async { | ||
var a = newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'b.dart'; | ||
f() { } | ||
'''); | ||
|
||
var b = newFile('$testPackageLibPath/b.dart', r''' | ||
augment library 'a.dart'; | ||
augment f() { } | ||
'''); | ||
|
||
result = await resolveFile(a.path); | ||
await assertDiagnosticsIn(errors, [ | ||
lint(26, 1), | ||
]); | ||
|
||
result = await resolveFile(b.path); | ||
await assertNoDiagnosticsIn(errors); | ||
} | ||
|
||
test_augmentedTopLevelFunction_chain() async { | ||
var a = newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'b.dart'; | ||
f() { } | ||
'''); | ||
|
||
var b = newFile('$testPackageLibPath/b.dart', r''' | ||
augment library 'a.dart'; | ||
augment dynamic f() { } | ||
augment f() { } | ||
'''); | ||
|
||
result = await resolveFile(a.path); | ||
await assertDiagnosticsIn(errors, [ | ||
lint(26, 1), | ||
]); | ||
|
||
result = await resolveFile(b.path); | ||
await assertNoDiagnosticsIn(errors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,5 +27,5 @@ CHANNEL dev | |
MAJOR 3 | ||
MINOR 5 | ||
PATCH 0 | ||
PRERELEASE 88 | ||
PRERELEASE 89 | ||
PRERELEASE_PATCH 0 |