diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/patmatexhaust.check | 2 | ||||
-rw-r--r-- | test/files/neg/patmatexhaust.flags | 2 | ||||
-rw-r--r-- | test/files/neg/patmatexhaust.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t8291.check | 7 | ||||
-rw-r--r-- | test/files/neg/t8291.scala | 7 | ||||
-rw-r--r-- | test/files/neg/t8430.check | 12 | ||||
-rw-r--r-- | test/files/neg/t8430.flags | 2 | ||||
-rw-r--r-- | test/files/presentation/doc.check | 1 | ||||
-rwxr-xr-x | test/files/presentation/doc/doc.scala | 147 | ||||
-rwxr-xr-x | test/files/presentation/doc/src/Class.scala | 1 | ||||
-rwxr-xr-x | test/files/presentation/doc/src/p/Base.scala | 11 | ||||
-rwxr-xr-x | test/files/presentation/doc/src/p/Derived.scala | 9 | ||||
-rw-r--r-- | test/files/run/t8845.flags | 1 | ||||
-rw-r--r-- | test/files/run/t8845.scala | 17 | ||||
-rw-r--r-- | test/files/run/virtpatmat_nested_lists.flags | 1 | ||||
-rw-r--r-- | test/files/run/virtpatmat_opt_sharing.flags | 1 |
16 files changed, 213 insertions, 10 deletions
diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check index 2dad608451..bbf5e9b528 100644 --- a/test/files/neg/patmatexhaust.check +++ b/test/files/neg/patmatexhaust.check @@ -12,7 +12,7 @@ It would fail on the following inputs: (Kult(_), Kult(_)), (Qult(), Qult()) ^ patmatexhaust.scala:49: warning: match may not be exhaustive. It would fail on the following inputs: Gp(), Gu - def ma4(x:Deep) = x match { // missing cases: Gu, Gp + def ma4(x:Deep) = x match { // missing cases: Gu, Gp which is not abstract so must be included ^ patmatexhaust.scala:55: warning: unreachable code case _ if 1 == 0 => diff --git a/test/files/neg/patmatexhaust.flags b/test/files/neg/patmatexhaust.flags index 85d8eb2ba2..3b01ca062c 100644 --- a/test/files/neg/patmatexhaust.flags +++ b/test/files/neg/patmatexhaust.flags @@ -1 +1 @@ --Xfatal-warnings +-Xfatal-warnings -Ypatmat-exhaust-depth off
\ No newline at end of file diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala index f937197829..26f0c12a91 100644 --- a/test/files/neg/patmatexhaust.scala +++ b/test/files/neg/patmatexhaust.scala @@ -46,7 +46,7 @@ class TestSealedExhaustive { // compile only case _ => } - def ma4(x:Deep) = x match { // missing cases: Gu, Gp + def ma4(x:Deep) = x match { // missing cases: Gu, Gp which is not abstract so must be included case Ga => } diff --git a/test/files/neg/t8291.check b/test/files/neg/t8291.check new file mode 100644 index 0000000000..c9972e5575 --- /dev/null +++ b/test/files/neg/t8291.check @@ -0,0 +1,7 @@ +t8291.scala:5: error: Could not find implicit for Int or String + implicitly[X[Int, String]] + ^ +t8291.scala:6: error: Could not find implicit for Int or String + implicitly[Z[String]] + ^ +two errors found diff --git a/test/files/neg/t8291.scala b/test/files/neg/t8291.scala new file mode 100644 index 0000000000..b344586a56 --- /dev/null +++ b/test/files/neg/t8291.scala @@ -0,0 +1,7 @@ +@scala.annotation.implicitNotFound("Could not find implicit for ${T} or ${U}") trait X[T, U] + +object Test { + type Z[U] = X[Int, U] + implicitly[X[Int, String]] + implicitly[Z[String]] +} diff --git a/test/files/neg/t8430.check b/test/files/neg/t8430.check index 7c6a73ce53..dbc0c70bba 100644 --- a/test/files/neg/t8430.check +++ b/test/files/neg/t8430.check @@ -1,25 +1,25 @@ t8430.scala:15: warning: match may not be exhaustive. -It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP +It would fail on the following inputs: LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetL(UnitLit), LetP (tree: Tree) => tree match {case LetL(CharLit) => ??? } ^ t8430.scala:16: warning: match may not be exhaustive. -It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP +It would fail on the following inputs: LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetL(UnitLit), LetP (tree: Tree) => tree match {case LetL(CharLit) => ??? } ^ t8430.scala:17: warning: match may not be exhaustive. -It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP +It would fail on the following inputs: LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetL(UnitLit), LetP (tree: Tree) => tree match {case LetL(CharLit) => ??? } ^ t8430.scala:18: warning: match may not be exhaustive. -It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP +It would fail on the following inputs: LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetL(UnitLit), LetP (tree: Tree) => tree match {case LetL(CharLit) => ??? } ^ t8430.scala:19: warning: match may not be exhaustive. -It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP +It would fail on the following inputs: LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetL(UnitLit), LetP (tree: Tree) => tree match {case LetL(CharLit) => ??? } ^ t8430.scala:20: warning: match may not be exhaustive. -It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP +It would fail on the following inputs: LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetL(UnitLit), LetP (tree: Tree) => tree match {case LetL(CharLit) => ??? } ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/t8430.flags b/test/files/neg/t8430.flags index 85d8eb2ba2..6f60189a8d 100644 --- a/test/files/neg/t8430.flags +++ b/test/files/neg/t8430.flags @@ -1 +1 @@ --Xfatal-warnings +-Xfatal-warnings -Ypatmat-exhaust-depth off diff --git a/test/files/presentation/doc.check b/test/files/presentation/doc.check new file mode 100644 index 0000000000..5a3ff13151 --- /dev/null +++ b/test/files/presentation/doc.check @@ -0,0 +1 @@ +reload: Base.scala, Class.scala, Derived.scala diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala new file mode 100755 index 0000000000..f2233f1828 --- /dev/null +++ b/test/files/presentation/doc/doc.scala @@ -0,0 +1,147 @@ +import scala.reflect.internal.util.{ BatchSourceFile, SourceFile } +import scala.tools.nsc.doc +import scala.tools.nsc.doc.base._ +import scala.tools.nsc.doc.base.comment._ +import scala.tools.nsc.interactive._ +import scala.tools.nsc.interactive.tests._ + +object Test extends InteractiveTest { + val tags = Seq( + "@example `\"abb\".permutations = Iterator(abb, bab, bba)`", + "@version 1.0, 09/07/2012", + "@since 2.10", + "@todo this is unsafe!", + "@note Don't inherit!", + "@see something else" + ) + + val names = Seq("Class", "Def", "Val", "Var", "AbstracType", "TypeAlias", "Trait", "InnerClass") + val bareText = + """abstract class %s { + | def %s = "" + | val %s = "" + | var %s: String = _ + | type %s + | type %s = String + | class %s + |} + |trait %s""".stripMargin.format(names: _*) + + def docComment(nTags: Int) = "/**\n%s*/".format(tags.take(nTags).mkString("\n")) + + def text(name: String, nTags: Int) = { + val nameIndex = bareText.indexOf(name) + val (pre, post) = bareText.splitAt(nameIndex) + val crIndex = pre.lastIndexOf("\n") + val (prepre, prepost) = pre.splitAt(crIndex) + prepre + docComment(nTags) + prepost + post + } + + override lazy val compiler = { + prepareSettings(settings) + new Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase with doc.ScaladocGlobalTrait { + outer => + + val global: this.type = this + + override lazy val analyzer = new { + val global: outer.type = outer + } with doc.ScaladocAnalyzer with InteractiveAnalyzer { + override def newTyper(context: Context): InteractiveTyper with ScaladocTyper = + new Typer(context) with InteractiveTyper with ScaladocTyper + } + + def chooseLink(links: List[LinkTo]): LinkTo = links.head + def internalLink(sym: Symbol, site: Symbol) = None + def toString(link: LinkTo) = link.toString + def warnNoLink = false + def findExternalLink(sym: Symbol, name: String) = None + + override def forScaladoc = true + + def getComment(sym: Symbol, source: SourceFile, fragments: List[(Symbol,SourceFile)]): Option[Comment] = { + val docResponse = new Response[(String, String, Position)] + askDocComment(sym, source, sym.owner, fragments, docResponse) + docResponse.get.left.toOption flatMap { + case (expanded, raw, pos) => + if (expanded.isEmpty) + None + else + Some(ask { () => parseAtSymbol(expanded, raw, pos, sym.owner) }) + } + } + } + } + + override def runDefaultTests() { + import compiler._ + def findSource(name: String) = sourceFiles.find(_.file.name == name).get + + val className = names.head + for (name <- names; + i <- 1 to tags.length) { + val newText = text(name, i) + val source = findSource("Class.scala") + val batch = new BatchSourceFile(source.file, newText.toCharArray) + val reloadResponse = new Response[Unit] + compiler.askReload(List(batch), reloadResponse) + reloadResponse.get.left.toOption match { + case None => + println("Couldn't reload") + case Some(_) => + val parseResponse = new Response[Tree] + askParsedEntered(batch, true, parseResponse) + parseResponse.get.left.toOption match { + case None => + println("Couldn't parse") + case Some(_) => + val sym = compiler.ask { () => + val toplevel = compiler.rootMirror.EmptyPackage.info.decl(TypeName(name)) + if (toplevel eq NoSymbol) { + val clazz = compiler.rootMirror.EmptyPackage.info.decl(TypeName(className)) + val term = clazz.info.decl(TermName(name)) + if (term eq NoSymbol) clazz.info.decl(TypeName(name)) else + if (term.isAccessor) term.accessed else term + } else toplevel + } + + getComment(sym, batch, (sym,batch)::Nil) match { + case None => println(s"Got no doc comment for $name") + case Some(comment) => + import comment._ + def cnt(bodies: Iterable[Body]) = bodies.size + val actual = cnt(example) + cnt(version) + cnt(since) + cnt(todo) + cnt(note) + cnt(see) + if (actual != i) + println(s"Got docComment with $actual tags instead of $i, file text:\n$newText") + } + } + } + } + + // Check inter-classes documentation one-time retrieved ok. + val baseSource = findSource("Base.scala") + val derivedSource = findSource("Derived.scala") + def existsText(where: Any, text: String): Boolean = where match { + case s: String => s contains text + case s: Seq[_] => s exists (existsText(_, text)) + case p: Product => p.productIterator exists (existsText(_, text)) + case c: Comment => existsText(c.body, text) + } + val (derived, base) = compiler.ask { () => + val derived = compiler.rootMirror.RootPackage.info.decl(newTermName("p")).info.decl(newTypeName("Derived")) + (derived, derived.ancestors(0)) + } + val cmt1 = getComment(derived, derivedSource, (base, baseSource)::(derived, derivedSource)::Nil) + if (!existsText(cmt1, "This is Derived comment")) + println("Unexpected Derived class comment:"+cmt1) + + val (fooDerived, fooBase) = compiler.ask { () => + val decl = derived.tpe.decl(newTermName("foo")) + (decl, decl.allOverriddenSymbols(0)) + } + + val cmt2 = getComment(fooDerived, derivedSource, (fooBase, baseSource)::(fooDerived, derivedSource)::Nil) + if (!existsText(cmt2, "Base method has documentation")) + println("Unexpected foo method comment:"+cmt2) + } +} diff --git a/test/files/presentation/doc/src/Class.scala b/test/files/presentation/doc/src/Class.scala new file mode 100755 index 0000000000..a974bd6f5c --- /dev/null +++ b/test/files/presentation/doc/src/Class.scala @@ -0,0 +1 @@ +object Class
\ No newline at end of file diff --git a/test/files/presentation/doc/src/p/Base.scala b/test/files/presentation/doc/src/p/Base.scala new file mode 100755 index 0000000000..d91632b6f6 --- /dev/null +++ b/test/files/presentation/doc/src/p/Base.scala @@ -0,0 +1,11 @@ +package p + +/** + * @define BaseComment This is $BaseVar comment. + */ +trait Base { + /** + * Base method has documentation. + */ + def foo: String +} diff --git a/test/files/presentation/doc/src/p/Derived.scala b/test/files/presentation/doc/src/p/Derived.scala new file mode 100755 index 0000000000..1a9c9a26d1 --- /dev/null +++ b/test/files/presentation/doc/src/p/Derived.scala @@ -0,0 +1,9 @@ +package p + +/** + * $BaseComment + * @define BaseVar Derived + */ +class Derived extends Base { + def foo = "" +} diff --git a/test/files/run/t8845.flags b/test/files/run/t8845.flags new file mode 100644 index 0000000000..aada25f80d --- /dev/null +++ b/test/files/run/t8845.flags @@ -0,0 +1 @@ +-Ybackend:GenBCode -Ynooptimize diff --git a/test/files/run/t8845.scala b/test/files/run/t8845.scala new file mode 100644 index 0000000000..8ccdbdadc7 --- /dev/null +++ b/test/files/run/t8845.scala @@ -0,0 +1,17 @@ +// crashes compiler under GenASM, works under GenBCode. +object Interpreter { + def mkDataProp(i: Int) = i + def break(n: Int): Unit = + try { + n match { + case _ => + val newDesc = mkDataProp(n) + n match { case _ => return } + } + } catch { case e: Throwable => } + finally { } +} + +object Test extends App { + Interpreter.break(0) +} diff --git a/test/files/run/virtpatmat_nested_lists.flags b/test/files/run/virtpatmat_nested_lists.flags new file mode 100644 index 0000000000..ca9a4c0697 --- /dev/null +++ b/test/files/run/virtpatmat_nested_lists.flags @@ -0,0 +1 @@ +-Ypatmat-exhaust-depth off
\ No newline at end of file diff --git a/test/files/run/virtpatmat_opt_sharing.flags b/test/files/run/virtpatmat_opt_sharing.flags new file mode 100644 index 0000000000..ca9a4c0697 --- /dev/null +++ b/test/files/run/virtpatmat_opt_sharing.flags @@ -0,0 +1 @@ +-Ypatmat-exhaust-depth off
\ No newline at end of file |