Skip to content

Commit

Permalink
add addional test case for function listener and fix syntax issue
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed May 20, 2024
1 parent f6d9716 commit 715aae5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/general/FunctionListener.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{
function myError() {
throw "Upsi dupsi!"
}
function logAndFail(name,value) {
request.testFunctionListenerEcho[name]=value;
throw "Upsi dupsi!"
}

function run( testResults , testBox ) {
describe( "test suite for function listeners", function() {
Expand Down Expand Up @@ -118,7 +122,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{
onSuccess:function(result) {
thread.success=result;
}
onFail:function(result,error) {
,onFail:function(result,error) {
thread.fail=error.message;
}
};
Expand Down Expand Up @@ -148,6 +152,20 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{
expect(cfthread[threadName2].fail).toBe("Upsi dupsi!");
});

it(title="async execution without a listener", body=function() {
// passing null
var threadName1=logAndFail("testNull","Peter Lustig"):nullValue();
// passing empty struct
var threadName1=logAndFail("testStruct","Ruedi Zraggen"):{};

// wait for the thread to finsish
threadJoin(threadName1);
threadJoin(threadName2);

expect(request.testFunctionListenerEcho[name].testNull).toBe("Peter Lustig");
expect(request.testFunctionListenerEcho[name].testStruct).toBe("Ruedi Zraggen");
});

it(title="similar syntax that could conflict: switch", body=function() {
// switch allow this strange syntax, so Lucee does not allow the function listener operation within this context
savecontent variable="local.result" {
Expand Down

0 comments on commit 715aae5

Please sign in to comment.