Skip to content

Commit 1cc9c7b

Browse files
committed
Add missing tests
1 parent 51b9f83 commit 1cc9c7b

File tree

1 file changed

+24
-0
lines changed
  • ScriptingExample/src/test/java/org/openzen/zenscript/scriptingexample/tests/actual_test/arrays

1 file changed

+24
-0
lines changed

ScriptingExample/src/test/java/org/openzen/zenscript/scriptingexample/tests/actual_test/arrays/ArrayCreationTests.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,30 @@ public void callback() {
9090
logger.assertPrintOutput(0, "4");
9191
}
9292

93+
@Test
94+
public void projection() {
95+
ScriptBuilder.create()
96+
.add("var x = [9, 8, 7] as int[];")
97+
.add("var y = new int[]<int>(x, (xVal => 10 * xVal) as function(xVal as int) as int);")
98+
.add("println(y[0]);")
99+
.execute(this);
100+
101+
logger.assertPrintOutputSize(1);
102+
logger.assertPrintOutput(0, "90");
103+
}
104+
105+
@Test
106+
public void projectionWithIndex() {
107+
ScriptBuilder.create()
108+
.add("var x = [9, 8, 7] as int[];")
109+
.add("var y = new int[]<int>(x, ((index, xVal) => 10 * xVal) as function(index as usize, xVal as int) as int);")
110+
.add("println(y[0]);")
111+
.execute(this);
112+
113+
logger.assertPrintOutputSize(1);
114+
logger.assertPrintOutput(0, "90");
115+
}
116+
93117
@Test
94118
public void varargCreationShouldUseProperType() {
95119
ScriptBuilder.create()

0 commit comments

Comments
 (0)