-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Test for restrictions of valid combinations of modifiers.
- Loading branch information
Showing
32 changed files
with
2,278 additions
and
0 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
55 changes: 55 additions & 0 deletions
55
LanguageFeatures/Class-modifiers/syntax_base_class_A01_t01.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,55 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion Base class can be constructed and extended but not implemented, | ||
/// mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that `base class` can be constructed and extended by | ||
/// `base/final/sealed` classes | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
base class LocalBaseClass {} | ||
|
||
base class BaseClassExtendsBaseClass extends BaseClass {} | ||
|
||
final class FinalClassExtendsBaseClass extends BaseClass {} | ||
|
||
sealed class SealedClassExtendsBaseClass extends BaseClass {} | ||
|
||
abstract base class AbstractBaseClassExtendsBaseClass extends BaseClass {} | ||
|
||
abstract final class AbstractFinalClassExtendsBaseClass extends BaseClass {} | ||
|
||
base class BaseClassExtendsLocalBaseClass extends LocalBaseClass {} | ||
|
||
final class FinalClassExtendsLocalBaseClass extends LocalBaseClass {} | ||
|
||
sealed class SealedClassExtendsLocalBaseClass extends LocalBaseClass {} | ||
|
||
abstract base class AbstractBaseClassExtendsLocalBaseClass | ||
extends LocalBaseClass {} | ||
|
||
abstract final class AbstractFinalClassExtendsLocalBaseClass | ||
extends LocalBaseClass {} | ||
|
||
main() { | ||
BaseClass(); | ||
LocalBaseClass(); | ||
|
||
print(BaseClassExtendsBaseClass); | ||
print(FinalClassExtendsBaseClass); | ||
print(SealedClassExtendsBaseClass); | ||
print(AbstractBaseClassExtendsBaseClass); | ||
print(AbstractFinalClassExtendsBaseClass); | ||
|
||
print(BaseClassExtendsLocalBaseClass); | ||
print(FinalClassExtendsLocalBaseClass); | ||
print(SealedClassExtendsLocalBaseClass); | ||
print(AbstractBaseClassExtendsLocalBaseClass); | ||
print(AbstractFinalClassExtendsLocalBaseClass); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Class-modifiers/syntax_base_class_A02_t01.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,47 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion Base class can be constructed and extended but not implemented, | ||
/// mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that it is a compile-time error if a `base class` is | ||
/// implemented outside of the library where it is defined | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
base class BaseClassImplementsBaseClass implements BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassImplementsBaseClass implements BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassImplementsBaseClass implements BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassImplementsBaseClass implements BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassImplementsBaseClass implements BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(BaseClassImplementsBaseClass); | ||
print(FinalClassImplementsBaseClass); | ||
print(SealedClassImplementsBaseClass); | ||
print(AbstractBaseClassImplementsBaseClass); | ||
print(AbstractFinalClassImplementsBaseClass); | ||
} |
34 changes: 34 additions & 0 deletions
34
LanguageFeatures/Class-modifiers/syntax_base_class_A02_t02.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,34 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion Base class can be constructed and extended but not implemented, | ||
/// mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that it is not an error if a `base class` is | ||
/// implemented in the same library where it is defined | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
base class LocalBaseClass {} | ||
|
||
base class BaseClassImplementsLocalBaseClass implements LocalBaseClass {} | ||
|
||
final class FinalClassImplementsLocalBaseClass implements LocalBaseClass {} | ||
|
||
sealed class SealedClassImplementsLocalBaseClass implements LocalBaseClass {} | ||
|
||
abstract base class AbstractBaseClassImplementsLocalBaseClass | ||
implements LocalBaseClass {} | ||
|
||
abstract final class AbstractFinalClassImplementsLocalBaseClass | ||
implements LocalBaseClass {} | ||
|
||
main() { | ||
print(BaseClassImplementsLocalBaseClass); | ||
print(FinalClassImplementsLocalBaseClass); | ||
print(SealedClassImplementsLocalBaseClass); | ||
print(AbstractBaseClassImplementsLocalBaseClass); | ||
print(AbstractFinalClassImplementsLocalBaseClass); | ||
} |
140 changes: 140 additions & 0 deletions
140
LanguageFeatures/Class-modifiers/syntax_base_class_A03_t01.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,140 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion Base class can be constructed and extended but not implemented, | ||
/// mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that it is a compile-time error if a `base class` is | ||
/// mixed in | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
base class LocalBaseClass {} | ||
|
||
base class BaseClassWithBaseClass1 with BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base class BaseClassWithBaseClass2 = Object with BaseClass; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassWithBaseClass1 with BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassWithBaseClass2 = Object with BaseClass; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassWithBaseClass1 with BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassWithBaseClass2 = Object with BaseClass; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassWithBaseClass1 with BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassWithBaseClass2 = Object with BaseClass; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassWithBaseClass1 with BaseClass {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassWithBaseClass2 = Object with BaseClass; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base class BaseClassWithLocalBaseClass1 with LocalBaseClass {} | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base class BaseClassWithLocalBaseClass2 = Object with LocalBaseClass; | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassWithLocalBaseClass1 with LocalBaseClass {} | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassWithLocalBaseClass2 = Object with LocalBaseClass; | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassWithLocalBaseClass1 with LocalBaseClass {} | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassWithLocalBaseClass2 = Object with LocalBaseClass; | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassWithLocalBaseClass1 with LocalBaseClass {} | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassWithLocalBaseClass2 = Object with LocalBaseClass; | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassWithLocalBaseClass1 with LocalBaseClass {} | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassWithLocalBaseClass2 = Object with LocalBaseClass; | ||
// ^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(BaseClassWithBaseClass1); | ||
print(BaseClassWithBaseClass2); | ||
print(FinalClassWithBaseClass1); | ||
print(FinalClassWithBaseClass2); | ||
print(SealedClassWithBaseClass1); | ||
print(SealedClassWithBaseClass2); | ||
print(AbstractBaseClassWithBaseClass1); | ||
print(AbstractBaseClassWithBaseClass2); | ||
print(AbstractFinalClassWithBaseClass1); | ||
print(AbstractFinalClassWithBaseClass2); | ||
|
||
print(BaseClassWithLocalBaseClass1); | ||
print(BaseClassWithLocalBaseClass2); | ||
print(FinalClassWithLocalBaseClass1); | ||
print(FinalClassWithLocalBaseClass2); | ||
print(SealedClassWithLocalBaseClass1); | ||
print(SealedClassWithLocalBaseClass2); | ||
print(AbstractBaseClassWithLocalBaseClass1); | ||
print(AbstractBaseClassWithLocalBaseClass2); | ||
print(AbstractFinalClassWithLocalBaseClass1); | ||
print(AbstractFinalClassWithLocalBaseClass2); | ||
} |
38 changes: 38 additions & 0 deletions
38
LanguageFeatures/Class-modifiers/syntax_base_class_A04_t01.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,38 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion Base class can be constructed and extended but not implemented, | ||
/// mixed in and is not exhaustive | ||
/// | ||
/// @description Checks that `base class` is not exhaustive | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
import "class_modifiers_lib.dart"; | ||
|
||
base class C {} | ||
base class ExtendsC1 extends C {} | ||
base class ExtendsC2 extends C {} | ||
|
||
String test1(C c) => switch (c) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
ExtendsC1 _ => "ExtendsC1", | ||
ExtendsC2 _ => "ExtendsC2", | ||
}; | ||
|
||
String test2(BaseClass c) => switch (c) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
BaseExtendsBaseClass1 _ => "BaseExtendsBaseClass1", | ||
BaseExtendsBaseClass2 _ => "BaseExtendsBaseClass2", | ||
}; | ||
|
||
main() { | ||
test1(ExtendsC1()); | ||
test2(BaseExtendsBaseClass1()); | ||
} |
Oops, something went wrong.