Skip to content

Commit

Permalink
#1959. More basic and mixin restrictions tests (#2021)
Browse files Browse the repository at this point in the history
Add more basic and mixin restrictions tests.
  • Loading branch information
sgrekhov authored Apr 17, 2023
1 parent c966bce commit a740be1
Show file tree
Hide file tree
Showing 21 changed files with 3,451 additions and 2 deletions.
84 changes: 84 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A05_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 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 An enum declaration still cannot be implemented, extended or
/// mixed in anywhere, independently of modifiers.
///
/// @description Check that it is a compile-time error if an enum declaration is
/// extended or used in mixin's `on` part
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

enum E {e1, e2}

class ExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract class AbstractExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract base class AbstractBaseExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified


abstract interface class AbstractInterfaceExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract final class AbstractFinalExtendsEnum extends E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

mixin MixinOnEnum on E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

base mixin BaseMixinOnEnum on E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ExtendsEnum);
print(BaseExtendsEnum);
print(InterfaceExtendsEnum);
print(FinalExtendsEnum);
print(SealedExtendsEnum);
print(AbstractExtendsEnum);
print(AbstractBaseExtendsEnum);
print(AbstractInterfaceExtendsEnum);
print(AbstractFinalExtendsEnum);
print(MixinOnEnum);
print(BaseMixinOnEnum);
}
108 changes: 108 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A05_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// 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 An enum declaration still cannot be implemented, extended or
/// mixed in anywhere, independently of modifiers.
///
/// @description Check that it is a compile-time error if an enum declaration is
/// implemented
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

enum E {e1, e2}

class ImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract class AbstractImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract base class AbstractBaseImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified


abstract interface class AbstractInterfaceImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract final class AbstractFinalImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinClassImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

base mixin class BaseMixinClassImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract mixin class AbstractMixinClassImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract base mixin class AbstractBaseMixinClassImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

mixin MixinImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

base mixin BaseMixinImplementsEnum implements E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ImplementsEnum);
print(BaseImplementsEnum);
print(InterfaceImplementsEnum);
print(FinalImplementsEnum);
print(SealedImplementsEnum);
print(AbstractImplementsEnum);
print(AbstractBaseImplementsEnum);
print(AbstractInterfaceImplementsEnum);
print(AbstractFinalImplementsEnum);
print(MixinClassImplementsEnum);
print(BaseMixinClassImplementsEnum);
print(AbstractMixinClassImplementsEnum);
print(AbstractBaseMixinClassImplementsEnum);
print(MixinImplementsEnum);
print(BaseMixinImplementsEnum);
}
96 changes: 96 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A05_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// 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 An enum declaration still cannot be implemented, extended or
/// mixed in anywhere, independently of modifiers.
///
/// @description Check that it is a compile-time error if an enum declaration is
/// mixed in
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

enum E {e1, e2}

class WithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract class AbstractWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract base class AbstractBaseWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified


abstract interface class AbstractInterfaceWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract final class AbstractFinalWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinClassWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

base mixin class BaseMixinClassWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract mixin class AbstractMixinClassWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

abstract base mixin class AbstractBaseMixinClassWithEnum with E {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(WithEnum);
print(BaseWithEnum);
print(InterfaceWithEnum);
print(FinalWithEnum);
print(SealedWithEnum);
print(AbstractWithEnum);
print(AbstractBaseWithEnum);
print(AbstractInterfaceWithEnum);
print(AbstractFinalWithEnum);
print(MixinClassWithEnum);
print(BaseMixinClassWithEnum);
print(AbstractMixinClassWithEnum);
print(AbstractBaseMixinClassWithEnum);
}
13 changes: 11 additions & 2 deletions LanguageFeatures/Class-modifiers/class_modifiers_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ abstract base mixin class AbstractBaseMixinClass {}
mixin Mixin {}
base mixin BaseMixin {}

typedef TypedefFinalClass = FinalClass;
typedef TypedefBaseClass = BaseClass;
typedef TypedefInterfaceClass = InterfaceClass;
typedef TypedefFinalClass = FinalClass;
typedef TypedefSealedClass = SealedClass;
typedef TypedefBaseClass = BaseClass;
typedef TypedefAbstractClass = AbstractClass;
typedef TypedefAbstractBaseClass = AbstractBaseClass;
typedef TypedefAbstractInterfaceClass = AbstractInterfaceClass;
typedef TypedefAbstractFinalClass = AbstractFinalClass;
typedef TypedefMixinClass = MixinClass;
typedef TypedefBaseMixinClass = BaseMixinClass;
typedef TypedefAbstractBaseMixinClass = AbstractBaseMixinClass;
typedef TypedefMixin = Mixin;
typedef TypedefBaseMixin = BaseMixin;

class ExtendsSealedClass extends SealedClass {}
class ImplementsSealedClass implements SealedClass {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.

/// @description Library containing pre-feature classes for testing class
/// modifiers
/// @author [email protected]
// @dart=2.19

library class_modifiers_pre_feature_lib;

class Class {}
abstract class AbstractClass {}
mixin Mixin {}

typedef TypedefClass = Class;
typedef TypedefAbstractClass = AbstractClass;
typedef TypedefMixin = Mixin;
66 changes: 66 additions & 0 deletions LanguageFeatures/Class-modifiers/mixin_restrictions_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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 It's a compile-time error if a mixin class declaration:
/// ...
/// - has an extends clause
///
/// @description Check that it is a compile-time error if a `mixin class`
/// declaration has an `extends` clause
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

class C {}

mixin class MixinClassExtendsObject extends Object {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

base mixin class BaseMixinClassExtendsObject extends Object {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract mixin class AbstractMixinClassExtendsObject extends Object {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract base mixin class AbstractBaseMixinClassExtendsObject extends Object {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinClassExtendsC extends C {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

base mixin class BaseMixinClassExtendsC extends C {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract mixin class AbstractMixinClassExtendsC extends C {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract base mixin class AbstractBaseMixinClassExtendsC extends C {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(MixinClassExtendsObject);
print(BaseMixinClassExtendsObject);
print(AbstractMixinClassExtendsObject);
print(AbstractBaseMixinClassExtendsObject);
print(MixinClassExtendsC);
print(BaseMixinClassExtendsC);
print(AbstractMixinClassExtendsC);
print(AbstractBaseMixinClassExtendsC);
}
Loading

0 comments on commit a740be1

Please sign in to comment.