Skip to content

Commit f13f9a3

Browse files
author
Sergey G. Grekhov
committed
#495. Partial fix. Explicit extension member invocation tests for binary operations added
1 parent 655d6da commit f13f9a3

File tree

38 files changed

+1268
-10
lines changed

38 files changed

+1268
-10
lines changed

LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A07_t01.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,30 @@
1616
import "../../Utils/expect.dart";
1717

1818
class C {
19-
String id<T, Y extends num>(T t, Y val) => "C: t=" + t.toString() + ", i=$val";
19+
String id<T, Y extends num>(T t, Y val) =>
20+
"C: t=" + t.toString() + ", i=$val";
2021
}
2122

2223
extension Extension1 on C {
23-
String id<T, Y extends num>(T t, Y val) => "Extension1: t=" + t.toString() + ", i=$val";
24+
String id<T, Y extends num>(T t, Y val) =>
25+
"Extension1: t=" + t.toString() + ", i=$val";
2426
}
2527

2628
extension Extension2 on C {
27-
String id<T, Y extends num>(T t, Y val) => "Extension2: t=" + t.toString() + ", i=$val";
29+
String id<T, Y extends num>(T t, Y val) =>
30+
"Extension2: t=" + t.toString() + ", i=$val";
2831
}
2932

3033
main() {
3134
C c = new C();
32-
Expect.equals("Extension1: t=Lily was here, i=42", Extension1(c).id<String, int>("Lily was here", 42));
33-
Expect.equals("Extension1: t=Show must go on, i=3.14", Extension1(c).id<String, double>("Show must go on", 3.14));
34-
Expect.equals("Extension2: t=Lily was here, i=42", Extension2(c).id<String, int>("Lily was here", 42));
35-
Expect.equals("Extension2: t=Show must go on, i=3.14", Extension2(c).id<String, double>("Show must go on", 3.14));
36-
Expect.equals("C: t=Show must go on, i=3.14", c.id<String, double>("Show must go on", 3.14));
35+
Expect.equals("Extension1: t=Lily was here, i=42",
36+
Extension1(c).id<String, int>("Lily was here", 42));
37+
Expect.equals("Extension1: t=Show must go on, i=3.14",
38+
Extension1(c).id<String, double>("Show must go on", 3.14));
39+
Expect.equals("Extension2: t=Lily was here, i=42",
40+
Extension2(c).id<String, int>("Lily was here", 42));
41+
Expect.equals("Extension2: t=Show must go on, i=3.14",
42+
Extension2(c).id<String, double>("Show must go on", 3.14));
43+
Expect.equals("C: t=Show must go on, i=3.14",
44+
c.id<String, double>("Show must go on", 3.14));
3745
}

LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A07_t02.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
// SharedOptions=--enable-experiment=extension-methods
1616

1717
class C {
18-
String id2<T, Y extends num>(T t, Y val) => "C: t=" + t.toString() + ", i=$val";
18+
String id2<T, Y extends num>(T t, Y val) =>
19+
"C: t=" + t.toString() + ", i=$val";
1920
}
2021

2122
extension Extension1 on C {
22-
String id<T, Y extends num>(T t, Y val) => "Extension1: t=" + t.toString() + ", i=$val";
23+
String id<T, Y extends num>(T t, Y val) =>
24+
"Extension1: t=" + t.toString() + ", i=$val";
2325
}
2426

