diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/innerClassAttribute/Classes_1.scala | 6 | ||||
-rw-r--r-- | test/files/jvm/innerClassAttribute/Test.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t9535.check | 7 | ||||
-rw-r--r-- | test/files/neg/t9535.scala | 7 | ||||
-rw-r--r-- | test/files/run/repl-paste-5.check | 28 | ||||
-rw-r--r-- | test/files/run/repl-paste-5.scala | 18 | ||||
-rw-r--r-- | test/files/run/stringinterpolation_macro-run.check | 71 | ||||
-rw-r--r-- | test/files/run/stringinterpolation_macro-run.scala | 122 | ||||
-rw-r--r-- | test/files/run/t9535.scala | 22 |
9 files changed, 86 insertions, 197 deletions
diff --git a/test/files/jvm/innerClassAttribute/Classes_1.scala b/test/files/jvm/innerClassAttribute/Classes_1.scala index 2b690bdd7b..5b821d43f8 100644 --- a/test/files/jvm/innerClassAttribute/Classes_1.scala +++ b/test/files/jvm/innerClassAttribute/Classes_1.scala @@ -13,7 +13,7 @@ object A3 { class A4 { def f(l: List[String]): List[String] = { - l map (_ + "1") + l map (_ + "1") : @noinline // inlining adds a reference to the nested class scala/collection/generic/GenTraversableFactory$GenericCanBuildFrom } } @@ -274,8 +274,8 @@ object NestedInValueClass { class A(val arg: String) extends AnyVal { // A has InnerClass entries for the two closures (and for A and A$). not for B / C def f = { - def g = List().map(x => ((s: String) => x)) // outer class A, no outer method (g is moved to the companion, doesn't exist in A) - g.map(x => ((s: String) => x)) // outer class A, outer method f + def g = List().map(x => ((s: String) => x)): @noinline // outer class A, no outer method (g is moved to the companion, doesn't exist in A) + g.map(x => ((s: String) => x)): @noinline // outer class A, outer method f } // statements and field declarations are not allowed in value classes } diff --git a/test/files/jvm/innerClassAttribute/Test.scala b/test/files/jvm/innerClassAttribute/Test.scala index 702e5e279a..903d08f72d 100644 --- a/test/files/jvm/innerClassAttribute/Test.scala +++ b/test/files/jvm/innerClassAttribute/Test.scala @@ -23,7 +23,7 @@ object Test extends BytecodeTest { def testInner(cls: String, fs: (InnerClassNode => Unit)*) = { val ns = innerClassNodes(cls) - assert(ns.length == fs.length, ns) + assert(ns.length == fs.length, ns.map(_.name)) (ns zip fs.toList) foreach { case (n, f) => f(n) } } diff --git a/test/files/neg/t9535.check b/test/files/neg/t9535.check new file mode 100644 index 0000000000..5c3e3ea8e6 --- /dev/null +++ b/test/files/neg/t9535.check @@ -0,0 +1,7 @@ +t9535.scala:4: error: not found: type E1 + @throws[E1] def f[E1 <: Exception] = 1 + ^ +t9535.scala:6: error: class type required but E found + @throws(classOf[E]) def g: E = ??? // neg test: classOf requires class type + ^ +two errors found diff --git a/test/files/neg/t9535.scala b/test/files/neg/t9535.scala new file mode 100644 index 0000000000..37253804ce --- /dev/null +++ b/test/files/neg/t9535.scala @@ -0,0 +1,7 @@ +class C[E <: Exception] { + // cannot be expressed in Scala (it's allowed in Java) + // https://issues.scala-lang.org/browse/SI-7066 + @throws[E1] def f[E1 <: Exception] = 1 + + @throws(classOf[E]) def g: E = ??? // neg test: classOf requires class type +} diff --git a/test/files/run/repl-paste-5.check b/test/files/run/repl-paste-5.check new file mode 100644 index 0000000000..8b97b8888d --- /dev/null +++ b/test/files/run/repl-paste-5.check @@ -0,0 +1,28 @@ + +scala> :paste < EOF +// Entering paste mode (EOF to finish) + +class C { def c = 42 } +EOF + +// Exiting paste mode, now interpreting. + +defined class C + +scala> new C().c +res0: Int = 42 + +scala> :paste <| EOF +// Entering paste mode (EOF to finish) + + |class D { def d = 42 } +EOF + +// Exiting paste mode, now interpreting. + +defined class D + +scala> new D().d +res1: Int = 42 + +scala> :quit diff --git a/test/files/run/repl-paste-5.scala b/test/files/run/repl-paste-5.scala new file mode 100644 index 0000000000..890f47f141 --- /dev/null +++ b/test/files/run/repl-paste-5.scala @@ -0,0 +1,18 @@ + +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + //def code = ":paste < EOF\n" + ( + def code = + """ +:paste < EOF +class C { def c = 42 } +EOF +new C().c +:paste <| EOF + |class D { def d = 42 } +EOF +new D().d + """ + //) +} diff --git a/test/files/run/stringinterpolation_macro-run.check b/test/files/run/stringinterpolation_macro-run.check deleted file mode 100644 index c7f46bac87..0000000000 --- a/test/files/run/stringinterpolation_macro-run.check +++ /dev/null @@ -1,71 +0,0 @@ -false -false -true -false -true -FALSE -FALSE -TRUE -FALSE -TRUE -true -false -null -0 -80000000 -4c01926 -NULL -4C01926 -null -NULL -Scala -SCALA -5 -x -x -x -x -x -x -x -x -x -x -x -x -S -120 -120 -120 -120 -120 -120 -120 -120 -120 -120 -120 -120 - 0X4 -She is 4 feet tall. -120 -42 -3.400000e+00 -3.400000e+00 -3.400000e+00 -3.400000e+00 -3.400000e+00 -3.400000e+00 -3.000000e+00 -3.000000e+00 -05/26/12 -05/26/12 -05/26/12 -05/26/12 -% - mind ------- -matter - -7 7 9 -7 9 9 diff --git a/test/files/run/stringinterpolation_macro-run.scala b/test/files/run/stringinterpolation_macro-run.scala deleted file mode 100644 index ae7c0e5d7a..0000000000 --- a/test/files/run/stringinterpolation_macro-run.scala +++ /dev/null @@ -1,122 +0,0 @@ -/* - * filter: inliner warnings; re-run with - */ -object Test extends App { - -// 'b' / 'B' (category: general) -// ----------------------------- -println(f"${null}%b") -println(f"${false}%b") -println(f"${true}%b") -println(f"${new java.lang.Boolean(false)}%b") -println(f"${new java.lang.Boolean(true)}%b") - -println(f"${null}%B") -println(f"${false}%B") -println(f"${true}%B") -println(f"${new java.lang.Boolean(false)}%B") -println(f"${new java.lang.Boolean(true)}%B") - -implicit val stringToBoolean = java.lang.Boolean.parseBoolean(_: String) -println(f"${"true"}%b") -println(f"${"false"}%b") - -// 'h' | 'H' (category: general) -// ----------------------------- -println(f"${null}%h") -println(f"${0.0}%h") -println(f"${-0.0}%h") -println(f"${"Scala"}%h") - -println(f"${null}%H") -println(f"${"Scala"}%H") - -// 's' | 'S' (category: general) -// ----------------------------- -println(f"${null}%s") -println(f"${null}%S") -println(f"${"Scala"}%s") -println(f"${"Scala"}%S") -println(f"${5}") - -// 'c' | 'C' (category: character) -// ------------------------------- -println(f"${120:Char}%c") -println(f"${120:Byte}%c") -println(f"${120:Short}%c") -println(f"${120:Int}%c") -println(f"${new java.lang.Character('x')}%c") -println(f"${new java.lang.Byte(120:Byte)}%c") -println(f"${new java.lang.Short(120:Short)}%c") -println(f"${new java.lang.Integer(120)}%c") - -println(f"${'x' : java.lang.Character}%c") -println(f"${(120:Byte) : java.lang.Byte}%c") -println(f"${(120:Short) : java.lang.Short}%c") -println(f"${120 : java.lang.Integer}%c") - -implicit val stringToChar = (x: String) => x(0) -println(f"${"Scala"}%c") - -// 'd' | 'o' | 'x' | 'X' (category: integral) -// ------------------------------------------ -println(f"${120:Byte}%d") -println(f"${120:Short}%d") -println(f"${120:Int}%d") -println(f"${120:Long}%d") -println(f"${new java.lang.Byte(120:Byte)}%d") -println(f"${new java.lang.Short(120:Short)}%d") -println(f"${new java.lang.Integer(120)}%d") -println(f"${new java.lang.Long(120)}%d") -println(f"${120 : java.lang.Integer}%d") -println(f"${120 : java.lang.Long}%d") -println(f"${BigInt(120)}%d") -println(f"${new java.math.BigInteger("120")}%d") -println(f"${4}%#10X") - -locally { - val fff = new java.util.Formattable { - def formatTo(f: java.util.Formatter, g: Int, w: Int, p: Int) = f.format("4") - } - println(f"She is ${fff}%#s feet tall.") -} - -{ - implicit val strToShort = (s: String) => java.lang.Short.parseShort(s) - println(f"${"120"}%d") - implicit val strToInt = (s: String) => 42 - println(f"${"120"}%d") -} - -// 'e' | 'E' | 'g' | 'G' | 'f' | 'a' | 'A' (category: floating point) -// ------------------------------------------------------------------ -println(f"${3.4f}%e") -println(f"${3.4}%e") -println(f"${3.4f : java.lang.Float}%e") -println(f"${3.4 : java.lang.Double}%e") -println(f"${BigDecimal(3.4)}%e") -println(f"${new java.math.BigDecimal(3.4)}%e") -println(f"${3}%e") -println(f"${3L}%e") - -// 't' | 'T' (category: date/time) -// ------------------------------- -import java.util.Calendar -import java.util.Locale -val c = Calendar.getInstance(Locale.US) -c.set(2012, Calendar.MAY, 26) -println(f"${c}%TD") -println(f"${c.getTime}%TD") -println(f"${c.getTime.getTime}%TD") - -implicit val strToDate = (x: String) => c -println(f"""${"1234"}%TD""") - - -// literals and arg indexes -println(f"%%") -println(f" mind%n------%nmatter%n") -println(f"${7}%d %<d ${9}%d") -println(f"${7}%d %2$$d ${9}%d") - -} diff --git a/test/files/run/t9535.scala b/test/files/run/t9535.scala new file mode 100644 index 0000000000..62e156e456 --- /dev/null +++ b/test/files/run/t9535.scala @@ -0,0 +1,22 @@ +class C[E <: Exception] { + @throws[E] def f = 1 + + @throws(classOf[Exception]) def g: E = ??? + + @throws[E] @throws[Exception] def h = 1 +} + +object Test extends App { + val c = classOf[C[_]] + def sig(method: String) = c.getDeclaredMethod(method).toString + def genSig(method: String) = c.getDeclaredMethod(method).toGenericString + + assert(sig("f") == "public int C.f() throws java.lang.Exception") + assert(genSig("f") == "public int C.f() throws E") + + assert(sig("g") == "public java.lang.Exception C.g() throws java.lang.Exception") + assert(genSig("g") == "public E C.g() throws java.lang.Exception") + + assert(sig("h") == "public int C.h() throws java.lang.Exception,java.lang.Exception") + assert(genSig("h") == "public int C.h() throws E,java.lang.Exception") +} |