Fixed literals with special characters
This commit is contained in:
parent
928912de68
commit
3498398452
2 changed files with 9 additions and 6 deletions
|
@ -125,7 +125,10 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
|||
public Collection<? extends CommandNode<S>> getRelevantNodes(final StringReader input) {
|
||||
if (literals.size() > 0) {
|
||||
final int cursor = input.getCursor();
|
||||
final String text = input.readUnquotedString();
|
||||
while (input.canRead() && input.peek() != ' ') {
|
||||
input.skip();
|
||||
}
|
||||
final String text = input.getString().substring(cursor, input.getCursor());
|
||||
input.setCursor(cursor);
|
||||
final LiteralCommandNode<S> literal = literals.get(text);
|
||||
if (literal != null) {
|
||||
|
|
|
@ -163,12 +163,12 @@ public class CommandDispatcherTest {
|
|||
subject.register(literal("foo").then(
|
||||
literal("a")
|
||||
).then(
|
||||
literal("b").executes(subCommand)
|
||||
literal("=").executes(subCommand)
|
||||
).then(
|
||||
literal("c")
|
||||
).executes(command));
|
||||
|
||||
assertThat(subject.execute("foo b", source), is(100));
|
||||
assertThat(subject.execute("foo =", source), is(100));
|
||||
verify(subCommand).run(any(CommandContext.class));
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class CommandDispatcherTest {
|
|||
when(modifier.apply(argThat(hasProperty("source", is(source))))).thenReturn(Lists.newArrayList(source1, source2));
|
||||
|
||||
subject.register(literal("actual").executes(command));
|
||||
subject.register(literal("redirected").redirect(subject.getRoot()));
|
||||
subject.register(literal("redirected").fork(subject.getRoot(), modifier));
|
||||
|
||||
final String input = "redirected actual";
|
||||
final ParseResults<Object> parse = subject.parse(input, source);
|
||||
|
@ -335,9 +335,9 @@ public class CommandDispatcherTest {
|
|||
subject.execute("foo$", source);
|
||||
fail();
|
||||
} catch (final CommandSyntaxException ex) {
|
||||
assertThat(ex.getType(), is(CommandDispatcher.ERROR_EXPECTED_ARGUMENT_SEPARATOR));
|
||||
assertThat(ex.getType(), is(CommandDispatcher.ERROR_UNKNOWN_COMMAND));
|
||||
assertThat(ex.getData(), is(Collections.emptyMap()));
|
||||
assertThat(ex.getCursor(), is(3));
|
||||
assertThat(ex.getCursor(), is(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue