diff options
author | Paul Phillips <paulp@improving.org> | 2011-05-27 00:10:39 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-05-27 00:10:39 +0000 |
commit | d76dc724e319663b6f854ecade8524323a576ea8 (patch) | |
tree | c72f205509380a51a5834413b0503f8dd8ede2b2 /test/files | |
parent | d800ebd073bbbaddfc5df200a84c355ce36eeeed (diff) | |
download | scala-d76dc724e319663b6f854ecade8524323a576ea8.tar.gz scala-d76dc724e319663b6f854ecade8524323a576ea8.tar.bz2 scala-d76dc724e319663b6f854ecade8524323a576ea8.zip |
Overcoming limitations of the repl, multiple-tr...
Overcoming limitations of the repl, multiple-tree lines and assignments.
The best part of nicely documented limitations is that you can stare at
the same comment for years and then the day comes when you give it the
heave-ho.
Exhibit A (regarding a single bare expression): "This is necessary due
to it being hard to modify code at a textual level, and it being hard
to submit an AST to the compiler." Yes, it IS hard to modify code at
a textual level (see enclosed patch) but we won't let that stop us
anymore. Closes #4578.
Exhibit B (regarding the left hand side of assignments having to be
Ident): "An unfortunate limitation." Unfortunate no longer! No review.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/repl-bare-expr.check | 36 | ||||
-rw-r--r-- | test/files/run/repl-bare-expr.scala | 16 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/files/run/repl-bare-expr.check b/test/files/run/repl-bare-expr.check new file mode 100644 index 0000000000..04daa48232 --- /dev/null +++ b/test/files/run/repl-bare-expr.check @@ -0,0 +1,36 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> 2 ; 3 +res0: Int = 3 + +scala> { 2 ; 3 } +res1: Int = 3 + +scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { + 1 + + 2 + + 3 } ; bippy+88+11 +defined module Cow +defined class Moo +bippy: Int +res2: Int = 105 + +scala> + +scala> object Bovine { var x: List[_] = null } ; case class Ruminant(x: Int) ; bippy * bippy * bippy +defined module Bovine +defined class Ruminant +res3: Int = 216 + +scala> Bovine.x = List(Ruminant(5), Cow, new Moo) +Bovine.x: List[Any] = List(Ruminant(5), Cow, Moooooo) + +scala> Bovine.x +res4: List[Any] = List(Ruminant(5), Cow, Moooooo) + +scala> + +scala> diff --git a/test/files/run/repl-bare-expr.scala b/test/files/run/repl-bare-expr.scala new file mode 100644 index 0000000000..df9849fa6d --- /dev/null +++ b/test/files/run/repl-bare-expr.scala @@ -0,0 +1,16 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +2 ; 3 +{ 2 ; 3 } +5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { + 1 + + 2 + + 3 } ; bippy+88+11 + +object Bovine { var x: List[_] = null } ; case class Ruminant(x: Int) ; bippy * bippy * bippy +Bovine.x = List(Ruminant(5), Cow, new Moo) +Bovine.x + """ +}
\ No newline at end of file |