From bc3589d3ebab7735fbbb130fbb7c8ccb1146eef7 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 27 Sep 2015 18:52:23 -0700 Subject: SI-9492 REPL paste here doc Simple here documentish syntax for REPL paste. This makes it easier to paste a block of script (as opposed to transcript). It also means you won't accidentally ctl-D out of the REPL and then out of SBT and then out of the terminal window. ``` scala> :paste < EOF // Entering paste mode (EOF to finish) class C { def c = 42 } EOF // Exiting paste mode, now interpreting. defined class C scala> new C().c res0: Int = 42 scala> :paste <| EOF // Entering paste mode (EOF to finish) |class D { def d = 42 } EOF // Exiting paste mode, now interpreting. defined class D scala> new D().d res1: Int = 42 scala> :quit ``` --- test/files/run/repl-paste-5.check | 28 ++++++++++++++++++++++++++++ test/files/run/repl-paste-5.scala | 18 ++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/files/run/repl-paste-5.check create mode 100644 test/files/run/repl-paste-5.scala (limited to 'test/files/run') diff --git a/test/files/run/repl-paste-5.check b/test/files/run/repl-paste-5.check new file mode 100644 index 0000000000..8b97b8888d --- /dev/null +++ b/test/files/run/repl-paste-5.check @@ -0,0 +1,28 @@ + +scala> :paste < EOF +// Entering paste mode (EOF to finish) + +class C { def c = 42 } +EOF + +// Exiting paste mode, now interpreting. + +defined class C + +scala> new C().c +res0: Int = 42 + +scala> :paste <| EOF +// Entering paste mode (EOF to finish) + + |class D { def d = 42 } +EOF + +// Exiting paste mode, now interpreting. + +defined class D + +scala> new D().d +res1: Int = 42 + +scala> :quit diff --git a/test/files/run/repl-paste-5.scala b/test/files/run/repl-paste-5.scala new file mode 100644 index 0000000000..890f47f141 --- /dev/null +++ b/test/files/run/repl-paste-5.scala @@ -0,0 +1,18 @@ + +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + //def code = ":paste < EOF\n" + ( + def code = + """ +:paste < EOF +class C { def c = 42 } +EOF +new C().c +:paste <| EOF + |class D { def d = 42 } +EOF +new D().d + """ + //) +} -- cgit v1.2.3