Skip to content

Commit

Permalink
dart-lang#2559. Add augmenting members tests. Part 2 (dart-lang#2799)
Browse files Browse the repository at this point in the history
Add augmenting members tests. Part 2
  • Loading branch information
sgrekhov authored Sep 2, 2024
1 parent 36ad405 commit e80817a
Show file tree
Hide file tree
Showing 22 changed files with 1,262 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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.

/// @assertion It is a compile-time error if:
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if an implicitly induced
/// getter of a final variable declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_members_A02_t01_lib.dart';

final String topLevelVariable = "topLevelVariable";

class C {
static final String staticVariable = "staticVariable";
final String instanceVariable = "instanceVariable";
}

mixin M {
static final String staticVariable = "staticVariable";
final String instanceVariable = "instanceVariable";
}

enum E {
e0;
static final String staticVariable = "staticVariable";
final String instanceVariable = "instanceVariable";
}

class A {}

extension Ext on A {
static final String staticVariable = "staticVariable";
}

extension type ET(String id) {
static final String staticVariable = "staticVariable";
}

main() {
print(topLevelVariable);
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// 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.

/// @assertion It is a compile-time error if:
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if an implicitly induced
/// getter of a final variable declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

augment library 'augmenting_members_A02_t01.dart';

/**/augment void set topLevelVariable(String _) {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment void set instanceVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment void set instanceVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E {
augment e0;
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment void set instanceVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment static void set id(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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.

/// @assertion It is a compile-time error if:
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if an implicitly induced
/// getter of a `late final` variable declaration with an initializer is
/// augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_members_A02_t02_lib.dart';

late final String topLevelVariable = "";

class C {
static late final String staticVariable = "";
late final String instanceVariable = "";
}

mixin M {
static late final String staticVariable = "";
late final String instanceVariable = "";
}

enum E {
e0;
static late final String staticVariable = "";
}

class A {}

extension Ext on A {
static late final String staticVariable = "";
}

extension type ET(String _) {
static late final String staticVariable = "";
}

main() {
print(topLevelVariable);
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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.

/// @assertion It is a compile-time error if:
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if an implicitly induced
/// getter of a `late final` variable declaration with an initializer is
/// augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

augment library 'augmenting_members_A02_t02.dart';

/**/augment void set topLevelVariable(String _) {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment void set instanceVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment void set instanceVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E {
augment e0;
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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.

/// @assertion It is a compile-time error if:
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if a `const` variable
/// declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_members_A02_t03_lib.dart';

const topLevelVariable = "topLevelVariable";

class C {
static const staticVariable = "staticVariable";
}

mixin M {
static const staticVariable = "staticVariable";
}

enum E {
e0;
static const staticVariable = "staticVariable";
}

class A {}

extension Ext on A {
static const staticVariable = "staticVariable";
}

extension type ET(String _) {
static const staticVariable = "staticVariable";
}

main() {
print(topLevelVariable);
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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.

/// @assertion It is a compile-time error if:
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if a `const` variable
/// declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

augment library 'augmenting_members_A02_t03.dart';

/**/augment void set topLevelVariable(String _) {}
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E {
augment e0;
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Loading

0 comments on commit e80817a

Please sign in to comment.