diff options
author | Som Snytt <som.snytt@gmail.com> | 2013-07-03 02:06:25 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2013-07-04 07:55:15 -0700 |
commit | 596b85373b0203e7557f71e1bced980e277ec751 (patch) | |
tree | b379fbd87975937dd2d750bc276e2c65ec333d65 /src/partest | |
parent | 4222849b14e64f668e7250bc2decef15eea5822a (diff) | |
download | scala-596b85373b0203e7557f71e1bced980e277ec751.tar.gz scala-596b85373b0203e7557f71e1bced980e277ec751.tar.bz2 scala-596b85373b0203e7557f71e1bced980e277ec751.zip |
SI-4594 Repl settings command
A settings command for the rest of us.
The usual command line options are used, except that boolean flags
are enabled with +flag and disabled with -flag.
```
scala> :settings +deprecation
scala> new BigInt(java.math.BigInteger.TEN) { }
<console>:8: warning: inheritance from class BigInt in package math is deprecated: This class will me made final.
new BigInt(java.math.BigInteger.TEN) { }
^
res0: BigInt = 10
scala> :settings -deprecation
scala> new BigInt(java.math.BigInteger.TEN) { }
res1: BigInt = 10
```
Multivalue "colon" options can be reset by supplying no values
after the colon. This behavior is different from the command line.
```
scala> 1 toString
warning: there were 1 feature warning(s); re-run with -feature for details
res0: String = 1
scala> :settings -language:postfixOps
scala> 1 toString
res1: String = 1
scala> :settings
-d = .
-encoding = UTF-8
-explaintypes = false
-language = List(postfixOps)
-nowarn = false
scala> :settings -language:
scala> :settings
-d = .
-encoding = UTF-8
-explaintypes = false
-language = List()
-nowarn = false
```
Diffstat (limited to 'src/partest')
-rw-r--r-- | src/partest/scala/tools/partest/ReplTest.scala | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/partest/scala/tools/partest/ReplTest.scala b/src/partest/scala/tools/partest/ReplTest.scala index edd1f705a4..7381b8af54 100644 --- a/src/partest/scala/tools/partest/ReplTest.scala +++ b/src/partest/scala/tools/partest/ReplTest.scala @@ -7,6 +7,7 @@ package scala.tools.partest import scala.tools.nsc.Settings import scala.tools.nsc.interpreter.ILoop +import scala.tools.partest.nest.FileUtil import java.lang.reflect.{ Method => JMethod, Field => JField } /** A trait for testing repl code. It drops the first line @@ -29,3 +30,15 @@ abstract class ReplTest extends DirectTest { } def show() = eval() foreach println } + +abstract class SessionTest extends ReplTest with FileUtil { + def session: String + override final def code = expected filter (_.startsWith(prompt)) map (_.drop(prompt.length)) mkString "\n" + def expected = session.stripMargin.lines.toList + final def prompt = "scala> " + override def show() = { + val out = eval().toList + if (out.size != expected.size) Console println s"Expected ${expected.size} lines, got ${out.size}" + if (out != expected) Console print compareContents(expected, out, "expected", "actual") + } +} |