lhartikk / ArnoldC

Arnold Schwarzenegger based programming language
lhartikk.github.io/ArnoldC/
Apache License 2.0
6.73k stars 290 forks source link

Tests fail on windows because of line separator #102

Open 22222 opened 9 years ago

22222 commented 9 years ago

The expected values for all of the tests use just line feeds ("\n") for line separators. But the line separators are added by the PrintStream class, and on Windows it will use a carriage return and line feed ("\r\n") as the line separator by default. This makes all tests with at least one line of expected output fail.

A solution I've been using is to explicitly set the system line.separator property to "\n" before creating the new PrintStream for the output:

diff --git a/src/test/scala/org/arnoldc/ByteCodeExecutor.scala b/src/test/scala/org/arnoldc/ByteCodeExecutor.scala
index ef9aebf..d6dc5f2 100644
--- a/src/test/scala/org/arnoldc/ByteCodeExecutor.scala
+++ b/src/test/scala/org/arnoldc/ByteCodeExecutor.scala
@@ -9,6 +9,7 @@ class ByteCodeExecutor extends ClassLoader {

     val outputRedirectionStream = new ByteArrayOutputStream()

+   System.setProperty("line.separator", "\n");
    System.setOut(new PrintStream(outputRedirectionStream))

     invokeMainMethod(bytecode, className)