Skip to content

Commit

Permalink
Fix broken static_extension_getter_setter_test.
Browse files Browse the repository at this point in the history
Change-Id: Ie8cfc07df8507862c1d534421a1bd9a60fac580c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116500
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
  • Loading branch information
lrhn authored and commit-bot@chromium.org committed Sep 11, 2019
1 parent cbdbb46 commit 4d5e15a
Showing 1 changed file with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// SharedOptions=--enable-experiment=extension-methods

// Tests interactions between getters and setters where one or both is defined
// Tests getters and setters where one or both is defined
// by an extension.

import "package:expect/expect.dart";
Expand All @@ -14,37 +14,27 @@ main() {
// v1: C get, C set
expectGet("C.v1", c.v1);
expectSet("C.v1=1", c.v1 = Result("1"));
// v2: C get, E1 set
// v2: C get, E1 get/set, C wins.
expectGet("C.v2", c.v2);
expectSet("E1.v2=2", c.v2 = Result("2"));
// v3: E1 get, C set
expectGet("E1.v3", c.v3);
expectSet("E1.v2=2", E1(c).v2 = Result("2"));
// v3: E1 get/set, C set, C wins.
expectGet("E1.v3", E1(c).v3);
expectSet("C.v3=3", c.v3 = Result("3"));
// v4: E1 get, E1 set
// v4: E1 get/set
expectGet("E1.v4", c.v4);
expectSet("E1.v4=4", c.v4 = Result("4"));
// v5: E1 get, E2 set
expectGet("E1.v5", c.v5);
expectSet("E2.v5=5", c.v5 = Result("5"));
// v5: E1 get, E2 set, neither more specific.
expectGet("E1.v5", E1(c).v5);
expectSet("E2.v5=5", E2(c).v5 = Result("5"));

expectSet("C.v1=C.v1+1", c.v1++);
expectSet("E1.v2=C.v2+1", c.v2++);
expectSet("C.v3=E1.v3+1", c.v3++);
expectSet("E1.v4=E1.v4+1", c.v4++);
expectSet("E2.v5=E1.v5+1", c.v5++);

expectSet("C.v1=C.v1+a", c.v1 += "a");
expectSet("C.v1=C.v1-b", c.v1 -= "b");
expectSet("E1.v4=E1.v4-b", c.v4 -= "b");

// Cascades work.
expectSet(
"E1.v4=E2.v4+[C.v1=[E1.v2=a]]",
c
..v2 = Result("a")
..v1 = Result("[$lastSetter]")
..v4 += Result("[$lastSetter]"));

// Override used by all accesses of read/write operations
// Explicit application used by all accesses of read/write operations
expectSet("E1.v1=E1.v1+1", E1(c).v1++);
expectSet("E1.v2=E1.v2+1", E1(c).v2++);
expectSet("E1.v3=E1.v3+1", E1(c).v3++);
Expand All @@ -56,6 +46,14 @@ main() {
expectSet("E1.v1=E1.v1+1", E1(c).v1 = E1(c).v1 + 1);
expectSet("E1.v2=E1.v2+1", E1(c).v2 = E1(c).v2 + 1);
expectSet("E1.v3=E1.v3+1", E1(c).v3 = E1(c).v3 + 1);

// Cascades work.
expectSet(
"E1.v4=E1.v4+[C.v1=C.v1-[C.v3=a]]",
c
..v3 = Result("a")
..v1 -= Result("[$lastSetter]")
..v4 += Result("[$lastSetter]"));
}

/// Expect the value of [result] to be the [expected] string
Expand Down Expand Up @@ -105,41 +103,41 @@ class C {
/// Declares [v4] getter and setter, and [v5] getter
/// which are supplemented by a setter from the [E2] extension.
extension E1 on C {
// Overlaps with C on both.
// Same basename as C getter and setter.
Result get v1 => Result("E1.v1");

void set v1(Result value) {
lastSetter = "E1.v1=$value";
}

// Overlaps with C on getter.
// Same basename as C getter.
Result get v2 => Result("E1.v2");

void set v2(Result value) {
lastSetter = "E1.v2=$value";
}

// Overlaps with C on setter.
// Same basename as C setter.
Result get v3 => Result("E1.v3");

void set v3(Result value) {
lastSetter = "E1.v3=$value";
}

// Overlaps with nothing.
// No other declarations with same basename.
Result get v4 => Result("E1.v4");

void set v4(Result value) {
lastSetter = "E1.v4=$value";
}

// Combines with E2 setter.
// Same basename as E2 setter.
Result get v5 => Result("E1.v5");
}

/// A different extension than [E1] on [C].
///
/// Declares [v5] setter.
/// Together with [E1], this defined both getter and setter.
extension E2 on C {
void set v5(Result value) {
lastSetter = "E2.v5=$value";
Expand Down

0 comments on commit 4d5e15a

Please sign in to comment.