Skip to content

Commit

Permalink
dart-lang#2559. Add augmented expression tests for function
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed May 1, 2024
1 parent 6066581 commit d4a45aa
Show file tree
Hide file tree
Showing 5 changed files with 395 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 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 The exact result of an `augmented` expression depends on what is
/// being augmented, but it generally follows the same rules as any normal
/// identifier:
/// ...
/// - Augmenting functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to tear-off `augmented`
/// expression inside of an augmenting function
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A04_t01_lib1.dart';
import augment 'augmented_expression_A04_t01_lib2.dart';

const augmented = "Augmented constant, should not be used";

void topLevelFunction() {}

class C {
static void staticMethod() {}
void instanceMethod() {}
final augmented = "C.augmented, should not be used";
}

mixin M {
static void staticMethod() {}
void instanceMethod() {}
final augmented = "M.augmented, should not be used";
}

enum E {
e1;

static void staticMethod() {}
void instanceMethod() {}
final augmented = "E.augmented, should not be used";
}

class A {}

extension Ext on A {
static void staticMethod() {}
void instanceMethod() {}
final augmented = "Ext.augmented, should not be used";
}

main() {
print(topLevelFunction);
print(C);
print(M);
print(E);
print(A);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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 The exact result of an `augmented` expression depends on what is
/// being augmented, but it generally follows the same rules as any normal
/// identifier:
/// ...
/// - Augmenting functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to tear-off `augmented`
/// expression inside of an augmenting function
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A04_t01.dart';

augment void topLevelFunction() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment class C {
augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment mixin M {
augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment enum E {
augment e1;

augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment extension Ext {
augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// 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 The exact result of an `augmented` expression depends on what is
/// being augmented, but it generally follows the same rules as any normal
/// identifier:
/// ...
/// - Augmenting functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to tear-off `augmented`
/// expression inside of an augmenting function
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A04_t01.dart';

augment void topLevelFunction() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment class C {
augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
}

augment mixin M {
augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
}

augment enum E {
augment e1;

augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
}

augment extension Ext {
augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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 The exact result of an `augmented` expression depends on what is
/// being augmented, but it generally follows the same rules as any normal
/// identifier:
/// ...
/// - Augmenting functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to declare a local
/// variable named `augmented` inside of an augmenting function
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A04_t02_lib.dart';

void topLevelFunction() {}

class C {
static void staticMethod() {}
void instanceMethod() {}
}

mixin M {
static void staticMethod() {}
void instanceMethod() {}
}

enum E {
e1;

static void staticMethod() {}
void instanceMethod() {}
}

class A {}

extension Ext on A {
static void staticMethod() {}
void instanceMethod() {}
}

main() {
print(topLevelFunction);
print(C);
print(M);
print(E);
print(A);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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 The exact result of an `augmented` expression depends on what is
/// being augmented, but it generally follows the same rules as any normal
/// identifier:
/// ...
/// - Augmenting functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to tear-off `augmented`
/// expression inside of an augmenting function
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A04_t02.dart';

augment void topLevelFunction() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment class C {
augment static void staticMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment mixin M {
augment static void staticMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment enum E {
augment e1;

augment static void staticMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment extension Ext {
augment static void staticMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

0 comments on commit d4a45aa

Please sign in to comment.