diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/no-predef.check | 8 | ||||
-rw-r--r-- | test/files/neg/t2102.check | 4 | ||||
-rw-r--r-- | test/files/neg/type-diagnostics.check | 4 | ||||
-rw-r--r-- | test/files/pos/t4237.scala | 15 | ||||
-rw-r--r-- | test/files/run/t10171/Test.scala | 59 | ||||
-rw-r--r-- | test/junit/scala/collection/mutable/HashMapTest.scala | 38 | ||||
-rw-r--r-- | test/scaladoc/run/inlineToStr-strips-unwanted-text.check | 1 | ||||
-rw-r--r-- | test/scaladoc/run/inlineToStr-strips-unwanted-text.scala | 58 | ||||
-rw-r--r-- | test/scaladoc/run/shortDescription-annotation.scala | 19 |
9 files changed, 181 insertions, 25 deletions
diff --git a/test/files/neg/no-predef.check b/test/files/neg/no-predef.check index a63d8c5ba5..f5c2e82fe1 100644 --- a/test/files/neg/no-predef.check +++ b/test/files/neg/no-predef.check @@ -1,11 +1,11 @@ no-predef.scala:2: error: type mismatch; - found : scala.Long(5L) - required: java.lang.Long + found : Long (in scala) + required: Long (in java.lang) def f1 = 5L: java.lang.Long ^ no-predef.scala:3: error: type mismatch; - found : java.lang.Long - required: scala.Long + found : Long (in java.lang) + required: Long (in scala) def f2 = new java.lang.Long(5) : Long ^ no-predef.scala:4: error: value map is not a member of String diff --git a/test/files/neg/t2102.check b/test/files/neg/t2102.check index b4f91a5319..6f70839d22 100644 --- a/test/files/neg/t2102.check +++ b/test/files/neg/t2102.check @@ -1,6 +1,6 @@ t2102.scala:2: error: type mismatch; - found : java.util.Iterator[Int] - required: scala.collection.Iterator[_] + found : Iterator[Int] (in java.util) + required: Iterator[_] (in scala.collection) val x: Iterator[_] = new java.util.ArrayList[Int]().iterator ^ one error found diff --git a/test/files/neg/type-diagnostics.check b/test/files/neg/type-diagnostics.check index c5e6dec3f8..fd327bcb66 100644 --- a/test/files/neg/type-diagnostics.check +++ b/test/files/neg/type-diagnostics.check @@ -1,6 +1,6 @@ type-diagnostics.scala:4: error: type mismatch; - found : scala.collection.Set[String] - required: scala.collection.immutable.Set[String] + found : Set[String] (in scala.collection) + required: Set[String] (in scala.collection.immutable) def f = Calculator("Hello", binding.keySet: collection.Set[String]) ^ type-diagnostics.scala:13: error: type mismatch; diff --git a/test/files/pos/t4237.scala b/test/files/pos/t4237.scala index fcf6eb8bf1..3f605607b2 100644 --- a/test/files/pos/t4237.scala +++ b/test/files/pos/t4237.scala @@ -2,5 +2,16 @@ class A { (new { def field = 0; def field_=(i: Int) = () }).field = 5 // compiles as expected (new { def field(implicit i: Int) = 0; def field_=(i: Int) = () }).field = 5 // compiles even with implicit params on getter (new { def field = 0; def field_=[T](i: Int) = () }).field = 5 // compiles with type param on setter - (new { def field[T] = 0; def field_=(i: Int) = () }).field = 5 // DOESN'T COMPILE -}
\ No newline at end of file + (new { def field[T] = 0; def field_=(i: Int) = () }).field = 5 // DIDN'T COMPILE + + class Imp + implicit val imp: Imp = new Imp + implicit val implicitList: List[Int] = null + + // compiles even with implicit params on setter + (new { def field(implicit i: Int) = 0; def field_=(i: Int)(implicit j: Imp) = () }).field = 5 + (new { def field(implicit i: Int) = 0; def field_=[T <: Imp](i: Int)(implicit j: T) = () }).field = 5 + // was reassignment to val + (new { def field[T](implicit ts: List[T]) = 0; def field_=[T](i: Int)(implicit ts: List[T]) = () }).field = 5 + (new { def field[T](implicit ts: List[T]) = 0; def field_=[T](i: T)(implicit ts: List[T]) = () }).field = 5 +} diff --git a/test/files/run/t10171/Test.scala b/test/files/run/t10171/Test.scala new file mode 100644 index 0000000000..37a2cfc67f --- /dev/null +++ b/test/files/run/t10171/Test.scala @@ -0,0 +1,59 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def library = """ +package a { + package b { + class C { class D } + } +} +package z { + class Base { + type S = String + def foo(s: S): a.b.C#D = null + } + class Sub extends Base { + def sub = "sub" + } +} + """ + + def client = """ + class Client { new z.Sub().sub } + """ + + def deleteClass(s: String) = { + val f = new File(testOutput.path, s + ".class") + assert(f.exists) + f.delete() + } + + def deletePackage(s: String) = { + val f = new File(testOutput.path, s) + assert(f.exists) + f.delete() + } + + def assertNoErrors(): Unit = { + assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n")) + storeReporter.reset() + } + def show(): Unit = { + compileCode(library) + assertNoErrors() + deleteClass("a/b/C$D") + deleteClass("a/b/C") + deletePackage("a/b") + compileCode(client) + assertNoErrors() + } +} + diff --git a/test/junit/scala/collection/mutable/HashMapTest.scala b/test/junit/scala/collection/mutable/HashMapTest.scala new file mode 100644 index 0000000000..cc1979a920 --- /dev/null +++ b/test/junit/scala/collection/mutable/HashMapTest.scala @@ -0,0 +1,38 @@ +package scala.collection +package mutable + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class HashMapTest { + + @Test + def getOrElseUpdate_mutationInCallback() { + val hm = new mutable.HashMap[String, String]() + // add enough elements to resize the hash table in the callback + def add() = 1 to 100000 foreach (i => hm(i.toString) = "callback") + hm.getOrElseUpdate("0", { + add() + "" + }) + assertEquals(Some(""), hm.get("0")) + } + + @Test + def getOrElseUpdate_evalOnce(): Unit = { + var i = 0 + val hm = new mutable.HashMap[Int, Int]() + hm.getOrElseUpdate(0, {i += 1; i}) + assertEquals(1, hm(0)) + } + + @Test + def getOrElseUpdate_noEval(): Unit = { + val hm = new mutable.HashMap[Int, Int]() + hm.put(0, 0) + hm.getOrElseUpdate(0, throw new AssertionError()) + } +} diff --git a/test/scaladoc/run/inlineToStr-strips-unwanted-text.check b/test/scaladoc/run/inlineToStr-strips-unwanted-text.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/inlineToStr-strips-unwanted-text.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/inlineToStr-strips-unwanted-text.scala b/test/scaladoc/run/inlineToStr-strips-unwanted-text.scala new file mode 100644 index 0000000000..8faaf1b93d --- /dev/null +++ b/test/scaladoc/run/inlineToStr-strips-unwanted-text.scala @@ -0,0 +1,58 @@ +import scala.tools.nsc.doc.html.Page +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = """ + /** This comment contains ^superscript^ */ + class Foo { + /** This comment contains ,,subscript,, */ + def bar = ??? + + /** This comment contains a link [[https://scala.epfl.ch/]] */ + def baz = ??? + + /** This comment contains an <strong>html tag</strong> */ + def qux = ??? + + /** This comment contains a<br> single html tag */ + def quux = ??? + + /** This comment contains nested <strong>html<br> tags</strong> */ + def quuz = ??? + + /** This comment contains a [[corge ,,link with a subscript title,,]] */ + def corge = ??? + } + """ + def scaladocSettings = "" + + def testModel(root: Package) = { + import scala.tools.nsc.doc.base.comment._ + import access._ + + val foo = root._class("Foo") + + val fooStr = Page.inlineToStr(foo.comment.get.short) + assert(fooStr == "This comment contains superscript", fooStr) + + val barStr = Page.inlineToStr(foo._method("bar").comment.get.short) + assert(barStr == "This comment contains subscript", barStr) + + val bazStr = Page.inlineToStr(foo._method("baz").comment.get.short) + assert(bazStr == "This comment contains a link https://scala.epfl.ch/", bazStr) + + val quxStr = Page.inlineToStr(foo._method("qux").comment.get.short) + assert(quxStr == "This comment contains an html tag", quxStr) + + val quuxStr = Page.inlineToStr(foo._method("quux").comment.get.short) + assert(quuxStr == "This comment contains a single html tag", quuxStr) + + val quuzStr = Page.inlineToStr(foo._method("quuz").comment.get.short) + assert(quuzStr == "This comment contains nested html tags", quuzStr) + + val corgeStr = Page.inlineToStr(foo._method("corge").comment.get.short) + assert(corgeStr == "This comment contains a link with a subscript title", corgeStr) + } +} diff --git a/test/scaladoc/run/shortDescription-annotation.scala b/test/scaladoc/run/shortDescription-annotation.scala index 0e2950f4f9..4f9a891133 100644 --- a/test/scaladoc/run/shortDescription-annotation.scala +++ b/test/scaladoc/run/shortDescription-annotation.scala @@ -1,3 +1,4 @@ +import scala.tools.nsc.doc.html.Page import scala.tools.nsc.doc.model._ import scala.tools.partest.ScaladocModelTest @@ -26,30 +27,18 @@ object Test extends ScaladocModelTest { import scala.tools.nsc.doc.base.comment._ import access._ - def inlineToStr(inl: Inline): String = inl match { - case Chain(items) => items flatMap (inlineToStr(_)) mkString "" - case Italic(in) => inlineToStr(in) - case Bold(in) => inlineToStr(in) - case Underline(in) => inlineToStr(in) - case Monospace(in) => inlineToStr(in) - case Text(text) => text - case Summary(in) => inlineToStr(in) - case EntityLink(Text(text), _) => text - case _ => inl.toString - } - val foo = rootPackage._package("a")._class("Foo") // Assert that the class has the correct short description - val classDesc = inlineToStr(foo.comment.get.short) + val classDesc = Page.inlineToStr(foo.comment.get.short) assert(classDesc == "This one should appear", classDesc) // Assert that the `foo` method has the correct short description - val fooDesc = inlineToStr(foo._method("foo").comment.get.short) + val fooDesc = Page.inlineToStr(foo._method("foo").comment.get.short) assert(fooDesc == "This comment should appear", fooDesc) // Assert that the `goo` method has the correct short description - val gooDesc = inlineToStr(foo._method("goo").comment.get.short) + val gooDesc = Page.inlineToStr(foo._method("goo").comment.get.short) assert(gooDesc == "This comment should appear", gooDesc) } } |