Skip to content

Commit

Permalink
dart-lang#1959. Tests for syntax and basic restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Apr 7, 2023
1 parent ad6c725 commit 6ef01bf
Show file tree
Hide file tree
Showing 23 changed files with 1,068 additions and 0 deletions.
42 changes: 42 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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 is a compile-time error if:
/// - A declaration depends directly on a sealed declaration from another
/// library.
///
/// @description Check that it is a compile-time error if a declaration depends
/// directly on a `sealed` declaration from another library.
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

import "class_modifiers_lib.dart";

class ExtendsSealed extends SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class ImplementsSealed implements SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin OnSealed on SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class WithSealed with SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ExtendsSealed);
print(ImplementsSealed);
print(OnSealed);
print(WithSealed);
}
54 changes: 54 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A01_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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 is a compile-time error if:
/// - A declaration depends directly on a sealed declaration from another
/// library.
///
/// @description Check that it is a compile-time error if class marked `sealed`
/// is extended outside of the library where it is declared
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

import "class_modifiers_lib.dart";

abstract class AbstractExtendsSealed extends SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalExtendsSealed extends SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseExtendsSealed extends SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedExtendsSealed extends SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceExtendsSealed extends SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinExtendsSealed extends SealedClass {}
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(AbstractExtendsSealed);
print(FinalExtendsSealed);
print(BaseExtendsSealed);
print(SealedExtendsSealed);
print(InterfaceExtendsSealed);
print(MixinExtendsSealed);
}
30 changes: 30 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A01_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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 is a compile-time error if:
/// - A declaration depends directly on a sealed declaration from another
/// library.
///
/// @description Check that it is not an error if a declaration depends
/// a `sealed` declaration from another librarybut not directly
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

import "class_modifiers_lib.dart";

class ExtendsSealed1 extends ExtendsSealedClass with MixinOnSealed {}

class ImplementsSealed1 implements ExtendsSealedClass {}

class ExtendsSealed2 extends ImplementsSealedClass with MixinOnSealed {}

class ImplementsSealed2 implements ImplementsSealedClass {}

main() {
print(ExtendsSealed1);
print(ImplementsSealed1);
print(ExtendsSealed2);
print(ImplementsSealed2);
}
61 changes: 61 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A02_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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 is a compile-time error if:
/// ...
/// - A class extends or mixes in a declaration marked interface or final from
/// another library.
///
/// @description Check that it is a compile-time error if class marked
/// `interface` is extended outside of the library where it is declared
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

import "class_modifiers_lib.dart";

class ExtendsInterface extends InterfaceClass {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract class AbstractExtendsInterface extends InterfaceClass {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalExtendsInterface extends InterfaceClass {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseExtendsInterface extends InterfaceClass {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedExtendsInterface extends InterfaceClass {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceExtendsInterface extends InterfaceClass {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinExtendsInterface extends InterfaceClass {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ExtendsInterface);
print(AbstractExtendsInterface);
print(FinalExtendsInterface);
print(BaseExtendsInterface);
print(SealedExtendsInterface);
print(InterfaceExtendsInterface);
print(MixinExtendsInterface);
}
61 changes: 61 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A02_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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 is a compile-time error if:
/// ...
/// - A class extends or mixes in a declaration marked interface or final from
/// another library.
///
/// @description Check that it is a compile-time error if class marked `final`
/// is extended outside of the library where it is declared
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

import "class_modifiers_lib.dart";

class ExtendsFinal extends FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract class AbstractExtendsFinal extends FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalExtendsFinal extends FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseExtendsFinal extends FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedExtendsFinal extends FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceExtendsFinal extends FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinExtendsFinal extends FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ExtendsFinal);
print(AbstractExtendsFinal);
print(FinalExtendsFinal);
print(BaseExtendsFinal);
print(SealedExtendsFinal);
print(InterfaceExtendsFinal);
print(MixinExtendsFinal);
}
63 changes: 63 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A03_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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 is a compile-time error if:
/// ...
/// - A declaration implements another declaration, and the other declaration
/// itself, or any of its super-declarations, are marked base or final and are
/// not from the first declaration's library
///
/// @description Check that it is a compile-time error to implement the
/// interface of a class marked `base` outside of the library where it is
/// declared
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

import "class_modifiers_lib.dart";

class ImplementsBaseClass implements BaseClass {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract class AbstractImplementsBaseClass implements BaseClass {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalImplementsBaseClass implements BaseClass {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseImplementsBaseClass implements BaseClass {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedImplementsBaseClass implements BaseClass {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceImplementsBaseClass implements BaseClass {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinImplementsBaseClass implements BaseClass {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ImplementsBaseClass);
print(AbstractImplementsBaseClass);
print(FinalImplementsBaseClass);
print(BaseImplementsBaseClass);
print(SealedImplementsBaseClass);
print(InterfaceImplementsBaseClass);
print(MixinImplementsBaseClass);
}
63 changes: 63 additions & 0 deletions LanguageFeatures/Class-modifiers/basic_restrictions_A03_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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 is a compile-time error if:
/// ...
/// - A declaration implements another declaration, and the other declaration
/// itself, or any of its super-declarations, are marked base or final and are
/// not from the first declaration's library
///
/// @description Check that it is a compile-time error to implement the
/// interface of a class marked `final` outside of the library where it is
/// declared
/// @author [email protected]
// SharedOptions=--enable-experiment=class-modifiers

import "class_modifiers_lib.dart";

class ImplementsFinalClass implements FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

abstract class AbstractImplementsFinalClass implements FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

final class FinalImplementsFinalClass implements FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

base class BaseImplementsFinalClass implements FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

sealed class SealedImplementsFinalClass implements FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

interface class InterfaceImplementsFinalClass implements FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

mixin class MixinImplementsFinalClass implements FinalClass {}
// ^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
print(ImplementsFinalClass);
print(AbstractImplementsFinalClass);
print(FinalImplementsFinalClass);
print(BaseImplementsFinalClass);
print(SealedImplementsFinalClass);
print(InterfaceImplementsFinalClass);
print(MixinImplementsFinalClass);
}
Loading

0 comments on commit 6ef01bf

Please sign in to comment.