本文整理汇总了Scala中scala.tools.nsc.interpreter.JPrintWriter类的典型用法代码示例。如果您正苦于以下问题:Scala JPrintWriter类的具体用法?Scala JPrintWriter怎么用?Scala JPrintWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JPrintWriter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ThpySpec
//设置package包名称以及导入依赖的类
package com.github.bigwheel.thpy
import com.github.bigwheel.thpy.Macro.anyToTyped
import java.io.BufferedReader
import java.io.StringReader
import java.io.StringWriter
import org.scalatest.FunSpec
import org.scalatest.Matchers
import scala.tools.nsc.interpreter.JPrintWriter
class ThpySpec extends FunSpec with Matchers {
private[this] def toBufferedReader(s: String) = new BufferedReader(new StringReader(s))
it ("""has "Welcome to Thpy" message""") {
val input = ":quit"
val sw = new StringWriter()
break(toBufferedReader(input), new JPrintWriter(sw))
sw.toString.contains("Welcome to Thpy") should be(true)
}
it ("can process") {
val b = 3
val input = """|1 + 1
|b
|:quit""".stripMargin
break(toBufferedReader(input), b)
}
it ("can change mutable object") {
val map = scala.collection.mutable.Map(1 -> "one")
map.size should equal(1)
val input = """|map
|map.put(2, "two")
|:quit""".stripMargin
break(toBufferedReader(input), map)
map.size should equal(2)
map(2) should equal("two")
}
}