Skip to content

Commit

Permalink
dart-lang#2559. Make augmented expression tests stronger
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Apr 30, 2024
1 parent d868920 commit 63a0343
Show file tree
Hide file tree
Showing 25 changed files with 531 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,32 @@
import augment 'augmented_expression_A01_t01_lib.dart';
import '../../Utils/expect.dart';

String get augmented => "Getter augmented";

String get augmented => "Global getter, shouldn't be invoked";
String get topLevelGetter => "Original";

class C {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "C.augmented, shouldn't be invoked";
}

mixin M {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "M.augmented, shouldn't be invoked";
}

enum E {
e1;

static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "E.augmented, shouldn't be invoked";
}

class A {}
class A {
String get augmented => "A.augmented, shouldn't be invoked";
}

extension Ext on A {
static String get staticGetter => "Original";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,34 @@
import augment 'augmented_expression_A01_t02_lib.dart';
import '../../Utils/expect.dart';

String get augmented => "Getter augmented";

String get augmented => "Global getter, shouldn't be invoked";
String topLevelVariable = "Original";

class C {
static String staticField = "Original";
String instanceField = "Original";
static String get augmented => "C.augmented, shouldn't be invoked";
}

mixin M {
static String staticField = "Original";
String instanceField = "Original";
static String get augmented => "M.augmented, shouldn't be invoked";
}

enum E {
e1;

static String staticField = "Original";
final String instanceField = "Original";
static String get augmented => "E.augmented, shouldn't be invoked";
}

class A {}

extension Ext on A {
static String staticField = "Original";
static String get augmented => "Ext.augmented, shouldn't be invoked";
}

class MA = Object with M;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,35 @@

import augment 'augmented_expression_A01_t03_lib.dart';

String augmented() => "Function augmented()";

String augmented() => "Global function, shouldn't be invoked";
String get topLevelGetter => "Original";

class C {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
static String augmented() => "C.augmented(), shouldn't be invoked";
}

mixin M {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
static String augmented() => "M.augmented(), shouldn't be invoked";
}

enum E {
e1;

static String get staticGetter => "Original";
String get instanceGetter => "Original";
static String augmented() => "E.augmented(), shouldn't be invoked";
}

class A {}

extension Ext on A {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
static String augmented() => "Ext.augmented(), shouldn't be invoked";
}

class MA = Object with M;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,39 @@ import augment 'augmented_expression_A01_t04_lib.dart';

void set augmented(String value) {}

String topLevelVariable = "Original";
final String topLevelVariable = "Original";

class C {
static String staticField = "Original";
String instanceField = "Original";
void set augmented(String value) {}
}

mixin M {
static String staticField = "Original";
String instanceField = "Original";
void set augmented(String value) {}
}

enum E {
e1;

static String staticField = "Original";
final String instanceField = "Original";
void set augmented(String value) {}
}

class A {}

extension Ext on A {
static String staticField = "Original";
static void set augmented(String value) {}
}

class MA = Object with M;

main() {
print(topLevelGetter);
print(topLevelVariable);
print(C);
print(M);
print(E);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,36 @@

import augment 'augmented_expression_A01_t05_lib.dart';

final bool augmented = false;
const augmented = false;

String get topLevelGetter => "Original:";

class C {
static String get staticGetter => "Original:";
String get instanceGetter => "Original:";
final bool augmented = false;
}

mixin M {
static String get staticGetter => "Original:";
String get instanceGetter => "Original:";
static final bool augmented = false;
}

enum E {
e1;

static String get staticGetter => "Original:";
String get instanceGetter => "Original:";
static final bool augmented = false;
}

class A {}

extension Ext on A {
static String get staticGetter => "Original:";
String get instanceGetter => "Original:";
static final bool augmented = false;
}

class MA = Object with M;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,36 @@ import augment 'augmented_expression_A01_t07_lib1.dart';
import augment 'augmented_expression_A01_t07_lib2.dart';
import '../../Utils/expect.dart';

String get augmented => "Getter augmented";
const augmented = "Const augmented, shouldn't be used";

String get topLevelGetter => "Original";

class C {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "C.augmented, shouldn't be invoked";
}

mixin M {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
static String get augmented => "M.augmented, shouldn't be invoked";
}

enum E {
e1;

static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "E.augmented, shouldn't be invoked";
}

class A {}

extension Ext on A {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
static String get augmented => "Ext.augmented, shouldn't be invoked";
}

class MA = Object with M;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,33 @@
import augment 'augmented_expression_A01_t08_lib.dart';
import '../../Utils/expect.dart';

String get augmented => "Getter augmented";
const augmented = "Const augmented, shouldn't be invoked";

String get topLevelGetter => "Original";

class C {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "C.augmented, shouldn't be invoked";
}

mixin M {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "M.augmented, shouldn't be invoked";
}

enum E {
e1;

static String get staticGetter => "Original";
String get instanceGetter => "Original";
String get augmented => "E.augmented, shouldn't be invoked";
}

class A {}
class A {
String get augmented => "A.augmented, shouldn't be invoked";
}

extension Ext on A {
static String get staticGetter => "Original";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,36 @@ class A {
String call() => "A($id).call";
}

String augmented() => "Wrong augmented() call!";
String augmented() => "Global function, shouldn't be invoked";

A get topLevelGetter => A("topLevelGetter");

class C {
static A get staticGetter => A("C.staticGetter");
A get instanceGetter => A("C.instanceGetter");
static String augmented() => "C.augmented(), shouldn't be invoked";
}

mixin M {
static A get staticGetter => A("M.staticGetter");
A get instanceGetter => A("M.instanceGetter");
static String augmented() => "M.augmented(), shouldn't be invoked";
}

enum E {
e1;

static A get staticGetter => A("E.staticGetter");
A get instanceGetter => A("E.instanceGetter");
static String augmented() => "E.augmented(), shouldn't be invoked";
}

class A {}

extension Ext on A {
static A get staticGetter => A("Ext.staticGetter");
A get instanceGetter => A("Ext.instanceGetter");
static String augmented() => "Ext.augmented(), shouldn't be invoked";
}

class MA = Object with M;
Expand Down
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 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 getters: Within an augmenting getter `augmented` invokes the
/// getter and evaluates to the return value. If augmenting a field with a
/// getter, this will invoke the implicit getter from the augmented field.
///
/// @description Checks that it is a compile-time error to declare a local
/// variable named `augmented` within an augmenting getter
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A01_t10_lib.dart';

class C {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
}

mixin M {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
}

enum E {
e1;

static String get staticGetter => "Original";
String get instanceGetter => "Original";
}

class A {}

extension Ext on A {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
}

class MA = Object with M;

main() {
print(topLevelGetter);
print(C);
print(M);
print(E);
print(A);
}

0 comments on commit 63a0343

Please sign in to comment.