diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/richs.check | 9 | ||||
-rw-r--r-- | test/files/run/richs.scala | 41 |
2 files changed, 44 insertions, 6 deletions
diff --git a/test/files/run/richs.check b/test/files/run/richs.check index 3b2f468010..3b73f084a0 100644 --- a/test/files/run/richs.check +++ b/test/files/run/richs.check @@ -1,4 +1,13 @@ +RichCharTest1: +true +true +true +true + +RichCharTest2: +true + RichIntTest: 10 11 diff --git a/test/files/run/richs.scala b/test/files/run/richs.scala index 8b2775ea7b..a88a3c1237 100644 --- a/test/files/run/richs.scala +++ b/test/files/run/richs.scala @@ -14,10 +14,37 @@ trait RichTest { def length[A](it: Iterator[A]) = it.toList length def run: Unit } +object RichCharTest1 extends RichTest { + def run { + Console.println("\n" + getObjectName + ":") + Console.println('\40'.isWhitespace) + Console.println('\011'.isWhitespace) + Console.println('1'.asDigit == java.lang.Character.digit('1', 10)) + Console.println('A'.asDigit(16) == java.lang.Character.digit('A', 16)) + } +} +object RichCharTest2 extends RichTest { + case class C(s: String) { + private val it = s.elements + private var c: Char = _ + def ch(): Char = c + def nextch(): Unit = { c = if (it.hasNext) it.next else ';' } + def err(msg: String) = Console.println(msg) + nextch() + } + def run { + Console.println("\n" + getObjectName + ":") + val c1 = C("x4A;") + val s1 = xml.Utility.parseCharRef(c1.ch, c1.nextch, c1.err) + val c2 = C("74;") + val s2 = xml.Utility.parseCharRef(c2.ch, c2.nextch, c2.err) + Console.println(s1 == s2) + } +} object RichIntTest extends RichTest { private val n = 10 private val m = -2 - def run: Unit = { + def run { Console.println("\n" + getObjectName + ":") Console.println(length(0 until n)) Console.println(length(0 to n)) @@ -28,7 +55,7 @@ object RichIntTest extends RichTest { } } object RichStringTest1 extends RichTest { - def run: Unit = { + def run { Console.println("\n" + getObjectName + ":") Console.println("s1: " + s1) Console.println("s2: " + s2) @@ -38,7 +65,7 @@ object RichStringTest1 extends RichTest { } } object RichStringTest2 extends RichTest { - def run: Unit = { + def run { Console.println("\n" + getObjectName + ":") Console.print("s1: "); s1.lines foreach Console.println Console.print("s2: "); s2.lines foreach Console.println @@ -48,7 +75,7 @@ object RichStringTest2 extends RichTest { } } object RichStringTest3 extends RichTest { - def run: Unit = { + def run { Console.println("\n" + getObjectName + ":") Console.println("s1: " + s1.stripLineEnd) Console.println("s2: " + s2.stripLineEnd) @@ -58,7 +85,7 @@ object RichStringTest3 extends RichTest { } } object RichStringTest4 extends RichTest { - def run: Unit = { + def run { Console.println("\n" + getObjectName + ":") Console.println("s1: " + s1.stripMargin) Console.println("s2: " + s2.stripMargin) @@ -68,7 +95,7 @@ object RichStringTest4 extends RichTest { } } object RichStringTest5 extends RichTest { - def run: Unit = { + def run { Console.println("\n" + getObjectName + ":") Console.println("s1: " + s3.stripMargin('#')) Console.println("s2: " + s3.stripMargin('#')) @@ -79,6 +106,8 @@ object RichStringTest5 extends RichTest { } object Test { def main(args: Array[String]): Unit = { + RichCharTest1.run + RichCharTest2.run RichIntTest.run RichStringTest1.run RichStringTest2.run |