File tree Expand file tree Collapse file tree 2 files changed +57
-1
lines changed
Expand file tree Collapse file tree 2 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,20 @@ class Client
189189 default :
190190 }
191191
192+ switch LocalFunctionExceptions .testObjMethodOnReturn () {
193+ case Error (message ):
194+ Common .status = ' Failed test for running object method on returned value: ' + message ;
195+ return ;
196+ default :
197+ }
198+
199+ switch LocalFunctionExceptions .testClassMethodOnReturn () {
200+ case Error (message ):
201+ Common .status = ' Failed test for running class method on returned value: ' + message ;
202+ return ;
203+ default :
204+ }
205+
192206 final extending = new ClientExtendedExtendedRoot ();
193207
194208 extending .addValue ();
Original file line number Diff line number Diff line change @@ -3,8 +3,12 @@ enum Status {
33 Error (message : String );
44}
55
6+ class DummyClass {
7+ public function run () {}
8+ }
9+
610class LocalFunctionExceptions {
7- static function staticFunction () {
11+ static function staticFunction (): Dynamic {
812 throw ' Thrown from static' ;
913 }
1014
@@ -65,4 +69,42 @@ class LocalFunctionExceptions {
6569
6670 return Error (" No exception caught" );
6771 }
72+
73+ public static function testObjMethodOnReturn (): Status {
74+ function localFunction () {
75+ (staticFunction () : Dynamic ).run ();
76+ throw ' Thrown from local' ;
77+ }
78+
79+ try {
80+ localFunction ();
81+ } catch (e : String ) {
82+ if (e == ' Thrown from static' ) {
83+ return Ok ;
84+ } else {
85+ return Error (" Incorrect exception caught from local function call: " + e );
86+ }
87+ }
88+
89+ return Error (" No exception caught" );
90+ }
91+
92+ public static function testClassMethodOnReturn (): Status {
93+ function localFunction () {
94+ (staticFunction () : DummyClass ).run ();
95+ throw ' Thrown from local' ;
96+ }
97+
98+ try {
99+ localFunction ();
100+ } catch (e : String ) {
101+ if (e == ' Thrown from static' ) {
102+ return Ok ;
103+ } else {
104+ return Error (" Incorrect exception caught from local function call: " + e );
105+ }
106+ }
107+
108+ return Error (" No exception caught" );
109+ }
68110}
You can’t perform that action at this time.
0 commit comments