Skip to content

Commit

Permalink
Add additional function signature test
Browse files Browse the repository at this point in the history
  • Loading branch information
kindlich committed Dec 15, 2020
1 parent a51dd36 commit f4f0ebc
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package stanhebben.zenscript.tests;

import com.google.gson.internal.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import stanhebben.zenscript.TestHelper;
import org.junit.jupiter.api.*;
import stanhebben.zenscript.*;

import java.util.*;

Expand Down Expand Up @@ -45,4 +42,17 @@ public void TestFunctionExpressionInClassSignature() {
TestHelper.run(joiner.toString());
assertMany("inside fun: abc");
}

@Test
public void TestFuncSupplier() {
final StringJoiner joiner = new StringJoiner("\n");
joiner.add("global funcCreator as function(int)function()string = function(i as int) as function() string {");
joiner.add(" return function() as string {return 'Hello, Nr. ' ~ i;};");
joiner.add("};");
joiner.add("print(funcCreator(10)());");
joiner.add("print(funcCreator(42)());");

TestHelper.run(joiner.toString());
assertMany("Hello, Nr. 10", "Hello, Nr. 42");
}
}

0 comments on commit f4f0ebc

Please sign in to comment.