本文整理汇总了Scala中scala.compat.Platform.EOL类的典型用法代码示例。如果您正苦于以下问题:Scala EOL类的具体用法?Scala EOL怎么用?Scala EOL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EOL类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: FailDescription
//设置package包名称以及导入依赖的类
package macroni.helper
import macroni.compiler._
import scala.compat.Platform.EOL
import scala.reflect.runtime.universe.{showCode, Tree}
object FailDescription {
import Colors._
private def highlightCode(tree: Tree) = highlight(showCode(tree))
private def describeSection(section: (String, String)) = {
val (head, body) = section
bold(red(s"--- $head: ---")) + EOL + body
}
private def describeFailure(sections: (String, String)*) = {
val descriptions = sections.map(describeSection)
descriptions.mkString(EOL) + EOL + bold(red("---")) + EOL
}
def shouldCompile(result: CompileFailure) = {
import result._
describeFailure("source" -> highlightCode(source), "which doesn't compile but should" -> (notices ++ errors).mkString(EOL))
}
def shouldNotCompile(result: CompileSuccess) = {
import result._
describeFailure("source" -> highlightCode(source), "which compiles but shouldn't" -> notices.mkString(EOL))
}
def shouldContain(source: Tree, message: String) = {
describeFailure("source" -> highlightCode(source), "which does not contain" -> highlight(message))
}
def shouldHaveChild(source: Tree, message: String) = {
describeFailure("source" -> highlightCode(source), "which does not have a direct child" -> highlight(message))
}
def compilerWarnings(source: Tree, description: String) = {
describeFailure("source" -> highlightCode(source), "which has unexpected warnings" -> description)
}
def compilerErrors(source: Tree, description: String) = {
describeFailure("source" -> highlightCode(source), "which has unexpected errors" -> description)
}
}