-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add `noSuchMethod` tests. Part 4 (dynamic semantics)
- Loading branch information
Showing
21 changed files
with
2,249 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,6 @@ enum E5 { | |
int noSuchMethod(Invocation i) => 5; | ||
} | ||
|
||
|
||
main() { | ||
Expect.throws(() { | ||
C1().m(); | ||
|
76 changes: 76 additions & 0 deletions
76
Language/Classes/Instance_Methods/Method_noSuchMethod/dynamic_A01_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) 2023, 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 For the dynamic semantics, assume that a class C has an | ||
/// implicitly induced noSuchMethod forwarder named m, with formal type | ||
/// parameters X1, . . . , Xr, positional formal parameters a1, . . . , ak (some | ||
/// of which may be optional when n = 0), and named formal parameters with names | ||
/// x1, . . . , xn | ||
/// | ||
/// The execution of the body of m creates an instance im of the predefined im | ||
/// class Invocation such that: | ||
/// • im.isMethod evaluates to true iff m is a method. | ||
/// | ||
/// @description Checks that `im.isMethod` evaluates to `true` iff `m` is a | ||
/// method | ||
/// @author [email protected] | ||
import "../../../../Utils/expect.dart"; | ||
|
||
bool log = false; | ||
|
||
mixin class A { | ||
bool m(); | ||
bool get g; | ||
void set s(bool i); | ||
|
||
dynamic noSuchMethod(Invocation i) { | ||
log = i.isMethod; | ||
return i.isMethod; | ||
} | ||
} | ||
|
||
class C1 extends A {} | ||
|
||
class C2 with A {} | ||
|
||
mixin M on A {} | ||
|
||
class MA = A with M; | ||
|
||
enum E with A { | ||
e1, e2; | ||
} | ||
|
||
main() { | ||
Expect.isTrue(A().m()); | ||
Expect.isFalse(A().g); | ||
A().s = true; | ||
Expect.isFalse(log); | ||
Expect.isTrue(A().m is bool Function()); // tear-off, no `noSuchMethod` invoked | ||
|
||
Expect.isTrue(C1().m()); | ||
Expect.isFalse(C1().g); | ||
C1().s = true; | ||
Expect.isFalse(log); | ||
Expect.isTrue(C1().m is bool Function()); | ||
|
||
Expect.isTrue(C2().m()); | ||
Expect.isFalse(C2().g); | ||
C2().s = true; | ||
Expect.isFalse(log); | ||
Expect.isTrue(C2().m is bool Function()); | ||
|
||
Expect.isTrue(MA().m()); | ||
Expect.isFalse(MA().g); | ||
MA().s = true; | ||
Expect.isFalse(log); | ||
Expect.isTrue(MA().m is bool Function()); | ||
|
||
Expect.isTrue(E.e1.m()); | ||
Expect.isFalse(E.e1.g); | ||
E.e1.s = true; | ||
Expect.isFalse(log); | ||
Expect.isTrue(E.e1.m is bool Function()); | ||
} |
72 changes: 72 additions & 0 deletions
72
Language/Classes/Instance_Methods/Method_noSuchMethod/dynamic_A02_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2023, 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 For the dynamic semantics, assume that a class C has an | ||
/// implicitly induced noSuchMethod forwarder named m, with formal type | ||
/// parameters X1, . . . , Xr, positional formal parameters a1, . . . , ak (some | ||
/// of which may be optional when n = 0), and named formal parameters with names | ||
/// x1, . . . , xn | ||
/// | ||
/// The execution of the body of m creates an instance im of the predefined im | ||
/// class Invocation such that: | ||
/// ... | ||
/// • im.isGetter evaluates to true iff m is a getter. | ||
/// | ||
/// @description Checks that `im.isGetter` evaluates to `true` iff `m` is a | ||
/// getter | ||
/// @author [email protected] | ||
import "../../../../Utils/expect.dart"; | ||
|
||
bool log = false; | ||
|
||
mixin class A { | ||
bool m(); | ||
bool get g; | ||
void set s(bool i); | ||
|
||
dynamic noSuchMethod(Invocation i) { | ||
log = i.isGetter; | ||
return i.isGetter; | ||
} | ||
} | ||
|
||
class C1 extends A {} | ||
|
||
class C2 with A {} | ||
|
||
mixin M on A {} | ||
|
||
class MA = A with M; | ||
|
||
enum E with A { | ||
e1, e2; | ||
} | ||
|
||
main() { | ||
Expect.isFalse(A().m()); | ||
Expect.isTrue(A().g); | ||
A().s = true; | ||
Expect.isFalse(log); | ||
|
||
Expect.isFalse(C1().m()); | ||
Expect.isTrue(C1().g); | ||
C1().s = true; | ||
Expect.isFalse(log); | ||
|
||
Expect.isFalse(C2().m()); | ||
Expect.isTrue(C2().g); | ||
C2().s = true; | ||
Expect.isFalse(log); | ||
|
||
Expect.isFalse(MA().m()); | ||
Expect.isTrue(MA().g); | ||
MA().s = true; | ||
Expect.isFalse(log); | ||
|
||
Expect.isFalse(E.e1.m()); | ||
Expect.isTrue(E.e1.g); | ||
E.e1.s = true; | ||
Expect.isFalse(log); | ||
} |
72 changes: 72 additions & 0 deletions
72
Language/Classes/Instance_Methods/Method_noSuchMethod/dynamic_A03_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2023, 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 For the dynamic semantics, assume that a class C has an | ||
/// implicitly induced noSuchMethod forwarder named m, with formal type | ||
/// parameters X1, . . . , Xr, positional formal parameters a1, . . . , ak (some | ||
/// of which may be optional when n = 0), and named formal parameters with names | ||
/// x1, . . . , xn | ||
/// | ||
/// The execution of the body of m creates an instance im of the predefined im | ||
/// class Invocation such that: | ||
/// ... | ||
/// • im.isSetter evaluates to true iff m is a setter | ||
/// | ||
/// @description Checks that `im.isSetter` evaluates to `true` iff `m` is a | ||
/// setter | ||
/// @author [email protected] | ||
import "../../../../Utils/expect.dart"; | ||
|
||
bool log = false; | ||
|
||
mixin class A { | ||
bool m(); | ||
bool get g; | ||
void set s(bool i); | ||
|
||
dynamic noSuchMethod(Invocation i) { | ||
log = i.isSetter; | ||
return i.isSetter; | ||
} | ||
} | ||
|
||
class C1 extends A {} | ||
|
||
class C2 with A {} | ||
|
||
mixin M on A {} | ||
|
||
class MA = A with M; | ||
|
||
enum E with A { | ||
e1, e2; | ||
} | ||
|
||
main() { | ||
Expect.isFalse(A().m()); | ||
Expect.isFalse(A().g); | ||
A().s = true; | ||
Expect.isTrue(log); | ||
|
||
Expect.isFalse(C1().m()); | ||
Expect.isFalse(C1().g); | ||
C1().s = true; | ||
Expect.isTrue(log); | ||
|
||
Expect.isFalse(C2().m()); | ||
Expect.isFalse(C2().g); | ||
C2().s = true; | ||
Expect.isTrue(log); | ||
|
||
Expect.isFalse(MA().m()); | ||
Expect.isFalse(MA().g); | ||
MA().s = true; | ||
Expect.isTrue(log); | ||
|
||
Expect.isFalse(E.e1.m()); | ||
Expect.isFalse(E.e1.g); | ||
E.e1.s = true; | ||
Expect.isTrue(log); | ||
} |
71 changes: 71 additions & 0 deletions
71
Language/Classes/Instance_Methods/Method_noSuchMethod/dynamic_A04_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) 2023, 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 For the dynamic semantics, assume that a class C has an | ||
/// implicitly induced noSuchMethod forwarder named m, with formal type | ||
/// parameters X1, . . . , Xr, positional formal parameters a1, . . . , ak (some | ||
/// of which may be optional when n = 0), and named formal parameters with names | ||
/// x1, . . . , xn | ||
/// | ||
/// The execution of the body of m creates an instance im of the predefined im | ||
/// class Invocation such that: | ||
/// ... | ||
/// • im.memberName evaluates to the symbol m. | ||
/// | ||
/// @description Checks that `im.memberName` evaluates to the symbol `m`. | ||
/// @author [email protected] | ||
import "../../../../Utils/expect.dart"; | ||
|
||
late Symbol log; | ||
|
||
mixin class A { | ||
Symbol m(); | ||
Symbol get g; | ||
void set s(String s); | ||
|
||
dynamic noSuchMethod(Invocation i) { | ||
log = i.memberName; | ||
return i.memberName; | ||
} | ||
} | ||
|
||
class C1 extends A {} | ||
|
||
class C2 with A {} | ||
|
||
mixin M on A {} | ||
|
||
class MA = A with M; | ||
|
||
enum E with A { | ||
e1, e2; | ||
} | ||
|
||
main() { | ||
Expect.equals(#m, A().m()); | ||
Expect.equals(#g, A().g); | ||
A().s = ""; | ||
Expect.equals(Symbol("s="), log); | ||
|
||
Expect.equals(#m, C1().m()); | ||
Expect.equals(#g, C1().g); | ||
C1().s = ""; | ||
Expect.equals(Symbol("s="), log); | ||
|
||
Expect.equals(#m, C2().m()); | ||
Expect.equals(#g, C2().g); | ||
C2().s = ""; | ||
Expect.equals(Symbol("s="), log); | ||
|
||
Expect.equals(#m, MA().m()); | ||
Expect.equals(#g, MA().g); | ||
MA().s = ""; | ||
Expect.equals(Symbol("s="), log); | ||
|
||
Expect.equals(#m, E.e1.m()); | ||
Expect.equals(#g, E.e2.g); | ||
E.e1.s = ""; | ||
Expect.equals(Symbol("s="), log); | ||
} |
Oops, something went wrong.