2527
main() {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* -X unary-
11+
* @description Check explicit extension member invocation in form of -X
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
import "../../Utils/expect.dart";
16+
17+
class C {
18+
String operator -() => "Lily was here";
19+
}
20+
21+
extension Extension1 on C {
22+
String operator -() => "Show must go on";
23+
}
24+
25+
extension Extension2 on C {
26+
String operator -() => "Let it be";
27+
}
28+
29+
main() {
30+
C c = new C();
31+
Expect.equals("Show must go on", -Extension1(c));
32+
Expect.equals("Let it be", -Extension2(c));
33+
Expect.equals("Lily was here", -c);
34+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* -X unary-
11+
* @description Check explicit extension member invocation in form of -X
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
16+
class C {
17+
String operator -() => "Lily was here";
18+
}
19+
20+
extension Extension1 on C {
21+
String operator ~() => "Show must go on";
22+
}
23+
24+
main() {
25+
C c = new C();
26+
-Extension1(c);
27+
//^^^^^^^^^^^
28+
// [analyzer] unspecified
29+
// [cfe] unspecified
30+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* ~X ~
11+
* @description Check explicit extension member invocation in form of ~X
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
import "../../Utils/expect.dart";
16+
17+
class C {
18+
String operator ~() => "Lily was here";
19+
}
20+
21+
extension Extension1 on C {
22+
String operator ~() => "Show must go on";
23+
}
24+
25+
extension Extension2 on C {
26+
String operator ~() => "Let it be";
27+
}
28+
29+
main() {
30+
C c = new C();
31+
Expect.equals("Show must go on", ~Extension1(c));
32+
Expect.equals("Let it be", ~Extension2(c));
33+
Expect.equals("Lily was here", ~c);
34+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* ~X unary~
11+
* @description Check explicit extension member invocation in form of ~X
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
16+
class C {
17+
String operator ~() => "Lily was here";
18+
}
19+
20+
extension Extension1 on C {
21+
String operator -() => "Show must go on";
22+
}
23+
24+
main() {
25+
C c = new C();
26+
~Extension1(c);
27+
//^^^^^^^^^^^
28+
// [analyzer] unspecified
29+
// [cfe] unspecified
30+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* X binop expr2 +, -, *, / , ~/, %, <, <=, >, >=, <<, >>, >>>, ^, |, &
11+
* @description Check explicit extension member invocation in form of X + expr2
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
import "../../Utils/expect.dart";
16+
17+
class C {
18+
String value;
19+
C(this.value);
20+
String operator +(C other) => this.value + "," + other.value;
21+
}
22+
23+
extension Extension1 on C {
24+
String operator +(C other) => "Show must go on," + other.value;
25+
}
26+
27+
extension Extension2 on C {
28+
String operator +(C other) => "Let it be," + other.value;
29+
}
30+
31+
main() {
32+
C c = new C("Lily was here");
33+
C other = new C("No woman no cry");
34+
Expect.equals("Show must go on,No woman no cry", Extension1(c) + other);
35+
Expect.equals("Let it be,No woman no cry", Extension2(c) + other);
36+
Expect.equals("Lily was here,No woman no cry", c + other);
37+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* X binop expr2 +, -, *, / , ~/, %, <, <=, >, >=, <<, >>, >>>, ^, |, &
11+
* @description Check explicit extension member invocation in form of X + expr2
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
16+
class C {
17+
String value;
18+
C(this.value);
19+
String operator +(C other) => this.value + "," + other.value;
20+
}
21+
22+
extension Extension1 on C {
23+
String operator -(C other) => "Show must go on," + other.value;
24+
}
25+
26+
main() {
27+
C c = new C("Lily was here");
28+
C other = new C("No woman no cry");
29+
Extension1(c) + other;
30+
// ^
31+
// [analyzer] unspecified
32+
// [cfe] unspecified
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* X binop expr2 +, -, *, / , ~/, %, <, <=, >, >=, <<, >>, >>>, ^, |, &
11+
* @description Check explicit extension member invocation in form of X - expr2
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
import "../../Utils/expect.dart";
16+
17+
class C {
18+
String value;
19+
C(this.value);
20+
String operator -(C other) => this.value + "," + other.value;
21+
}
22+
23+
extension Extension1 on C {
24+
String operator -(C other) => "Show must go on," + other.value;
25+
}
26+
27+
extension Extension2 on C {
28+
String operator -(C other) => "Let it be," + other.value;
29+
}
30+
31+
main() {
32+
C c = new C("Lily was here");
33+
C other = new C("No woman no cry");
34+
Expect.equals("Show must go on,No woman no cry", Extension1(c) - other);
35+
Expect.equals("Let it be,No woman no cry", Extension2(c) - other);
36+
Expect.equals("Lily was here,No woman no cry", c - other);
37+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* X binop expr2 +, -, *, / , ~/, %, <, <=, >, >=, <<, >>, >>>, ^, |, &
11+
* @description Check explicit extension member invocation in form of X - expr2
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
16+
class C {
17+
String value;
18+
C(this.value);
19+
String operator -(C other) => this.value + "," + other.value;
20+
}
21+
22+
extension Extension1 on C {
23+
String operator +(C other) => "Show must go on," + other.value;
24+
}
25+
26+
main() {
27+
C c = new C("Lily was here");
28+
C other = new C("No woman no cry");
29+
Extension1(c) - other;
30+
// ^
31+
// [analyzer] unspecified
32+
// [cfe] unspecified
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion A simple member invocation on a target expression X is an
8+
* expression of one of the forms:
9+
* Member invocation on target X Corresponding member name
10+
* X binop expr2 +, -, *, / , ~/, %, <, <=, >, >=, <<, >>, >>>, ^, |, &
11+
* @description Check explicit extension member invocation in form of X * expr2
12+
13+
*/
14+
// SharedOptions=--enable-experiment=extension-methods
15+
import "../../Utils/expect.dart";
16+
17+
class C {
18+
String value;
19+
C(this.value);
20+
String operator *(C other) => this.value + "," + other.value;
21+
}
22+
23+
extension Extension1 on C {
24+
String operator *(C other) => "Show must go on," + other.value;
25+
}
26+
27+
extension Extension2 on C {
28+
String operator *(C other) => "Let it be," + other.value;
29+
}
30+
31+
main() {
32+
C c = new C("Lily was here");
33+
C other = new C("No woman no cry");
34+
Expect.equals("Show must go on,No woman no cry", Extension1(c) * other);
35+
Expect.equals("Let it be,No woman no cry", Extension2(c) * other);
36+
Expect.equals("Lily was here,No woman no cry", c * other);
37+
}

0 commit comments

Comments
 (0)