-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(wip): Allow Expansions with generic parameters in Java
- Loading branch information
Showing
5 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ript/scriptingexample/tests/actual_test/java_native/expansions/GenericExpansionTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.openzen.zenscript.scriptingexample.tests.actual_test.java_native.expansions; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
import org.openzen.zenscript.scriptingexample.tests.helpers.ScriptBuilder; | ||
import org.openzen.zenscript.scriptingexample.tests.helpers.ZenCodeTest; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
class GenericExpansionTests extends ZenCodeTest { | ||
|
||
@Override | ||
public List<String> getRequiredStdLibModules() { | ||
return Collections.singletonList("stdlib"); | ||
} | ||
|
||
@Override | ||
public List<Class<?>> getRequiredClasses() { | ||
List<Class<?>> requiredClasses = super.getRequiredClasses(); | ||
requiredClasses.add(ExpandStringList.class); | ||
return requiredClasses; | ||
} | ||
|
||
@Test | ||
void works() { | ||
ScriptBuilder.create() | ||
.add("import stdlib.List;") | ||
.add("var list = ['one', 'two', 'three'] as List<string>;") | ||
.add("println(list.join(','));") | ||
.execute(this); | ||
logger.assertPrintOutputSize(1); | ||
logger.assertPrintOutput(0, "one,two,three"); | ||
} | ||
|
||
@ZenCodeType.Expansion(value = "stdlib.List<T>", typeParameters = "<T : string>") | ||
public static class ExpandStringList { | ||
|
||
|
||
@ZenCodeType.Method | ||
public static String join(List<String> list) { | ||
return String.join(",", list); | ||
} | ||
} | ||
} |