-
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
More `noSuchMethod` tests added. Part 2
- Loading branch information
Showing
13 changed files
with
711 additions
and
37 deletions.
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
/// @description Checks that it is possible to define a `noSuchMethod` which | ||
/// is a correct override of `noSuchMethod` in `Object`. | ||
/// @author [email protected] | ||
/// @issue 53640 | ||
import "../../../../Utils/expect.dart"; | ||
|
||
|
@@ -50,6 +51,68 @@ class C5 { | |
int noSuchMethod(Invocation i) => 5; | ||
} | ||
|
||
mixin M1 { | ||
int m(); | ||
void noSuchMethod(Invocation i) {} | ||
} | ||
|
||
mixin M2 { | ||
int m(); | ||
Object? noSuchMethod(Invocation i) => 2; | ||
} | ||
|
||
mixin M3 { | ||
int m(); | ||
Null noSuchMethod(Invocation i) => null; | ||
} | ||
|
||
mixin M4 { | ||
int m(); | ||
Never noSuchMethod(Invocation i) => throw 42; | ||
} | ||
|
||
mixin M5 { | ||
int m(); | ||
int noSuchMethod(Invocation i) => 5; | ||
} | ||
|
||
class MA1 = Object with M1; | ||
class MA2 = Object with M2; | ||
class MA3 = Object with M3; | ||
class MA4 = Object with M4; | ||
class MA5 = Object with M5; | ||
|
||
enum E1 { | ||
e1, e2; | ||
int m(); | ||
void noSuchMethod(Invocation i) {} | ||
} | ||
|
||
enum E2 { | ||
e1, e2; | ||
int m(); | ||
Object? noSuchMethod(Invocation i) => 2; | ||
} | ||
|
||
enum E3 { | ||
e1, e2; | ||
int m(); | ||
Null noSuchMethod(Invocation i) => null; | ||
} | ||
|
||
enum E4 { | ||
e1, e2; | ||
int m(); | ||
Never noSuchMethod(Invocation i) => throw 42; | ||
} | ||
|
||
enum E5 { | ||
e1, e2; | ||
int m(); | ||
int noSuchMethod(Invocation i) => 5; | ||
} | ||
|
||
|
||
main() { | ||
Expect.throws(() { | ||
C1().m(); | ||
|
@@ -62,4 +125,28 @@ main() { | |
C4().m(); | ||
}); | ||
Expect.equals(5, C5().m()); | ||
|
||
Expect.throws(() { | ||
MA1().m(); | ||
}); | ||
Expect.equals(2, MA2().m()); | ||
Expect.throws(() { | ||
MA3().m(); | ||
}); | ||
Expect.throws(() { | ||
MA4().m(); | ||
}); | ||
Expect.equals(5, MA5().m()); | ||
|
||
Expect.throws(() { | ||
E1.e1.m(); | ||
}); | ||
Expect.equals(2, E2.e1.m()); | ||
Expect.throws(() { | ||
E3.e1.m(); | ||
}); | ||
Expect.throws(() { | ||
E4.e1.m(); | ||
}); | ||
Expect.equals(5, E5.e1.m()); | ||
} |
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
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
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 |
---|---|---|
|
@@ -22,16 +22,36 @@ | |
/// @description Checks that it is possible to define a `noSuchMethod` which | ||
/// is a correct override of `noSuchMethod` in `Object`. | ||
/// @author [email protected] | ||
/// @issue 53640 | ||
import "../../../../Utils/expect.dart"; | ||
|
||
class C1 { | ||
class C { | ||
int m(); | ||
dynamic noSuchMethod(covariant Object o) => o; | ||
} | ||
|
||
mixin M { | ||
int m(); | ||
dynamic noSuchMethod(covariant Object o) => o; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
enum E { | ||
e1, e2; | ||
int m(); | ||
dynamic noSuchMethod(covariant Object o) => o; | ||
} | ||
|
||
main() { | ||
Expect.throws(() { | ||
C1().m(); | ||
C().m(); | ||
}); | ||
Expect.throws(() { | ||
print(MA().m()); | ||
}); | ||
Expect.throws(() { | ||
E.e1.m(); | ||
}); | ||
} |
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
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
Oops, something went wrong.