mirror of https://github.com/Minestom/Minestom.git
Move test
This commit is contained in:
parent
8b74a7f1b8
commit
f6596926f6
|
@ -2,9 +2,12 @@ package net.minestom.server.command;
|
||||||
|
|
||||||
import net.minestom.server.command.builder.Command;
|
import net.minestom.server.command.builder.Command;
|
||||||
import net.minestom.server.command.builder.CommandContext;
|
import net.minestom.server.command.builder.CommandContext;
|
||||||
|
import net.minestom.server.command.builder.arguments.ArgumentType;
|
||||||
import net.minestom.server.command.builder.condition.CommandCondition;
|
import net.minestom.server.command.builder.condition.CommandCondition;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import static net.minestom.server.command.builder.arguments.ArgumentType.Literal;
|
import static net.minestom.server.command.builder.arguments.ArgumentType.Literal;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
@ -81,6 +84,24 @@ public class GraphConversionExecutorTest {
|
||||||
assertFalse(condition.canUse(null, null));
|
assertFalse(condition.canUse(null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void issue1326() {
|
||||||
|
final AtomicBoolean b = new AtomicBoolean(true);
|
||||||
|
var cmd = new Command("tp") {{
|
||||||
|
addConditionalSyntax((s, c) -> b.getAndSet(false), null, ArgumentType.Entity("target"),
|
||||||
|
ArgumentType.Double("x"), ArgumentType.Double("y"), ArgumentType.Double("z"));
|
||||||
|
}};
|
||||||
|
var graph = Graph.fromCommand(cmd);
|
||||||
|
final Graph.Node target = graph.root().next().get(0);
|
||||||
|
final Graph.Execution execution = target.execution();
|
||||||
|
assertNotNull(execution);
|
||||||
|
final CommandCondition condition = execution.condition();
|
||||||
|
assertNotNull(condition);
|
||||||
|
assertTrue(condition.canUse(null, null));
|
||||||
|
assertFalse(b.get(), "Condition wasn't executed.");
|
||||||
|
}
|
||||||
|
|
||||||
private static void dummyExecutor(CommandSender sender, CommandContext context) {
|
private static void dummyExecutor(CommandSender sender, CommandContext context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package net.minestom.server.command;
|
||||||
|
|
||||||
import net.minestom.server.command.builder.Command;
|
import net.minestom.server.command.builder.Command;
|
||||||
import net.minestom.server.command.builder.CommandContext;
|
import net.minestom.server.command.builder.CommandContext;
|
||||||
import net.minestom.server.command.builder.arguments.ArgumentType;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static net.minestom.server.command.builder.arguments.ArgumentType.Enum;
|
import static net.minestom.server.command.builder.arguments.ArgumentType.Enum;
|
||||||
|
@ -117,24 +115,6 @@ public class GraphConversionTest {
|
||||||
assertEqualsGraph(graph, main);
|
assertEqualsGraph(graph, main);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
//TODO See disable reason
|
|
||||||
@Disabled("Graphs' execution cannot be compared properly which makes this test pass when it shouldn't.")
|
|
||||||
public void issue1326() {
|
|
||||||
var cmd = new Command("tp") {{
|
|
||||||
addConditionalSyntax((s, c) -> s instanceof ConsoleSender, null, ArgumentType.Entity("target"),
|
|
||||||
ArgumentType.Double("x"), ArgumentType.Double("y"), ArgumentType.Double("z"));
|
|
||||||
}};
|
|
||||||
var graph = Graph.builder(ArgumentType.Literal("tp"))
|
|
||||||
.append(ArgumentType.Entity("target"),
|
|
||||||
new GraphImpl.ExecutionImpl(sender -> sender instanceof ConsoleSender,
|
|
||||||
null, null, null, null), b ->
|
|
||||||
b.append(ArgumentType.Double("x"), b1 ->
|
|
||||||
b1.append(ArgumentType.Double("y"), b2 ->
|
|
||||||
b2.append(ArgumentType.Double("z"))))).build();
|
|
||||||
assertEqualsGraph(graph, cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void assertEqualsGraph(Graph expected, Command command) {
|
private static void assertEqualsGraph(Graph expected, Command command) {
|
||||||
final Graph actual = Graph.fromCommand(command);
|
final Graph actual = Graph.fromCommand(command);
|
||||||
assertTrue(expected.compare(actual, Graph.Comparator.TREE), () -> {
|
assertTrue(expected.compare(actual, Graph.Comparator.TREE), () -> {
|
||||||
|
|
Loading…
Reference in New Issue