diff options
author | michelou <michelou@epfl.ch> | 2006-06-29 11:24:24 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-06-29 11:24:24 +0000 |
commit | 47e617d9624de8f36bb222398604f386d561d0aa (patch) | |
tree | 98cb4536037d189fd42d704092903a5f8f66e977 /test/files/run | |
parent | 4006064a64dbcececb368449b54d3b4592df48f2 (diff) | |
download | scala-47e617d9624de8f36bb222398604f386d561d0aa.tar.gz scala-47e617d9624de8f36bb222398604f386d561d0aa.tar.bz2 scala-47e617d9624de8f36bb222398604f386d561d0aa.zip |
updated cli test, added test for multiline strings
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/richs.check | 60 | ||||
-rw-r--r-- | test/files/run/richs.scala | 89 |
2 files changed, 149 insertions, 0 deletions
diff --git a/test/files/run/richs.check b/test/files/run/richs.check new file mode 100644 index 0000000000..3b2f468010 --- /dev/null +++ b/test/files/run/richs.check @@ -0,0 +1,60 @@ + +RichIntTest: +10 +11 +12 +13 +0 +0 + +RichStringTest1: +s1: abc +s2: abc\txyz\n +s3: abc + xyz +s4: abc + |xyz +s5: abc + #xyz + +RichStringTest2: +s1: abc +s2: abc\txyz\n +s3: abc + xyz +s4: abc + |xyz +s5: abc + #xyz + +RichStringTest3: +s1: abc +s2: abc\txyz\n +s3: abc + xyz +s4: abc + |xyz +s5: abc + #xyz + +RichStringTest4: +s1: abc +s2: abc\txyz\n +s3: abc + xyz +s4: abc +xyz +s5: abc + #xyz + +RichStringTest5: +s1: abc + xyz +s2: abc + xyz +s3: abc + xyz +s4: abc + |xyz +s5: abc +xyz 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 + } +} |