summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rwxr-xr-xtest/files/run/t2127.scala32
-rw-r--r--test/files/run/viewtest.check18
-rwxr-xr-xtest/files/run/viewtest.scala46
3 files changed, 96 insertions, 0 deletions
diff --git a/test/files/run/t2127.scala b/test/files/run/t2127.scala
new file mode 100755
index 0000000000..869d8a38d6
--- /dev/null
+++ b/test/files/run/t2127.scala
@@ -0,0 +1,32 @@
+// Seems to be fixed in trunk
+
+// As discussed here: http://www.nabble.com/Companion-object-constructor-visibility-td24342096.html
+
+//Simplified example:
+
+ class Test private (val value : Int)
+
+ abstract class Bar(val ctor : (Int) => Test)
+
+ object Test extends Bar(new Test(_)) { //<--- ILLEGAL ACCESS
+ def main(args: Array[String]){}
+ }
+
+//however the following is legal:
+/*
+ class Foo private (val value : Int)
+
+ abstract class Bar{
+
+ var ctor : (Int) => Foo
+
+ }
+
+ object Foo extends Bar{
+
+ ctor = new Foo(_) //<--- Legal access
+
+ }
+
+The constructor invocation of Bar is done within the scope of object Foo's constructor, and therefor the private constructor of Foo should be visible and accessible.
+*/
diff --git a/test/files/run/viewtest.check b/test/files/run/viewtest.check
new file mode 100644
index 0000000000..ded3ac0e92
--- /dev/null
+++ b/test/files/run/viewtest.check
@@ -0,0 +1,18 @@
+SeqViewZ((x,0))
+ys defined
+mapping 1
+2
+mapping 1
+mapping 2
+mapping 3
+SeqViewMS(3, 4)
+mapping 3
+4
+mapping 1
+mapping 2
+mapping 3
+SeqViewM(2, 3, 4)
+mapping 1
+mapping 2
+mapping 3
+List(2, 3, 4)
diff --git a/test/files/run/viewtest.scala b/test/files/run/viewtest.scala
new file mode 100755
index 0000000000..0f00536c1c
--- /dev/null
+++ b/test/files/run/viewtest.scala
@@ -0,0 +1,46 @@
+import collection._
+object Test extends Application {
+
+ val xs: SeqView[(String, Int), Seq[_]] = List("x").view.zip(Stream.from(0))
+ println(xs)
+
+ val ys = List(1, 2, 3).view map { x => println("mapping "+x); x + 1 }
+ println("ys defined")
+ println(ys.head)
+ println(ys.tail)
+ println(ys(2))
+ println(ys)
+ println(ys.force)
+
+ val zs = Array(1, 2, 3).view
+ val as: VectorView[Int, Array[Int]] = zs map (_ + 1)
+ val bs: Array[Int] = as.force
+ val cs = zs.reverse
+ cs(0) += 1
+ assert(cs.force.deep == Array(4, 2, 1).deep)
+ assert(zs(2) == 4)
+ assert(bs.deep == Array(2, 3, 4).deep)
+}
+
+/* crash confirmed.
+2.8 regression: CCE when zipping list projection with stream
+Reported by: szeiger Owned by: odersky
+Priority: normal Component: Standard Library
+Keywords: collections, zip Cc:
+Fixed in version:
+Description
+
+Welcome to Scala version 2.8.0.r18784-b20090925021043 (Java HotSpot(TM) Client VM, Java 1.6.0_11).
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> List("x").view.zip(Stream.from(0))List("x").view.zip(Stream.from(0))
+java.lang.ClassCastException: scala.collection.generic.IterableViewTemplate$$anon$8 cannot be cast to scala.collection.generic.SequenceView
+ at .<init>(<console>:5)
+ at .<clinit>(<console>)
+ at RequestResult$.<init>(<console>:4)
+ at RequestResult$.<clinit>(<console>)
+ at RequestResult$result(<console>)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.Nat...
+*/