summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/WeakHashSetTest.scala174
-rw-r--r--test/files/run/duration-coarsest.scala28
-rw-r--r--test/files/run/literals.check2
-rw-r--r--test/files/run/richs.check1
-rw-r--r--test/files/run/t5313.scala2
-rw-r--r--test/files/run/t7151.check6
-rw-r--r--test/files/run/t7151.scala24
-rw-r--r--test/files/run/t7439.check2
-rw-r--r--test/files/run/t7439/A_1.java3
-rw-r--r--test/files/run/t7439/B_1.java3
-rw-r--r--test/files/run/t7439/Test_2.scala32
-rw-r--r--test/files/run/t7569.check12
-rw-r--r--test/files/run/t7569.scala19
-rw-r--r--test/files/run/tailcalls.check56
-rw-r--r--test/files/run/tailcalls.scala2
15 files changed, 189 insertions, 177 deletions
diff --git a/test/files/run/WeakHashSetTest.scala b/test/files/run/WeakHashSetTest.scala
deleted file mode 100644
index 3c8f380150..0000000000
--- a/test/files/run/WeakHashSetTest.scala
+++ /dev/null
@@ -1,174 +0,0 @@
-object Test {
- def main(args: Array[String]) {
- val test = scala.reflect.internal.util.WeakHashSetTest
- test.checkEmpty
- test.checkPlusEquals
- test.checkPlusEqualsCollisions
- test.checkRehashing
- test.checkRehashCollisions
- test.checkFindOrUpdate
- test.checkMinusEquals
- test.checkMinusEqualsCollisions
- test.checkClear
- test.checkIterator
- test.checkIteratorCollisions
-
- // This test is commented out because it relies on gc behavior which isn't reliable enough in an automated environment
- // test.checkRemoveUnreferencedObjects
- }
-}
-
-// put the main test object in the same package as WeakHashSet because
-// it uses the package private "diagnostics" method
-package scala.reflect.internal.util {
-
- object WeakHashSetTest {
- // a class guaranteed to provide hash collisions
- case class Collider(x : String) extends Comparable[Collider] with Serializable {
- override def hashCode = 0
- def compareTo(y : Collider) = this.x compareTo y.x
- }
-
- // basic emptiness check
- def checkEmpty {
- val hs = new WeakHashSet[String]()
- assert(hs.size == 0)
- hs.diagnostics.fullyValidate
- }
-
- // make sure += works
- def checkPlusEquals {
- val hs = new WeakHashSet[String]()
- val elements = List("hello", "goodbye")
- elements foreach (hs += _)
- assert(hs.size == 2)
- assert(hs contains "hello")
- assert(hs contains "goodbye")
- hs.diagnostics.fullyValidate
- }
-
- // make sure += works when there are collisions
- def checkPlusEqualsCollisions {
- val hs = new WeakHashSet[Collider]()
- val elements = List("hello", "goodbye") map Collider
- elements foreach (hs += _)
- assert(hs.size == 2)
- assert(hs contains Collider("hello"))
- assert(hs contains Collider("goodbye"))
- hs.diagnostics.fullyValidate
- }
-
- // add a large number of elements to force rehashing and then validate
- def checkRehashing {
- val size = 200
- val hs = new WeakHashSet[String]()
- val elements = (0 until size).toList map ("a" + _)
- elements foreach (hs += _)
- elements foreach {i => assert(hs contains i)}
- hs.diagnostics.fullyValidate
- }
-
- // make sure rehashing works properly when the set is rehashed
- def checkRehashCollisions {
- val size = 200
- val hs = new WeakHashSet[Collider]()
- val elements = (0 until size).toList map {x => Collider("a" + x)}
- elements foreach (hs += _)
- elements foreach {i => assert(hs contains i)}
- hs.diagnostics.fullyValidate
- }
-
- // test that unreferenced objects are removed
- // not run in an automated environment because gc behavior can't be relied on
- def checkRemoveUnreferencedObjects {
- val size = 200
- val hs = new WeakHashSet[Collider]()
- val elements = (0 until size).toList map {x => Collider("a" + x)}
- elements foreach (hs += _)
- // don't throw the following into a retained collection so gc
- // can remove them
- for (i <- 0 until size) {
- hs += Collider("b" + i)
- }
- System.gc()
- Thread.sleep(1000)
- assert(hs.size == 200)
- elements foreach {i => assert(hs contains i)}
- for (i <- 0 until size) {
- assert(!(hs contains Collider("b" + i)))
- }
- hs.diagnostics.fullyValidate
- }
-
- // make sure findOrUpdate returns the originally entered element
- def checkFindOrUpdate {
- val size = 200
- val hs = new WeakHashSet[Collider]()
- val elements = (0 until size).toList map {x => Collider("a" + x)}
- elements foreach {x => assert(hs findEntryOrUpdate x eq x)}
- for (i <- 0 until size) {
- // when we do a lookup the result should be the same reference we
- // original put in
- assert(hs findEntryOrUpdate(Collider("a" + i)) eq elements(i))
- }
- hs.diagnostics.fullyValidate
- }
-
- // check -= functionality
- def checkMinusEquals {
- val hs = new WeakHashSet[String]()
- val elements = List("hello", "goodbye")
- elements foreach (hs += _)
- hs -= "goodbye"
- assert(hs.size == 1)
- assert(hs contains "hello")
- assert(!(hs contains "goodbye"))
- hs.diagnostics.fullyValidate
- }
-
- // check -= when there are collisions
- def checkMinusEqualsCollisions {
- val hs = new WeakHashSet[Collider]
- val elements = List(Collider("hello"), Collider("goodbye"))
- elements foreach (hs += _)
- hs -= Collider("goodbye")
- assert(hs.size == 1)
- assert(hs contains Collider("hello"))
- assert(!(hs contains Collider("goodbye")))
- hs -= Collider("hello")
- assert(hs.size == 0)
- assert(!(hs contains Collider("hello")))
- hs.diagnostics.fullyValidate
- }
-
- // check that the clear method actually cleans everything
- def checkClear {
- val size = 200
- val hs = new WeakHashSet[String]()
- val elements = (0 until size).toList map ("a" + _)
- elements foreach (hs += _)
- hs.clear()
- assert(hs.size == 0)
- elements foreach {i => assert(!(hs contains i))}
- hs.diagnostics.fullyValidate
- }
-
- // check that the iterator covers all the contents
- def checkIterator {
- val hs = new WeakHashSet[String]()
- val elements = (0 until 20).toList map ("a" + _)
- elements foreach (hs += _)
- assert(elements.iterator.toList.sorted == elements.sorted)
- hs.diagnostics.fullyValidate
- }
-
- // check that the iterator covers all the contents even when there is a collision
- def checkIteratorCollisions {
- val hs = new WeakHashSet[Collider]
- val elements = (0 until 20).toList map {x => Collider("a" + x)}
- elements foreach (hs += _)
- assert(elements.iterator.toList.sorted == elements.sorted)
- hs.diagnostics.fullyValidate
- }
- }
-}
diff --git a/test/files/run/duration-coarsest.scala b/test/files/run/duration-coarsest.scala
new file mode 100644
index 0000000000..51cb79287a
--- /dev/null
+++ b/test/files/run/duration-coarsest.scala
@@ -0,0 +1,28 @@
+import scala.concurrent.duration._
+import scala.language.postfixOps
+
+object Test extends App {
+ List(
+ (60 minutes, 1 hour),
+ (2000 millis, 2 seconds),
+ (2000 micros, 2 millis),
+ (2000 nanos, 2 micros),
+ (2000000 nanos, 2 millis),
+ (48 hours, 2 days),
+ (5 seconds, 5 seconds),
+ (1 second, 1 second)
+ ) foreach {
+ case (x, expected) =>
+ val actual = x.toCoarsest
+ assert(actual.unit == expected.unit, s"$actual, $expected")
+ assert(actual.length == expected.length, s"$actual, $expected")
+ }
+
+ List(
+ 45 minutes,
+ 500 millis,
+ 1500 millis,
+ 23 hours,
+ 40 days
+ ) foreach (x => assert(x == x.toCoarsest, x))
+} \ No newline at end of file
diff --git a/test/files/run/literals.check b/test/files/run/literals.check
index 6be5137994..5f948762b7 100644
--- a/test/files/run/literals.check
+++ b/test/files/run/literals.check
@@ -1,4 +1,4 @@
-warning: there were 13 deprecation warning(s); re-run with -deprecation for details
+warning: there were 18 deprecation warning(s); re-run with -deprecation for details
test '\u0024' == '$' was successful
test '\u005f' == '_' was successful
test 65.asInstanceOf[Char] == 'A' was successful
diff --git a/test/files/run/richs.check b/test/files/run/richs.check
index a970a814b1..02a98b376d 100644
--- a/test/files/run/richs.check
+++ b/test/files/run/richs.check
@@ -1,3 +1,4 @@
+warning: there were 2 deprecation warning(s); re-run with -deprecation for details
RichCharTest1:
true
diff --git a/test/files/run/t5313.scala b/test/files/run/t5313.scala
index 7da8726a1f..febfd9c3ed 100644
--- a/test/files/run/t5313.scala
+++ b/test/files/run/t5313.scala
@@ -7,7 +7,7 @@ object Test extends IcodeTest {
override def code =
"""class Foo {
- def randomBoolean = util.Random.nextInt % 2 == 0
+ def randomBoolean = scala.util.Random.nextInt % 2 == 0
def bar = {
var kept1 = new Object
val result = new java.lang.ref.WeakReference(kept1)
diff --git a/test/files/run/t7151.check b/test/files/run/t7151.check
new file mode 100644
index 0000000000..d532d9589f
--- /dev/null
+++ b/test/files/run/t7151.check
@@ -0,0 +1,6 @@
+class Test$InnerObject$ isFinal = false
+class Test$InnerCase isFinal = true
+class Test$InnerNonCase isFinal = true
+class TopLevelObject$ isFinal = true
+class TopLevelCase isFinal = true
+class TopLevelNonCase isFinal = true
diff --git a/test/files/run/t7151.scala b/test/files/run/t7151.scala
new file mode 100644
index 0000000000..f6492ba43c
--- /dev/null
+++ b/test/files/run/t7151.scala
@@ -0,0 +1,24 @@
+import java.lang.reflect.Modifier.isFinal
+
+object Test {
+ object InnerObject
+ final case class InnerCase()
+ final class InnerNonCase()
+
+ def main(args: Array[String]) {
+ def checkFinal(clazz: Class[_]) =
+ println(s"${clazz} isFinal = ${isFinal(clazz.getModifiers())}")
+
+ checkFinal(InnerObject.getClass)
+ checkFinal(classOf[InnerCase])
+ checkFinal(classOf[InnerNonCase])
+
+ checkFinal(TopLevelObject.getClass)
+ checkFinal(classOf[TopLevelCase])
+ checkFinal(classOf[TopLevelNonCase])
+ }
+}
+
+object TopLevelObject
+final case class TopLevelCase()
+final case class TopLevelNonCase()
diff --git a/test/files/run/t7439.check b/test/files/run/t7439.check
new file mode 100644
index 0000000000..9ea09f9c40
--- /dev/null
+++ b/test/files/run/t7439.check
@@ -0,0 +1,2 @@
+Recompiling after deleting t7439-run.obj/A_1.class
+pos: NoPosition Class A_1 not found - continuing with a stub. WARNING
diff --git a/test/files/run/t7439/A_1.java b/test/files/run/t7439/A_1.java
new file mode 100644
index 0000000000..4accd95d57
--- /dev/null
+++ b/test/files/run/t7439/A_1.java
@@ -0,0 +1,3 @@
+public class A_1 {
+
+} \ No newline at end of file
diff --git a/test/files/run/t7439/B_1.java b/test/files/run/t7439/B_1.java
new file mode 100644
index 0000000000..5dd3b93d6f
--- /dev/null
+++ b/test/files/run/t7439/B_1.java
@@ -0,0 +1,3 @@
+public class B_1 {
+ public void b(A_1[] a) {}
+}
diff --git a/test/files/run/t7439/Test_2.scala b/test/files/run/t7439/Test_2.scala
new file mode 100644
index 0000000000..3ebbcfe753
--- /dev/null
+++ b/test/files/run/t7439/Test_2.scala
@@ -0,0 +1,32 @@
+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 C = """
+ class C {
+ new B_1
+ }
+ """
+
+ def show(): Unit = {
+ //compileCode(C)
+ assert(filteredInfos.isEmpty, filteredInfos)
+
+ // blow away the entire package
+ val a1Class = new File(testOutput.path, "A_1.class")
+ assert(a1Class.exists)
+ assert(a1Class.delete())
+ println(s"Recompiling after deleting $a1Class")
+
+ // bad symbolic reference error expected (but no stack trace!)
+ compileCode(C)
+ println(storeReporter.infos.mkString("\n")) // Included a NullPointerException before.
+ }
+}
diff --git a/test/files/run/t7569.check b/test/files/run/t7569.check
new file mode 100644
index 0000000000..98513c3ab2
--- /dev/null
+++ b/test/files/run/t7569.check
@@ -0,0 +1,12 @@
+source-newSource1.scala,line-3,offset=49 A.this.one
+source-newSource1.scala,line-3,offset=49 A.this
+source-newSource1.scala,line-4,offset=67 A.super.<init>()
+source-newSource1.scala,line-4,offset=67 A.super.<init>
+source-newSource1.scala,line-4,offset=67 this
+source-newSource1.scala,line-3,offset=49 A.this.one
+source-newSource1.scala,line-3,offset=49 A.this
+RangePosition(newSource1.scala, 55, 57, 65) scala.Int.box(1).toString()
+RangePosition(newSource1.scala, 55, 57, 65) scala.Int.box(1).toString
+RangePosition(newSource1.scala, 55, 55, 56) scala.Int.box(1)
+NoPosition scala.Int.box
+NoPosition scala.Int
diff --git a/test/files/run/t7569.scala b/test/files/run/t7569.scala
new file mode 100644
index 0000000000..b1b1443a18
--- /dev/null
+++ b/test/files/run/t7569.scala
@@ -0,0 +1,19 @@
+import scala.tools.partest._
+object Test extends CompilerTest {
+ import global._
+ override def extraSettings = super.extraSettings + " -Yrangepos"
+ override def sources = List(
+ """|import scala.language.postfixOps
+ |class A {
+ | val one = 1 toString
+ |}""".stripMargin
+ )
+ def check(source: String, unit: CompilationUnit) {
+ for (ClassDef(_, _, _, Template(_, _, stats)) <- unit.body ; stat <- stats ; t <- stat) {
+ t match {
+ case _: Select | _ : Apply | _:This => println("%-15s %s".format(t.pos.toString, t))
+ case _ =>
+ }
+ }
+ }
+}
diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check
index f123bc8f25..10384ac46e 100644
--- a/test/files/run/tailcalls.check
+++ b/test/files/run/tailcalls.check
@@ -1,3 +1,4 @@
+#partest !avian
test Object .f was successful
test Final .f was successful
test Class .f raised exception java.lang.StackOverflowError
@@ -51,3 +52,58 @@ test TailCall.b2 was successful
test FancyTailCalls.tcTryLocal was successful
test FancyTailCalls.differentInstance was successful
test PolyObject.tramp was successful
+
+#partest avian
+test Object .f was successful
+test Final .f was successful
+test Class .f was successful
+test SubClass .f was successful
+test Sealed .f was successful
+test SubSealed.f was successful
+
+test O .f was successful
+test c .f was successful
+test O.O .f was successful
+test O.c .f was successful
+test c.O .f was successful
+test c.c .f was successful
+test O.O.O .f was successful
+test O.O.c .f was successful
+test O.c.O .f was successful
+test O.c.c .f was successful
+test c.O.O .f was successful
+test c.O.c .f was successful
+test c.c.O .f was successful
+test c.c.c .f was successful
+test O.O.O.O.f was successful
+test O.O.O.c.f was successful
+test O.O.c.O.f was successful
+test O.O.c.c.f was successful
+test O.c.O.O.f was successful
+test O.c.O.c.f was successful
+test O.c.c.O.f was successful
+test O.c.c.c.f was successful
+test c.O.O.O.f was successful
+test c.O.O.c.f was successful
+test c.O.c.O.f was successful
+test c.O.c.c.f was successful
+test c.c.O.O.f was successful
+test c.c.O.c.f was successful
+test c.c.c.O.f was successful
+test c.c.c.c.f was successful
+
+test TailCall.f1 was successful
+test TailCall.f2 was successful
+test TailCall.f3 was successful
+test TailCall.g1 was successful
+test TailCall.g2 was successful
+test TailCall.g3 was successful
+test TailCall.h1 was successful
+
+test NonTailCall.f1 0 1 2 was successful
+test NonTailCall.f2
+test TailCall.b1 was successful
+test TailCall.b2 was successful
+test FancyTailCalls.tcTryLocal was successful
+test FancyTailCalls.differentInstance was successful
+test PolyObject.tramp was successful \ No newline at end of file
diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala
index 7d06a7e69d..1d4124e138 100644
--- a/test/files/run/tailcalls.scala
+++ b/test/files/run/tailcalls.scala
@@ -307,7 +307,7 @@ object Test {
def main(args: Array[String]) {
// compute min and max iteration number
val min = 16;
- val max = calibrate;
+ val max = if (scala.tools.partest.utils.Properties.isAvian) 10000 else calibrate
// test tail calls in different contexts
val Final = new Final()