Skip to content

Commit ae84534

Browse files
committed
broken test for wildcard casting
1 parent fdcbc96 commit ae84534

File tree

1 file changed

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

1 file changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.openzen.zenscript.scriptingexample.tests.actual_test.generics;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.openzen.zencode.java.ZenCodeType;
5+
import org.openzen.zenscript.scriptingexample.tests.helpers.ScriptBuilder;
6+
import org.openzen.zenscript.scriptingexample.tests.helpers.ZenCodeTest;
7+
8+
import java.util.List;
9+
10+
public class WildcardCastingTest extends ZenCodeTest {
11+
@Test
12+
void testPrinter() {
13+
ScriptBuilder.create()
14+
.add("import test_module.Generator;")
15+
.add("var generator = new Generator();")
16+
.add("var stuff = generator.generate();")
17+
.add("generator.print<string>(stuff);")
18+
.execute(this);
19+
}
20+
21+
@Override
22+
public List<Class<?>> getRequiredClasses() {
23+
List<Class<?>> requiredClasses = super.getRequiredClasses();
24+
requiredClasses.add(Generator.class);
25+
requiredClasses.add(Singleton.class);
26+
return requiredClasses;
27+
}
28+
29+
@ZenCodeType.Name("test_module.Generator")
30+
public static class Generator {
31+
@ZenCodeType.Constructor
32+
public Generator() {}
33+
34+
@ZenCodeType.Method
35+
public Singleton<?> generate() {
36+
return new Singleton<>("Hello, World!");
37+
}
38+
39+
@ZenCodeType.Method
40+
public <T> void print(Singleton<T> stuff) {
41+
System.out.println(stuff.value);
42+
}
43+
}
44+
45+
@ZenCodeType.Name("test_module.Singleton")
46+
public static class Singleton<T> {
47+
public final T value;
48+
49+
public Singleton(T value) {
50+
this.value = value;
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)