Skip to content

Commit 7832e35

Browse files
committed
Tests for vcArrays (functions, wrappers, vc arrays usage)
1 parent 37c761a commit 7832e35

File tree

6 files changed

+55
-43
lines changed

6 files changed

+55
-43
lines changed

test/dotc/tests.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ class tests extends CompilerTest {
105105
@Test def pos_extmethods = compileFile(posDir, "extmethods", twice)
106106
@Test def pos_companions = compileFile(posDir, "companions", twice)
107107
@Test def pos_vc_proto_any_val = compileFile(vcArraysDir, "prototypeAnyVal", args = "-Ycheck:all" :: Nil)
108-
@Test def pos_any_val_gen_classes = compileFile(runDir, "valueclasses-array-gen")
108+
@Test def pos_vc_array_functions = compileFile(runDir, "valueclasses-array-functions", args = "-Ycheck:all" :: Nil)
109+
@Test def pos_vc_array_usage = compileFile(runDir, "valueclasses-array-usage", args = "-Ycheck:all" :: Nil)
110+
@Test def pos_vc_array_gen = compileFile(runDir, "valueclasses-array-gen", args = "-Ycheck:all" :: Nil)
111+
@Test def pos_vc_array_int = compileFile(runDir, "valueclasses-array-int", args = "-Ycheck:all" :: Nil)
112+
@Test def pos_vc_array_object = compileFile(runDir, "valueclasses-array-object", args = "-Ycheck:all" :: Nil)
109113

110114
@Test def pos_all = compileFiles(posDir) // twice omitted to make tests run faster
111115

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
X-7
2+
X-9
3+
X-11
4+
X-7
5+
X-9
6+
X-11
7+
X-32
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import scala.collection.mutable._
2+
3+
class X(val a: Int) extends AnyVal {
4+
override def toString = s"X-$a"
5+
}
6+
object Test {
7+
def prettyPrintArray3(x: Array[_]) = { println(x.toString); println(x(0)) }
8+
9+
def main(args: Array[String]): Unit = {
10+
val r1 = for (y <- test) { println(y) }
11+
val r2 = test foreach ( x => println(x.toString) )
12+
val r3 = test.foldLeft(new X(5))((x, y) => new X(x.a + y.a))
13+
println(r3)
14+
15+
val t1: ArrayOps[X] = Array(new X(7))
16+
}
17+
18+
def test: Array[X] = Array(new X(7), new X(9), new X(11))
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
2
3+
3
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class X(val a: Int) extends AnyVal {
2+
override def toString = s"X-$a"
3+
}
4+
class Y(val b: Int)
5+
object Test {
6+
def main(args: Array[String]) = {
7+
val t: Array[X] = Array(new X(5))
8+
val t2 = new Array[X](2)
9+
t2(0) = new X(1)
10+
t2(1) = new X(2)
11+
println(t.size)
12+
println(t2.size)
13+
println(test.size)
14+
t: Array[X]
15+
t2: Array[X]
16+
}
17+
def test = {
18+
val a = Array(new X(5), new X(6), new X(7))
19+
a
20+
}
21+
}

tests/run/valueclasses-array.scala

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)