You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ScriptingExample/src/test/java/org/openzen/zenscript/scriptingexample/tests/actual_test/arrays/ArrayCreationTests.java
+70Lines changed: 70 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,76 @@ public List<Class<?>> getRequiredClasses() {
20
20
returnrequiredClasses;
21
21
}
22
22
23
+
@Test
24
+
publicvoidbasic() {
25
+
ScriptBuilder.create()
26
+
.add("var result = [1, 2, 3];")
27
+
.add("println(result[0]);")
28
+
.add("println(result.length);")
29
+
.execute(this);
30
+
31
+
logger.assertPrintOutputSize(2);
32
+
logger.assertPrintOutput(0, "1");
33
+
logger.assertPrintOutput(1, "3");
34
+
}
35
+
36
+
@Test
37
+
publicvoidsized() {
38
+
ScriptBuilder.create()
39
+
.add("var result = new int[](1);")
40
+
.add("println(result[0]);")
41
+
.execute(this);
42
+
43
+
logger.assertPrintOutputSize(1);
44
+
logger.assertPrintOutput(0, "0");
45
+
}
46
+
47
+
@Test
48
+
publicvoidsizedWithDefaultValue() {
49
+
ScriptBuilder.create()
50
+
.add("var x = new int[](10, 8);")
51
+
.add("println(x[5]);")
52
+
.add("println(x.length);")
53
+
.execute(this);
54
+
55
+
logger.assertPrintOutputSize(2);
56
+
logger.assertPrintOutput(0, "8");
57
+
logger.assertPrintOutput(1, "10");
58
+
}
59
+
60
+
@Test
61
+
publicvoidmultiDimSized() {
62
+
ScriptBuilder.create()
63
+
.add("var x = new int[,](10, 10);")
64
+
.add("println(x[5, 0]);")
65
+
.execute(this);
66
+
67
+
logger.assertPrintOutputSize(1);
68
+
logger.assertPrintOutput(0, "0");
69
+
}
70
+
71
+
@Test
72
+
publicvoidmultiDimSizedWithDefault() {
73
+
ScriptBuilder.create()
74
+
.add("var x = new int[,](10, 10, 7);")
75
+
.add("println(x[5, 0]);")
76
+
.execute(this);
77
+
78
+
logger.assertPrintOutputSize(1);
79
+
logger.assertPrintOutput(0, "7");
80
+
}
81
+
82
+
@Test
83
+
publicvoidcallback() {
84
+
ScriptBuilder.create()
85
+
.add("var result = new int[](10, (index as usize) => 4);")
0 commit comments