summaryrefslogtreecommitdiff
path: root/test/files/run/richs.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-06-29 11:24:24 +0000
committermichelou <michelou@epfl.ch>2006-06-29 11:24:24 +0000
commit47e617d9624de8f36bb222398604f386d561d0aa (patch)
tree98cb4536037d189fd42d704092903a5f8f66e977 /test/files/run/richs.scala
parent4006064a64dbcececb368449b54d3b4592df48f2 (diff)
downloadscala-47e617d9624de8f36bb222398604f386d561d0aa.tar.gz
scala-47e617d9624de8f36bb222398604f386d561d0aa.tar.bz2
scala-47e617d9624de8f36bb222398604f386d561d0aa.zip
updated cli test, added test for multiline strings
Diffstat (limited to 'test/files/run/richs.scala')
-rw-r--r--test/files/run/richs.scala89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/files/run/richs.scala b/test/files/run/richs.scala
new file mode 100644
index 0000000000..526783318b
--- /dev/null
+++ b/test/files/run/richs.scala
@@ -0,0 +1,89 @@
+trait RichTest {
+ val s1 = """abc"""
+ val s2 = """abc\txyz\n"""
+ val s3 = """abc
+ xyz"""
+ val s4 = """abc
+ |xyz"""
+ val s5 = """abc
+ #xyz"""
+ def getObjectName: String = {
+ val cn = this.getClass().getName()
+ cn.substring(0, cn.length-1)
+ }
+ def length[A](it: Iterator[A]) = it.toList length
+ def run: Unit
+}
+object RichIntTest extends RichTest {
+ private val n = 10
+ private val m = -2
+ def run: Unit = {
+ Console.println("\n" + getObjectName + ":")
+ Console.println(length(0 until n))
+ Console.println(length(0 to n))
+ Console.println(length(m until n))
+ Console.println(length(m to n))
+ Console.println(length(n until m))
+ Console.println(length(n to m))
+ }
+}
+object RichStringTest1 extends RichTest {
+ def run: Unit = {
+ Console.println("\n" + getObjectName + ":")
+ Console.println("s1: " + s1)
+ Console.println("s2: " + s2)
+ Console.println("s3: " + s3)
+ Console.println("s4: " + s4)
+ Console.println("s5: " + s5)
+ }
+}
+object RichStringTest2 extends RichTest {
+ def run: Unit = {
+ Console.println("\n" + getObjectName + ":")
+ Console.print("s1: "); s1.lines foreach Console.println
+ Console.print("s2: "); s2.lines foreach Console.println
+ Console.print("s3: "); s3.lines foreach Console.println
+ Console.print("s4: "); s4.lines foreach Console.println
+ Console.print("s5: "); s5.lines foreach Console.println
+ }
+}
+object RichStringTest3 extends RichTest {
+ def run: Unit = {
+ Console.println("\n" + getObjectName + ":")
+ Console.println("s1: " + s1.stripLineEnd)
+ Console.println("s2: " + s2.stripLineEnd)
+ Console.println("s3: " + s3.stripLineEnd)
+ Console.println("s4: " + s4.stripLineEnd)
+ Console.println("s5: " + s5.stripLineEnd)
+ }
+}
+object RichStringTest4 extends RichTest {
+ def run: Unit = {
+ Console.println("\n" + getObjectName + ":")
+ Console.println("s1: " + s1.stripMargin)
+ Console.println("s2: " + s2.stripMargin)
+ Console.println("s3: " + s3.stripMargin)
+ Console.println("s4: " + s4.stripMargin)
+ Console.println("s5: " + s5.stripMargin)
+ }
+}
+object RichStringTest5 extends RichTest {
+ def run: Unit = {
+ Console.println("\n" + getObjectName + ":")
+ Console.println("s1: " + s3.stripMargin('#'))
+ Console.println("s2: " + s3.stripMargin('#'))
+ Console.println("s3: " + s3.stripMargin('#'))
+ Console.println("s4: " + s4.stripMargin('#'))
+ Console.println("s5: " + s5.stripMargin('#'))
+ }
+}
+object Test {
+ def main(args: Array[String]): Unit = {
+ RichIntTest.run
+ RichStringTest1.run
+ RichStringTest2.run
+ RichStringTest3.run
+ RichStringTest4.run
+ RichStringTest5.run
+ }
+}