diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/javaConversions-2.10-ambiguity.check | 6 | ||||
-rw-r--r-- | test/files/neg/javaConversions-2.10-ambiguity.scala | 10 | ||||
-rw-r--r-- | test/files/pos/javaConversions-2.10-regression.scala | 17 | ||||
-rw-r--r-- | test/files/run/stream-stack-overflow-filter-map.scala | 44 | ||||
-rw-r--r-- | test/files/run/try-catch-unify.check | 1 | ||||
-rw-r--r-- | test/files/run/try-catch-unify.scala | 1 |
6 files changed, 79 insertions, 0 deletions
diff --git a/test/files/neg/javaConversions-2.10-ambiguity.check b/test/files/neg/javaConversions-2.10-ambiguity.check new file mode 100644 index 0000000000..c064a22964 --- /dev/null +++ b/test/files/neg/javaConversions-2.10-ambiguity.check @@ -0,0 +1,6 @@ +javaConversions-2.10-ambiguity.scala:8: error: type mismatch; + found : scala.collection.concurrent.Map[String,String] + required: scala.collection.mutable.ConcurrentMap[String,String] + assertType[mutable.ConcurrentMap[String, String]](a) + ^ +one error found diff --git a/test/files/neg/javaConversions-2.10-ambiguity.scala b/test/files/neg/javaConversions-2.10-ambiguity.scala new file mode 100644 index 0000000000..e856846a29 --- /dev/null +++ b/test/files/neg/javaConversions-2.10-ambiguity.scala @@ -0,0 +1,10 @@ +import collection.{JavaConversions, mutable, concurrent} +import JavaConversions._ +import java.util.concurrent.{ConcurrentHashMap => CHM} + +object Bar { + def assertType[T](t: T) = t + val a = new CHM[String, String]() += (("", "")) + assertType[mutable.ConcurrentMap[String, String]](a) +} +// vim: set et: diff --git a/test/files/pos/javaConversions-2.10-regression.scala b/test/files/pos/javaConversions-2.10-regression.scala new file mode 100644 index 0000000000..e1b81015ba --- /dev/null +++ b/test/files/pos/javaConversions-2.10-regression.scala @@ -0,0 +1,17 @@ +import collection.{JavaConversions, mutable, concurrent} +import JavaConversions._ +import java.util.concurrent.{ConcurrentHashMap => CHM} + +object Foo { + def buildCache2_9_simple[K <: AnyRef, V <: AnyRef]: mutable.ConcurrentMap[K, V] = + asScalaConcurrentMap(new CHM()) + + def buildCache2_9_implicit[K <: AnyRef, V <: AnyRef]: mutable.ConcurrentMap[K, V] = + new CHM[K, V]() +} + +object Bar { + def assertType[T](t: T) = t + val a = new CHM[String, String]() += (("", "")) + assertType[concurrent.Map[String, String]](a) +} diff --git a/test/files/run/stream-stack-overflow-filter-map.scala b/test/files/run/stream-stack-overflow-filter-map.scala new file mode 100644 index 0000000000..f3a9dd49cb --- /dev/null +++ b/test/files/run/stream-stack-overflow-filter-map.scala @@ -0,0 +1,44 @@ +import collection.generic.{FilterMonadic, CanBuildFrom} + +object Test extends App { + def mapSucc[Repr, That](s: FilterMonadic[Int, Repr])(implicit cbf: CanBuildFrom[Repr, Int, That]) = s map (_ + 1) + def flatMapId[T, Repr, That](s: FilterMonadic[T, Repr])(implicit cbf: CanBuildFrom[Repr, T, That]) = s flatMap (Seq(_)) + + def testStreamPred(s: Stream[Int])(p: Int => Boolean) { + val res1 = s withFilter p + val res2 = s filter p + + val expected = s.toSeq filter p + + val fMapped1 = flatMapId(res1) + val fMapped2 = flatMapId(res2) + assert(fMapped1 == fMapped2) + assert(fMapped1.toSeq == expected) + + val mapped1 = mapSucc(res1) + val mapped2 = mapSucc(res2) + assert(mapped1 == mapped2) + assert(mapped1.toSeq == (expected map (_ + 1))) + + assert((res1 map identity).toSeq == res2.toSeq) + } + + def testStream(s: Stream[Int]) { + testStreamPred(s)(_ => false) + testStreamPred(s)(_ => true) + testStreamPred(s)(_ % 2 == 0) + testStreamPred(s)(_ % 3 == 0) + } + + //Reduced version of the test case - either invocation used to cause a stack + //overflow before commit 80b3f433e5536d086806fa108ccdfacf10719cc2. + val resFMap = (1 to 10000).toStream withFilter (_ => false) flatMap (Seq(_)) + val resMap = (1 to 10000).toStream withFilter (_ => false) map (_ + 1) + + //Complete test case for withFilter + map/flatMap, as requested by @axel22. + for (j <- (0 to 3) :+ 10000) { + val stream = (1 to j).toStream + assert(stream.toSeq == (1 to j).toSeq) + testStream(stream) + } +} diff --git a/test/files/run/try-catch-unify.check b/test/files/run/try-catch-unify.check index b1de2bfa74..67a8c64a33 100644 --- a/test/files/run/try-catch-unify.check +++ b/test/files/run/try-catch-unify.check @@ -1,3 +1,4 @@ Failure(java.lang.NumberFormatException: For input string: "Hi") Success(5.0) O NOES +Failure(java.lang.NumberFormatException: For input string: "Hi") diff --git a/test/files/run/try-catch-unify.scala b/test/files/run/try-catch-unify.scala index 0d819ab957..8cb14d060e 100644 --- a/test/files/run/try-catch-unify.scala +++ b/test/files/run/try-catch-unify.scala @@ -11,5 +11,6 @@ object Test { } catch { case t => println(t.getMessage) } + println(nonFatalCatch withTry ("Hi".toDouble)) } } |