-
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.
Augment. Issue 55295. Report AUGMENTATION_WITHOUT_DECLARATION.
Bug: #55295 Change-Id: I50811e1ccd7a2be0e71b18eefa9ecb76ac1aef73 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359961 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
- Loading branch information
Showing
7 changed files
with
298 additions
and
10 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
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
223 changes: 223 additions & 0 deletions
223
pkg/analyzer/test/src/diagnostics/augmentation_without_declaration_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,223 @@ | ||
// 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:analyzer/src/error/codes.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../dart/resolution/context_collection_resolution.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(AugmentationWithoutDeclarationTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class AugmentationWithoutDeclarationTest extends PubPackageResolutionTest { | ||
test_class() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment class A {} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 27, 7), | ||
]); | ||
} | ||
|
||
test_class_constructor() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
class A {} | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment class A { | ||
augment A.named(); | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 47, 7), | ||
]); | ||
} | ||
|
||
test_class_field() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
class A {} | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment class A { | ||
augment int foo = 0; | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 47, 7), | ||
]); | ||
} | ||
|
||
test_class_getter() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
class A {} | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment class A { | ||
augment int get foo => 0; | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 47, 7), | ||
]); | ||
} | ||
|
||
test_class_method() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
class A {} | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment class A { | ||
augment void foo() {} | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 47, 7), | ||
]); | ||
} | ||
|
||
test_class_method_valid() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
class A { | ||
void foo() {} | ||
} | ||
'''); | ||
|
||
await assertNoErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment class A { | ||
augment void foo() {} | ||
} | ||
'''); | ||
} | ||
|
||
test_class_setter() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
class A {} | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment class A { | ||
augment set foo(int _) {} | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 47, 7), | ||
]); | ||
} | ||
|
||
test_mixin() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment mixin A {} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 27, 7), | ||
]); | ||
} | ||
|
||
test_topLevel_function() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment void foo() {} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 27, 7), | ||
]); | ||
} | ||
|
||
test_topLevel_function_valid() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
void foo() {} | ||
'''); | ||
|
||
await assertNoErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment void foo() {} | ||
'''); | ||
} | ||
|
||
test_topLevel_getter() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment int get foo => 0; | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 27, 7), | ||
]); | ||
} | ||
|
||
test_topLevel_setter() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment set foo(int _) {} | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 27, 7), | ||
]); | ||
} | ||
|
||
test_topLevel_variable() async { | ||
newFile('$testPackageLibPath/a.dart', r''' | ||
import augment 'test.dart'; | ||
'''); | ||
|
||
await assertErrorsInCode(r''' | ||
library augment 'a.dart'; | ||
augment int foo = 0; | ||
''', [ | ||
error(CompileTimeErrorCode.AUGMENTATION_WITHOUT_DECLARATION, 27, 7), | ||
]); | ||
} | ||
} |
Oops, something went wrong.