diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t2421b.check | 4 | ||||
-rw-r--r-- | test/files/neg/t2421b.scala | 17 | ||||
-rw-r--r-- | test/files/neg/t2641.check | 2 | ||||
-rw-r--r-- | test/files/neg/t2870.check | 7 | ||||
-rwxr-xr-x | test/files/neg/t2870.scala | 9 | ||||
-rw-r--r-- | test/files/pos/t2421b.scala | 19 | ||||
-rw-r--r-- | test/files/pos/t2810.scala | 8 | ||||
-rw-r--r-- | test/files/pos/t2867.scala | 1 | ||||
-rw-r--r-- | test/files/positions/Scaladoc6.scala | 10 | ||||
-rw-r--r-- | test/files/positions/Scaladoc7.scala | 6 | ||||
-rw-r--r-- | test/files/positions/Scaladoc8.scala | 6 | ||||
-rw-r--r-- | test/files/run/bug2354.scala | 17 | ||||
-rw-r--r-- | test/files/run/bug2876.scala | 7 | ||||
-rw-r--r-- | test/files/run/map_java_conversions.scala | 60 | ||||
-rw-r--r-- | test/files/run/t2849.scala | 46 | ||||
-rw-r--r-- | test/pending/run/bug2364.check | 1 | ||||
-rw-r--r-- | test/pending/run/bug2364.scala | 60 |
17 files changed, 279 insertions, 1 deletions
diff --git a/test/files/neg/t2421b.check b/test/files/neg/t2421b.check new file mode 100644 index 0000000000..f666a7d9d7 --- /dev/null +++ b/test/files/neg/t2421b.check @@ -0,0 +1,4 @@ +t2421b.scala:12: error: could not find implicit value for parameter aa: Test.F[Test.A] + f + ^ +one error found
\ No newline at end of file diff --git a/test/files/neg/t2421b.scala b/test/files/neg/t2421b.scala new file mode 100644 index 0000000000..d8159a8c37 --- /dev/null +++ b/test/files/neg/t2421b.scala @@ -0,0 +1,17 @@ +object Test { + class A + class B + class C + class F[X] + + def f(implicit aa: F[A]) = println(aa) + + // implicit def a : F[A] = new F[A]() + implicit def b[X <: B] = new F[X]() + + f +} + +/* bug: +error: type arguments [Test2.A] do not conform to method b's type parameter bounds [X <: Test2.B] +*/
\ No newline at end of file diff --git a/test/files/neg/t2641.check b/test/files/neg/t2641.check index 07900d0796..771624e8d9 100644 --- a/test/files/neg/t2641.check +++ b/test/files/neg/t2641.check @@ -25,7 +25,7 @@ t2641.scala:27: error: illegal inheritance; superclass Any trait Sliced extends Transformed[A] with super.Sliced { ^ t2641.scala:27: error: illegal inheritance; superclass Any - is not a subclass of the superclass TraversableLike + is not a subclass of the superclass Object of the mixin trait Sliced trait Sliced extends Transformed[A] with super.Sliced { ^ diff --git a/test/files/neg/t2870.check b/test/files/neg/t2870.check new file mode 100644 index 0000000000..6577577d3f --- /dev/null +++ b/test/files/neg/t2870.check @@ -0,0 +1,7 @@ +t2870.scala:1: error: not found: type Jar +class Jars(jar: Jar) + ^ +t2870.scala:6: error: illegal cyclic reference involving value <import> + val scala = fromClasspathString(javaClassPath) + ^ +two errors found diff --git a/test/files/neg/t2870.scala b/test/files/neg/t2870.scala new file mode 100755 index 0000000000..4de19242e3 --- /dev/null +++ b/test/files/neg/t2870.scala @@ -0,0 +1,9 @@ +class Jars(jar: Jar) + +object Jars { + import scala.util.Properties.javaClassPath + + val scala = fromClasspathString(javaClassPath) + + def fromClasspathString(s: String): Jars = null +} diff --git a/test/files/pos/t2421b.scala b/test/files/pos/t2421b.scala new file mode 100644 index 0000000000..0df3461662 --- /dev/null +++ b/test/files/pos/t2421b.scala @@ -0,0 +1,19 @@ +object Test { + class A + class B + class C + class F[X] + + def f(implicit aa: F[A]) = println(aa) + + implicit def a : F[A] = new F[A]() + implicit def b[X <: B] = new F[X]() + + f +} +/* bug: +error: ambiguous implicit values: + both method b in object Test1 of type [X <: Test1.B]Test1.F[X] + and method a in object Test1 of type => Test1.F[Test1.A] + match expected type Test1.F[Test1.A] +*/ diff --git a/test/files/pos/t2810.scala b/test/files/pos/t2810.scala new file mode 100644 index 0000000000..c85eca164a --- /dev/null +++ b/test/files/pos/t2810.scala @@ -0,0 +1,8 @@ + + + + +object Test { + val closeable1: { def close(): Unit } = new scala.io.Source { val iter: Iterator[Char] = "".iterator } + val closeable2: { def close(): Unit } = new java.io.Closeable { def close() = {} } +} diff --git a/test/files/pos/t2867.scala b/test/files/pos/t2867.scala new file mode 100644 index 0000000000..0434a380b9 --- /dev/null +++ b/test/files/pos/t2867.scala @@ -0,0 +1 @@ +case class A(l: List[_]*) diff --git a/test/files/positions/Scaladoc6.scala b/test/files/positions/Scaladoc6.scala new file mode 100644 index 0000000000..8beda625ae --- /dev/null +++ b/test/files/positions/Scaladoc6.scala @@ -0,0 +1,10 @@ +object Scaladoc6 { + { + /** + * Foo + */ + val i = 23 + } + + def f {} +} diff --git a/test/files/positions/Scaladoc7.scala b/test/files/positions/Scaladoc7.scala new file mode 100644 index 0000000000..6175222e3f --- /dev/null +++ b/test/files/positions/Scaladoc7.scala @@ -0,0 +1,6 @@ +object Scaladoc7 { + /** + * Foo + */ + val Pair(i, j) = (1, 2) +} diff --git a/test/files/positions/Scaladoc8.scala b/test/files/positions/Scaladoc8.scala new file mode 100644 index 0000000000..519d6ca06c --- /dev/null +++ b/test/files/positions/Scaladoc8.scala @@ -0,0 +1,6 @@ +/** + * Foo + */ +object Scaladoc8 { + +} diff --git a/test/files/run/bug2354.scala b/test/files/run/bug2354.scala new file mode 100644 index 0000000000..f46db13a95 --- /dev/null +++ b/test/files/run/bug2354.scala @@ -0,0 +1,17 @@ +import scala.xml.parsing._ +import scala.io.Source + +object Test +{ + val xml_good = "<title><![CDATA[Hello [tag]]]></title>" + val xml_bad = "<title><![CDATA[Hello [tag] ]]></title>" + + val parser1 = ConstructingParser.fromSource(Source.fromString(xml_good),false) + val parser2 = ConstructingParser.fromSource(Source.fromString(xml_bad),false) + + def main(args: Array[String]): Unit = { + parser1.document + parser2.document + } +} + diff --git a/test/files/run/bug2876.scala b/test/files/run/bug2876.scala new file mode 100644 index 0000000000..f71879ebff --- /dev/null +++ b/test/files/run/bug2876.scala @@ -0,0 +1,7 @@ +object Test +{ + def main(args: Array[String]): Unit = { + "x".view.filter(_ => true).take(1) + } +} + diff --git a/test/files/run/map_java_conversions.scala b/test/files/run/map_java_conversions.scala new file mode 100644 index 0000000000..4f9f8a915a --- /dev/null +++ b/test/files/run/map_java_conversions.scala @@ -0,0 +1,60 @@ + + + + + +object Test { + + def main(args: Array[String]) { + import collection.JavaConversions._ + + test(new java.util.HashMap[String, String]) + test(new java.util.Properties) + testConcMap + } + + def testConcMap { + import collection.JavaConversions._ + + val concMap = new java.util.concurrent.ConcurrentHashMap[String, String] + + test(concMap) + val cmap = asConcurrentMap(concMap) + cmap.putIfAbsent("absentKey", "absentValue") + cmap.put("somekey", "somevalue") + assert(cmap.remove("somekey", "somevalue") == true) + assert(cmap.replace("absentKey", "newAbsentValue") == Some("absentValue")) + assert(cmap.replace("absentKey", "newAbsentValue", ".......") == true) + } + + def test(m: collection.mutable.Map[String, String]) { + m.clear + assert(m.size == 0) + + m.put("key", "value") + assert(m.size == 1) + + assert(m.put("key", "anotherValue") == Some("value")) + assert(m.put("key2", "value2") == None) + assert(m.size == 2) + + m += (("key3", "value3")) + assert(m.size == 3) + + m -= "key2" + assert(m.size == 2) + assert(m.nonEmpty) + assert(m.remove("key") == Some("anotherValue")) + + m.clear + for (i <- 0 until 10) m += (("key" + i, "value" + i)) + for ((k, v) <- m) assert(k.startsWith("key")) + } + +} + + + + + + diff --git a/test/files/run/t2849.scala b/test/files/run/t2849.scala new file mode 100644 index 0000000000..68094de736 --- /dev/null +++ b/test/files/run/t2849.scala @@ -0,0 +1,46 @@ + + + +import scala.collection.immutable.SortedSet +import scala.collection.immutable.TreeSet + + + +object Test { + + def main(args: Array[String]) { + ticketExample + similarExample + } + + def ticketExample { + var big = 100000 + + var aSortedSet: SortedSet[Int] = TreeSet(big) + + for (i <- 1 until 10000) { + aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) + big = big - 1 + if (i % 1000 == 0) { + aSortedSet.until(i) + } + } + } + + def similarExample { + var big = 100 + + var aSortedSet: SortedSet[Int] = TreeSet(big) + + for (i <- 1 until 10000) { + aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) + big + big = big - 1 + if (i % 1000 == 0) { + aSortedSet.until(i) + } + } + } + +} + + diff --git a/test/pending/run/bug2364.check b/test/pending/run/bug2364.check new file mode 100644 index 0000000000..219305e43a --- /dev/null +++ b/test/pending/run/bug2364.check @@ -0,0 +1 @@ +<test></test> diff --git a/test/pending/run/bug2364.scala b/test/pending/run/bug2364.scala new file mode 100644 index 0000000000..d5805a13b8 --- /dev/null +++ b/test/pending/run/bug2364.scala @@ -0,0 +1,60 @@ +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import com.sun.xml.internal.fastinfoset._ +import com.sun.xml.internal.fastinfoset.sax._ +import scala.xml.parsing.NoBindingFactoryAdapter +import scala.xml._ + +// Note - this is in pending because com.sun.xml.etc is not standard, +// and I don't have time to extract a smaller test. + +object Test { + def main(args: Array[String]) { + val node = <test/> + val bytes = new ByteArrayOutputStream + val serializer = new SAXDocumentSerializer() + + serializer.setOutputStream(bytes) + serializer.startDocument() + serialize(node, serializer) + serializer.endDocument() + println(parse(new ByteArrayInputStream(bytes.toByteArray))) + } + def serialize(node: Node, serializer: SAXDocumentSerializer) { + node match { + case _ : ProcInstr | _ : Comment | _ : EntityRef => + case x : Atom[_] => + val chars = x.text.toCharArray + serializer.characters(chars, 0, chars.length) + case _ : Elem => + serializer.startElement("", node.label.toLowerCase, node.label.toLowerCase, attributes(node.attributes)) + for (m <- node.child) serialize(m, serializer) + serializer.endElement("", node.label.toLowerCase, node.label.toLowerCase) + } + } + def parse(str: ByteArrayInputStream) = { + val parser = new SAXDocumentParser + val fac = new NoBindingFactoryAdapter + + parser.setContentHandler(fac) + try { + parser.parse(str) + } catch { + case x: Exception => + x.printStackTrace + } + fac.rootElem + } + def attributes(d: MetaData) = { + val attrs = new AttributesHolder + + if (d != null) { + for (attr <- d) { + val sb = new StringBuilder() + Utility.sequenceToXML(attr.value, TopScope, sb, true) + attrs.addAttribute(new QualifiedName("", "", attr.key.toLowerCase), sb.toString) + } + } + attrs + } +} |