Skip to content

Commit

Permalink
Disallow delay within the testing system (#7095)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLimeGlass authored Oct 1, 2024
1 parent 875a39b commit c8ccc5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/main/java/ch/njol/skript/test/runner/EffAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public class EffAssert extends Effect {
@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
if (isDelayed == Kleenean.TRUE && !TestMode.JUNIT && !TestMode.DEV_MODE) {
Skript.error("Assertions cannot be delayed");
return false;
}

String conditionString = parseResult.regexes.get(0).group();
errorMsg = (Expression<String>) exprs[0];
boolean canInit = true;
Expand Down
16 changes: 10 additions & 6 deletions src/test/skript/tests/syntaxes/expressions/ExprEntities.sk
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
test "entities in chunk":
spawn 10 sheep at spawn of world "world"
wait 1 tick
clear all entities
spawn 10 sheep at spawn of world "world":
add event-entity to {_sheep::*}
add 1 to {_count}
assert {_count} and size of entities within {_sheep::*} is 10 with "Did not count 10 on the entities within {_sheep::*}: %{_sheep::*}%"
assert size of all entities in chunk at spawn of world "world" >= 10 with "Size of all entities in spawn chunk is not > 10: %size of all entities in chunk at spawn of world "world"%"

loop all entities in chunk at spawn of world "world":
loop all sheep in chunk at spawn of world "world":
add loop-entity to {_e::*}
assert size of {_e::*} >= 10 with "Size of all entities in spawn chunk is not > 10 (iterating): %size of {_e::*}%"
assert size of {_e::*} >= 10 with "Size of all sheep in spawn chunk is not >= 10 (iterating): %size of {_e::*}%"

delete all entities in chunk at spawn of world "world"
assert size of all entities in chunk at spawn of world "world" = 0 with "Size of all entities in spawn chunk != 0: %size of all entities in chunk at spawn of world "world"%"
clear entities within {_e::*}
assert entities within {_e::*} where [entity input is valid] is not set with "Not all the sheep were cleared"
clear all entities

0 comments on commit c8ccc5b

Please sign in to comment.