Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow delay within the testing system #7095

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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::*}%"
TheLimeGlass marked this conversation as resolved.
Show resolved Hide resolved

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