Skip to content

Commit aa9422a

Browse files
committed
Add tests for import structure and effect
1 parent b62ccaa commit aa9422a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/main/java/org/skriptlang/reflect/java/elements/structures/StructImport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public static class EffImport extends Effect {
183183

184184
@Override
185185
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
186-
if (!getParser().isCurrentEvent(EffectCommandEvent.class)) {
186+
if (!getParser().isCurrentEvent(EffectCommandEvent.class) && !Skript.testing()) {
187187
Skript.error("The import effect can only be used in effect commands. " +
188188
"To use imports in scripts, use the section.");
189189
return false;

src/test/scripts/EffImport.sk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test "import from effect":
2+
import java.lang.Byte
3+
assert Byte.SIZE is set with "Failed to use import from effect"

src/test/scripts/StructImport.sk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import:
2+
java.lang.Math
3+
java.lang.Math as AliasForMath
4+
5+
test "import from structure available":
6+
assert Math.PI is set with "Failed to use import from structure"
7+
assert AliasForMath.PI is set with "Failed to use import alias from structure"
8+

0 commit comments

Comments
 (0)