summaryrefslogtreecommitdiff
path: root/test/files/run/richs.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-11-02 10:25:25 +0000
committermichelou <michelou@epfl.ch>2006-11-02 10:25:25 +0000
commitd9ba6d6db90bcf0bbb34e706bcad8e2c316bce8f (patch)
tree44868afb7e631e12fb43d02dedf5879f3de6229a /test/files/run/richs.scala
parent6aa668e0f46a5bc19016350d0f90bde3403c854d (diff)
downloadscala-d9ba6d6db90bcf0bbb34e706bcad8e2c316bce8f.tar.gz
scala-d9ba6d6db90bcf0bbb34e706bcad8e2c316bce8f.tar.bz2
scala-d9ba6d6db90bcf0bbb34e706bcad8e2c316bce8f.zip
added tests for rich characters
Diffstat (limited to 'test/files/run/richs.scala')
-rw-r--r--test/files/run/richs.scala41
1 files changed, 35 insertions, 6 deletions
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