summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-01-04 10:38:41 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-01-04 10:38:41 +0000
commita87d132bb752858dc5f8ac0d450a33f58dd12cba (patch)
tree32799c6c6515b752382f50d5ddf3b587e083f20f /test
parent1f4d528702ca32ed01e500ea2ef2e9b2ebbe07d1 (diff)
downloadscala-a87d132bb752858dc5f8ac0d450a33f58dd12cba.tar.gz
scala-a87d132bb752858dc5f8ac0d450a33f58dd12cba.tar.bz2
scala-a87d132bb752858dc5f8ac0d450a33f58dd12cba.zip
Closes #3687, #3719, #3950, #3616.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t3687.check2
-rw-r--r--test/files/run/t3687.scala6
-rw-r--r--test/files/run/t3719.check4
-rw-r--r--test/files/run/t3719.scala35
-rw-r--r--test/files/run/t3950.check3
-rw-r--r--test/files/run/t3950.scala17
6 files changed, 67 insertions, 0 deletions
diff --git a/test/files/run/t3687.check b/test/files/run/t3687.check
new file mode 100644
index 0000000000..0f35862645
--- /dev/null
+++ b/test/files/run/t3687.check
@@ -0,0 +1,2 @@
+t.ValueSet(a, b)
+t.ValueSet(a, b) \ No newline at end of file
diff --git a/test/files/run/t3687.scala b/test/files/run/t3687.scala
new file mode 100644
index 0000000000..25141f8a32
--- /dev/null
+++ b/test/files/run/t3687.scala
@@ -0,0 +1,6 @@
+object t extends Enumeration { val a, b = Value }
+
+object Test extends Application {
+ println(t.values)
+ println(t.values)
+}
diff --git a/test/files/run/t3719.check b/test/files/run/t3719.check
new file mode 100644
index 0000000000..111fc7fd63
--- /dev/null
+++ b/test/files/run/t3719.check
@@ -0,0 +1,4 @@
+List(Mon, Tue, Wed, Thu, Fri, Sat, Sun)
+Mon
+Tue
+Mon \ No newline at end of file
diff --git a/test/files/run/t3719.scala b/test/files/run/t3719.scala
new file mode 100644
index 0000000000..2436e0cdf6
--- /dev/null
+++ b/test/files/run/t3719.scala
@@ -0,0 +1,35 @@
+object Days extends Enumeration {
+ type Day = DayValue
+ val Mon, Tue, Wed, Thu, Fri, Sat, Sun = new DayValue // DayValue
+
+ protected class DayValue extends Val {
+ def isWeekday: Boolean =
+ this match {
+ case Sun => false
+ case Sat => false
+ case _ => true
+ }
+ }
+}
+
+object Test extends Application {
+ def dayElementsShouldBeNamed(): List[String] =
+ Days.values.toList.sorted.map(x => x.toString)
+
+ def nameOfMon(): String = {
+ import Days._
+ val d: Day = Mon
+ d.toString
+ }
+
+ def nameOfTue(): String = {
+ import Days._
+ val d: Day = Tue
+ d.toString
+ }
+
+ println(dayElementsShouldBeNamed())
+ println(nameOfMon())
+ println(nameOfTue())
+ println(nameOfMon())
+}
diff --git a/test/files/run/t3950.check b/test/files/run/t3950.check
new file mode 100644
index 0000000000..10f81c51ad
--- /dev/null
+++ b/test/files/run/t3950.check
@@ -0,0 +1,3 @@
+minus
+zero
+plus \ No newline at end of file
diff --git a/test/files/run/t3950.scala b/test/files/run/t3950.scala
new file mode 100644
index 0000000000..fe99a7cc6f
--- /dev/null
+++ b/test/files/run/t3950.scala
@@ -0,0 +1,17 @@
+
+object NegativeId extends Enumeration {
+ val Negative = Value(-1, "minus")
+ val Zero = Value(0, "zero")
+ val Positive = Value(1, "plus")
+
+ def fromInt(id: Int) = values find (_.id == id) match {
+ case Some(v) => v
+ case None => null
+ }
+}
+
+object Test extends Application {
+ println(NegativeId.fromInt(-1))
+ println(NegativeId.fromInt(0))
+ println(NegativeId.fromInt(1))
+}