Skip to content

Commit f4f0ebc

Browse files
committed
Add additional function signature test
1 parent a51dd36 commit f4f0ebc

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/test/java/stanhebben/zenscript/tests/TestFunctionTypesInSignatures.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package stanhebben.zenscript.tests;
22

3-
import com.google.gson.internal.*;
4-
import org.junit.jupiter.api.BeforeAll;
5-
import org.junit.jupiter.api.BeforeEach;
6-
import org.junit.jupiter.api.Test;
7-
import stanhebben.zenscript.TestHelper;
3+
import org.junit.jupiter.api.*;
4+
import stanhebben.zenscript.*;
85

96
import java.util.*;
107

@@ -45,4 +42,17 @@ public void TestFunctionExpressionInClassSignature() {
4542
TestHelper.run(joiner.toString());
4643
assertMany("inside fun: abc");
4744
}
45+
46+
@Test
47+
public void TestFuncSupplier() {
48+
final StringJoiner joiner = new StringJoiner("\n");
49+
joiner.add("global funcCreator as function(int)function()string = function(i as int) as function() string {");
50+
joiner.add(" return function() as string {return 'Hello, Nr. ' ~ i;};");
51+
joiner.add("};");
52+
joiner.add("print(funcCreator(10)());");
53+
joiner.add("print(funcCreator(42)());");
54+
55+
TestHelper.run(joiner.toString());
56+
assertMany("Hello, Nr. 10", "Hello, Nr. 42");
57+
}
4858
}

0 commit comments

Comments
 (0)