Skip to content

Commit 41afe5c

Browse files
committed
[tests] Verify Call with return as function
1 parent cb6b669 commit 41afe5c

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

test/cppia/Client.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ class Client
224224
default:
225225
}
226226

227+
switch ReturnExpressions.testFuncReturn() {
228+
case Error(message):
229+
Common.status = 'Failed test for function value return stopping evaluation: ' + message;
230+
return;
231+
default:
232+
}
233+
227234
// regression test for #926
228235
var x:Dynamic = 3;
229236
x *= 5;

test/cppia/ReturnExpressions.hx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,20 @@ class ReturnExpressions {
2929
}
3030
return Error("Host method executed after return");
3131
}
32+
33+
@:analyzer(ignore)
34+
static function returnAsFunction() {
35+
// if return is not handled, there is no function to run so this will
36+
// give a null function exception
37+
(cast return : (Int) -> Void)(Common.incrementCount());
38+
}
39+
40+
public static function testFuncReturn() {
41+
Common.count = 0;
42+
returnAsFunction();
43+
if (Common.count == 0) {
44+
return Ok;
45+
}
46+
return Error("Host method executed after return");
47+
}
3248
}

0 commit comments

Comments
 (0)