当前位置: 首页>>代码示例>>Scala>>正文


Scala EOL类代码示例

本文整理汇总了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)
  }
} 
开发者ID:cornerman,项目名称:macroni,代码行数:49,代码来源:FailDescription.scala


注:本文中的scala.compat.Platform.EOL类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。