diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t8430.check | 27 | ||||
-rw-r--r-- | test/files/neg/t8430.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t8430.scala | 32 | ||||
-rw-r--r-- | test/files/neg/t8450.check | 6 | ||||
-rw-r--r-- | test/files/neg/t8450.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t8450.scala | 12 | ||||
-rw-r--r-- | test/files/pos/t8497/A_1.scala | 13 | ||||
-rw-r--r-- | test/files/pos/t8497/B_2.scala | 1 | ||||
-rw-r--r-- | test/files/run/t7992.scala | 20 | ||||
-rw-r--r-- | test/files/run/t7992b.scala | 18 | ||||
-rw-r--r-- | test/scaladoc/resources/SI-8144.scala | 17 | ||||
-rw-r--r-- | test/scaladoc/scalacheck/HtmlFactoryTest.scala | 66 |
12 files changed, 210 insertions, 4 deletions
diff --git a/test/files/neg/t8430.check b/test/files/neg/t8430.check new file mode 100644 index 0000000000..7c6a73ce53 --- /dev/null +++ b/test/files/neg/t8430.check @@ -0,0 +1,27 @@ +t8430.scala:15: warning: match may not be exhaustive. +It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), 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 + (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 + (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 + (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 + (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 + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/t8430.flags b/test/files/neg/t8430.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t8430.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t8430.scala b/test/files/neg/t8430.scala new file mode 100644 index 0000000000..4166b08a0a --- /dev/null +++ b/test/files/neg/t8430.scala @@ -0,0 +1,32 @@ +sealed trait CL3Literal +case object IntLit extends CL3Literal +case object CharLit extends CL3Literal +case object BooleanLit extends CL3Literal +case object UnitLit extends CL3Literal + + +sealed trait Tree +case class LetL(value: CL3Literal) extends Tree +case object LetP extends Tree +case object LetC extends Tree +case object LetF extends Tree + +object Test { + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + // After the first patch for SI-8430, we achieve stability: all of + // these get the same warning: + // + // ??, LetC, LetF, LetL(IntLit), LetP + // + // Before, it was non-deterministic. + // + // However, we our list of counter examples is itself non-exhaustive. + // We need to rework counter example generation to fix that. + // + // That work is the subject of SI-7746 +} diff --git a/test/files/neg/t8450.check b/test/files/neg/t8450.check new file mode 100644 index 0000000000..eeabb9730c --- /dev/null +++ b/test/files/neg/t8450.check @@ -0,0 +1,6 @@ +t8450.scala:5: warning: implicit numeric widening + def elapsed: Foo = (System.nanoTime - 100L).foo + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8450.flags b/test/files/neg/t8450.flags new file mode 100644 index 0000000000..9a1332d7af --- /dev/null +++ b/test/files/neg/t8450.flags @@ -0,0 +1 @@ +-Ywarn-numeric-widen -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t8450.scala b/test/files/neg/t8450.scala new file mode 100644 index 0000000000..f20ed2bc31 --- /dev/null +++ b/test/files/neg/t8450.scala @@ -0,0 +1,12 @@ +trait Foo + +class WarnWidening { + implicit class FooDouble(d: Double) { def foo = new Foo {} } + def elapsed: Foo = (System.nanoTime - 100L).foo +} + +class NoWarnWidening { + implicit class FooLong(l: Long) { def foo = new Foo {} } + implicit class FooDouble(d: Double) { def foo = new Foo {} } + def elapsed: Foo = (System.nanoTime - 100L).foo +} diff --git a/test/files/pos/t8497/A_1.scala b/test/files/pos/t8497/A_1.scala new file mode 100644 index 0000000000..6a76b0ee99 --- /dev/null +++ b/test/files/pos/t8497/A_1.scala @@ -0,0 +1,13 @@ +package p { + object Crash { + def e(s: (String @java.lang.Deprecated)): Unit = () + def f(s: (String @nonStatic)): Unit = () + } + object Ok { + def g(s: (String @nonStatic @static)): Unit = () + def h(s: (String @static)): Unit = () + } +} + +class nonStatic extends scala.annotation.Annotation +class static extends scala.annotation.StaticAnnotation diff --git a/test/files/pos/t8497/B_2.scala b/test/files/pos/t8497/B_2.scala new file mode 100644 index 0000000000..efe2edf2c3 --- /dev/null +++ b/test/files/pos/t8497/B_2.scala @@ -0,0 +1 @@ +package p { object Test { Crash } } diff --git a/test/files/run/t7992.scala b/test/files/run/t7992.scala new file mode 100644 index 0000000000..fde231b961 --- /dev/null +++ b/test/files/run/t7992.scala @@ -0,0 +1,20 @@ +class C { + def foo: Int = 0 +} + +class D extends C { + override def foo: Int = { + val f = () => { + class C // comment this line to fix. + D.super.foo // no super accessor generated here! + // java.lang.VerifyError: (class: D$$anonfun$1, method: apply$mcI$sp signature: ()I) Illegal use of nonvirtual function call + } + f() + } +} + +object Test { + def main(args: Array[String]) { + new D().foo + } +} diff --git a/test/files/run/t7992b.scala b/test/files/run/t7992b.scala new file mode 100644 index 0000000000..6fe1f990d5 --- /dev/null +++ b/test/files/run/t7992b.scala @@ -0,0 +1,18 @@ +class C { + def foo: Int = 0 +} + +class E extends C { + override def foo: Int = { + (None: Option[Int]).getOrElse { + class C + E.super.foo + } + } +} + +object Test { + def main(args: Array[String]) { + new E().foo + } +} diff --git a/test/scaladoc/resources/SI-8144.scala b/test/scaladoc/resources/SI-8144.scala new file mode 100644 index 0000000000..7b225acb32 --- /dev/null +++ b/test/scaladoc/resources/SI-8144.scala @@ -0,0 +1,17 @@ +package some.pack + +class SomeType(arg: String) { + + type TypeAlias = String + + def >@<(): TypeAlias = "Tricky method name" + + def >#<(): Int = 1 + +} + +object SomeType { + + val someVal = "Some arbitrary companion object value" + +} diff --git a/test/scaladoc/scalacheck/HtmlFactoryTest.scala b/test/scaladoc/scalacheck/HtmlFactoryTest.scala index 3ee8fd9303..ef70e0bf21 100644 --- a/test/scaladoc/scalacheck/HtmlFactoryTest.scala +++ b/test/scaladoc/scalacheck/HtmlFactoryTest.scala @@ -149,7 +149,6 @@ object Test extends Properties("HtmlFactory") { result } - def shortComments(root: scala.xml.Node) = XMLUtil.stripGroup(root).descendant.flatMap { case e: scala.xml.Elem => { @@ -417,7 +416,7 @@ object Test extends Properties("HtmlFactory") { checkText("SI_5054_q1.scala")( (None,"""def test(): Int""", true) //Disabled because the full signature is now displayed - //(None,"""def test(implicit lost: Int): Int""", false) + //(None, """def test(implicit lost: Int): Int""", false) ) property("SI-5054: Use cases should keep their flags - final should not be lost") = @@ -564,7 +563,7 @@ object Test extends Properties("HtmlFactory") { property("Comment inheritance: Correct explicit inheritance for override") = checkText("explicit-inheritance-override.scala")( (Some("InheritDocDerived"), - """def function[T](arg1: T, arg2: String): Double + """def function[T](arg1: T, arg2: String): Double Starting line Starting line The base comment. And another sentence... @@ -591,7 +590,7 @@ object Test extends Properties("HtmlFactory") { property("Comment inheritance: Correct explicit inheritance for usecase") = checkText("explicit-inheritance-usecase.scala")( (Some("UseCaseInheritDoc"), - """def function[T](arg1: T, arg2: String): Double + """def function[T](arg1: T, arg2: String): Double [use case] Starting line [use case] Starting line The base comment. And another sentence... @@ -755,4 +754,63 @@ object Test extends Properties("HtmlFactory") { """, true) ) } + + // SI-8144 + { + implicit class AttributesAwareNode(val node: NodeSeq) { + + def \@(attrName: String): String = + node \ ("@" + attrName) text + + def \@(attrName: String, attrValue: String): NodeSeq = + node filter { _ \ ("@" + attrName) exists (_.text == attrValue) } + } + + implicit class AssertionAwareNode(node: scala.xml.NodeSeq) { + + def assertTypeLink(expectedUrl: String): Boolean = { + val linkElement: NodeSeq = node \\ "div" \@ ("id", "definition") \\ "span" \@ ("class", "permalink") \ "a" + linkElement \@ "href" == expectedUrl && linkElement \@ "target" == "_top" + } + + def assertMemberLink(group: String)(memberName: String, expectedUrl: String): Boolean = { + val linkElement: NodeSeq = node \\ "div" \@ ("id", group) \\ "li" \@ ("name", memberName) \\ "span" \@ ("class", "permalink") \ "a" + linkElement \@ "href" == expectedUrl && linkElement \@ "target" == "_top" + } + + } + + val files = createTemplates("SI-8144.scala") + + def check(pagePath: String)(f: NodeSeq => org.scalacheck.Prop): org.scalacheck.Prop = + files(pagePath) match { + case node: scala.xml.Node => f(XMLUtil.stripGroup(node)) + case _ => false + } + + property("SI-8144: Members' permalink - package") = check("some/package.html") { node => + ("type link" |: node.assertTypeLink("../index.html#some.package")) && + ("member: some.pack" |: node.assertMemberLink("values")("some.pack", "../index.html#some.package@pack")) + } + + property("SI-8144: Members' permalink - inner package") = check("some/pack/package.html") { node => + ("type link" |: node.assertTypeLink("../../index.html#some.pack.package")) && + ("member: SomeType (object)" |: node.assertMemberLink("values")("some.pack.SomeType", "../../index.html#some.pack.package@SomeType")) && + ("member: SomeType (class)" |: node.assertMemberLink("types")("some.pack.SomeType", "../../index.html#some.pack.package@SomeTypeextendsAnyRef")) + } + + property("SI-8144: Members' permalink - companion object") = check("some/pack/SomeType$.html") { node => + ("type link" |: node.assertTypeLink("../../index.html#some.pack.SomeType$")) && + ("member: someVal" |: node.assertMemberLink("allMembers")("some.pack.SomeType#someVal", "../../index.html#some.pack.SomeType$@someVal:String")) + } + + property("SI-8144: Members' permalink - class") = check("some/pack/SomeType.html") { node => + ("type link" |: node.assertTypeLink("../../index.html#some.pack.SomeType")) && + ("constructor " |: node.assertMemberLink("constructors")("some.pack.SomeType#<init>", "../../index.html#some.pack.SomeType@<init>(arg:String):some.pack.SomeType")) && + ( "member: type TypeAlias" |: node.assertMemberLink("types")("some.pack.SomeType.TypeAlias", "../../index.html#some.pack.SomeType@TypeAlias=String")) && + ( "member: def >#<():Int " |: node.assertMemberLink("values")("some.pack.SomeType#>#<", "../../index.html#some.pack.SomeType@>#<():Int")) && + ( "member: def >@<():TypeAlias " |: node.assertMemberLink("values")("some.pack.SomeType#>@<", "../../index.html#some.pack.SomeType@>@<():SomeType.this.TypeAlias")) + } + + } } |