Skip to content

Commit

Permalink
#5758 Allow extra whitespaces for magic commands. (#5773)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalgce authored and scottdraves committed Aug 2, 2017
1 parent c6c92da commit 0bfc958
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static MagicCommandFinder find(Code code, Map<String, MagicCommandFunctio
List<MagicCommandItemWithResult> errors = new ArrayList<>();
LinkedHashMap<String, MagicCommandFunctionality> functionalityToRun = new LinkedHashMap<>();
code.getCommands().forEach(command -> {
command = command.replaceAll("\\s+"," ");
Optional<MagicCommandFunctionality> functionality = findFunctionality(commands, command);
if (functionality.isPresent()) {
functionalityToRun.put(command, functionality.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ public void showClasspathShouldNotContainDuplication() throws Exception {
assertThat(classpath(result)).isEqualTo(CLASSPATH_TO_JAR);
}

@Test
public void allowExtraWhitespaces() {
MagicCommandResult result = sut
.process(new Code("%classpath add jar " + CLASSPATH_TO_JAR), new Message(), 1);

assertThat(classpath(result)).isEqualTo("Added jar: [foo.jar]\n");
}

private String classpath(MagicCommandResult result) {
return result.getItems().get(0).getResult().get().getContent().get("text").toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ public void removeImport() throws Exception {
assertThat(kernel.getImports().getImportPaths()).doesNotContain(new ImportPath("com.twosigma.beakerx.widgets.integers.IntSlider"));
}

@Test
public void allowExtraWhitespaces() {
MagicCommandResult result = sut
.process(new Code("%import com.twosigma.beakerx.widgets.integers.IntSlider"), new Message(), 1);

assertThat(kernel.getImports().getImportPaths()).contains(new ImportPath("com.twosigma.beakerx.widgets.integers.IntSlider"));
}

}

0 comments on commit 0bfc958

Please sign in to comment.