Skip to content

Commit

Permalink
enhancement: add newline when writing strings to output stream
Browse files Browse the repository at this point in the history
  • Loading branch information
madmike200590 committed Sep 28, 2024
1 parent be6854e commit ec18c5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ private ActionResultTerm<ConstantTerm<String>> outputStreamWriteAction(List<Term
return Terms.actionError("Second input term must be a string constant!");
}
String str = ((ConstantTerm<String>) input.get(1)).getObject();
// TODO this needs some built-in conversion function
byte[] data = str.getBytes();
byte[] data = (str + "\n").getBytes();
OutputStream dst = dstHandle.getStream();
try {
dst.write(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void helloWorld() {
Alpha alpha = alphaFactory.buildInstance(new SystemConfig());
InputProgram program = alpha.readProgramString(HELLO_WORLD);
alpha.solve(program);
assertEquals("Hello World!", alphaFactory.getActionImplementationMock().getStdoutContent());
assertEquals("Hello World!\n", alphaFactory.getActionImplementationMock().getStdoutContent());
}

@Test
Expand Down Expand Up @@ -100,7 +100,7 @@ public void writeToFile() {
return funcTerm.getTerms().get(0) instanceof ConstantTerm<?> && ((ConstantTerm<String>) funcTerm.getTerms().get(0)).getObject().equals("ok");
})
).size());
assertEquals("Foo bar!", dummyFileContent.toString());
assertEquals("Foo bar!\n", dummyFileContent.toString());
}

}

0 comments on commit ec18c5e

Please sign in to comment.