Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Problem with EOL in tests for Printers is fixed

  • Loading branch information...
commit 06bae51b0767e5bfcc7968448c60659523dd4370 1 parent 695b9e1
@VladimirNik VladimirNik authored
View
12 src/reflect/scala/reflect/internal/Printers.scala
@@ -735,7 +735,8 @@ trait Printers extends api.Printers { self: SymbolTable =>
println()
};
case _ =>
- printPackageDef(pd, "\n")
+ val separator = scala.util.Properties.lineSeparator
+ printPackageDef(pd, separator)
}
case md @ ModuleDef(mods, name, impl) =>
@@ -944,15 +945,16 @@ trait Printers extends api.Printers { self: SymbolTable =>
}
case l @ Literal(x) =>
+ import Chars.LF
x match {
case Constant(v: String) if {
val strValue = x.stringValue
- strValue.contains("\n") && strValue.contains("\"\"\"") && strValue.size > 1
+ strValue.contains(LF) && strValue.contains("\"\"\"") && strValue.size > 1
} =>
- val splitValue = x.stringValue.split('\n'.toString).toList
- val multilineStringValue = if (x.stringValue.endsWith("\n")) splitValue :+ "" else splitValue
+ val splitValue = x.stringValue.split(s"$LF").toList
+ val multilineStringValue = if (x.stringValue.endsWith(s"$LF")) splitValue :+ "" else splitValue
val trQuotes = "\"\"\""
- print(trQuotes); printSeq(multilineStringValue) { print(_) } { print("\n") }; print(trQuotes)
+ print(trQuotes); printSeq(multilineStringValue) { print(_) } { print(LF) }; print(trQuotes)
case _ =>
// processing Float constants
val printValue = x.escapedStringValue + (if (x.value.isInstanceOf[Float]) "F" else "")
View
9 test/junit/scala/reflect/internal/PrintersTest.scala
@@ -19,14 +19,19 @@ class PrintersTest extends BasePrintTests
object PrinterHelper {
val toolbox = cm.mkToolBox()
def assertPrintedCode(code: String, tree: Tree = EmptyTree) = {
+ def processEOL(resultCode: String) = {
+ import scala.reflect.internal.Chars._
+ resultCode.replaceAll(s"$CR$LF", s"$LF").replace(CR, LF)
+ }
+
val toolboxTree =
try{
toolbox.parse(code)
} catch {
case e:scala.tools.reflect.ToolBoxError => throw new Exception(e.getMessage + ": " + code)
}
- if (tree ne EmptyTree) assertEquals("using quasiquote or given tree"+"\n", code.trim, showCode(tree))
- else assertEquals("using toolbox parser", code.trim, showCode(toolboxTree))
+ if (tree ne EmptyTree) assertEquals("using quasiquote or given tree"+"\n", code.trim, processEOL(showCode(tree)))
+ else assertEquals("using toolbox parser", code.trim, processEOL(showCode(toolboxTree)))
}
implicit class StrContextStripMarginOps(val stringContext: StringContext) extends util.StripMarginInterpolator
Please sign in to comment.
Something went wrong with that request. Please try again.