diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/delambdafy_t6028.check | 12 | ||||
-rw-r--r-- | test/files/run/t6028.check | 12 | ||||
-rw-r--r-- | test/files/run/t9110.scala | 27 | ||||
-rw-r--r-- | test/files/run/trait-defaults-modules.scala | 20 | ||||
-rw-r--r-- | test/files/run/trait-defaults-modules2/T_1.scala | 4 | ||||
-rw-r--r-- | test/files/run/trait-defaults-modules2/Test_2.scala | 5 | ||||
-rw-r--r-- | test/files/run/trait-defaults-modules3.scala | 8 | ||||
-rw-r--r-- | test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala | 2 | ||||
-rw-r--r-- | test/junit/scala/util/SystemPropertiesTest.scala | 27 |
9 files changed, 112 insertions, 5 deletions
diff --git a/test/files/run/delambdafy_t6028.check b/test/files/run/delambdafy_t6028.check index 885fc3c9f3..c8c4b1cb4c 100644 --- a/test/files/run/delambdafy_t6028.check +++ b/test/files/run/delambdafy_t6028.check @@ -38,10 +38,18 @@ package <empty> { <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer }; - final <stable> private[this] def MethodLocalObject$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { - MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); + final <stable> private[this] def MethodLocalObject$lzycompute$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { + T.this.synchronized({ + if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); + scala.runtime.BoxedUnit.UNIT + }); MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() }; + final <stable> private[this] def MethodLocalObject$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + T.this.MethodLocalObject$lzycompute$1(barParam$1, MethodLocalObject$module$1) + else + MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type](); abstract trait MethodLocalTrait$1$class extends Object with T#MethodLocalTrait$1 { def /*MethodLocalTrait$1$class*/$init$(barParam$1: String): Unit = { () diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index a768f32976..b3d20a9902 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -50,10 +50,18 @@ package <empty> { <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer }; - final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { - MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); + final <stable> private[this] def MethodLocalObject$lzycompute$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { + T.this.synchronized({ + if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); + scala.runtime.BoxedUnit.UNIT + }); MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() }; + final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + T.this.MethodLocalObject$lzycompute$1(barParam$1, MethodLocalObject$module$1) + else + MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type](); abstract trait MethodLocalTrait$1$class extends Object with T#MethodLocalTrait$1 { def /*MethodLocalTrait$1$class*/$init$(barParam$1: Int): Unit = { () diff --git a/test/files/run/t9110.scala b/test/files/run/t9110.scala new file mode 100644 index 0000000000..660291a4d1 --- /dev/null +++ b/test/files/run/t9110.scala @@ -0,0 +1,27 @@ +trait Event + +trait Domain { + case class Created(name: String) extends Event +} + +// declare three instances of Domain trait, one here and two +// in an inner scope + +object DomainC extends Domain + +object Test { + def main(args: Array[String]) { + object DomainA extends Domain + object DomainB extends Domain + + def lookingForAs(event: Event): Unit = { + event match { + case DomainB.Created(_) => throw null + case DomainC.Created(_) => throw null + case DomainA.Created(_) => // okay + } + } + + lookingForAs(DomainA.Created("I am an A")) + } +} diff --git a/test/files/run/trait-defaults-modules.scala b/test/files/run/trait-defaults-modules.scala new file mode 100644 index 0000000000..93fc74baff --- /dev/null +++ b/test/files/run/trait-defaults-modules.scala @@ -0,0 +1,20 @@ +trait T1 { def a: Any } + +trait T2 extends T1 { object a; object b; private object c; def usec: Any = c} +trait T3 extends T2 + +class C1 extends T1 { object a; object b } +class C2 extends C1 +class C3 extends T2 +class C4 extends T3 + +object Test { + def main(args: Array[String]): Unit = { + val (c1, c2, c3, c4) = (new C1, new C2, new C3, new C4) + c1.a; c1.b; (c1: T1).a + c2.a; c2.b; (c2: T1).a + c3.a; c3.b; (c3: T1).a; c3.usec + c4.a; c4.b; (c4: T1).a; c4.usec + } + +} diff --git a/test/files/run/trait-defaults-modules2/T_1.scala b/test/files/run/trait-defaults-modules2/T_1.scala new file mode 100644 index 0000000000..962acdade1 --- /dev/null +++ b/test/files/run/trait-defaults-modules2/T_1.scala @@ -0,0 +1,4 @@ +trait T { + private object O + def useO: Any = O +} diff --git a/test/files/run/trait-defaults-modules2/Test_2.scala b/test/files/run/trait-defaults-modules2/Test_2.scala new file mode 100644 index 0000000000..a1c49f5ddd --- /dev/null +++ b/test/files/run/trait-defaults-modules2/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends T { + def main(args: Array[String]): Unit = { + useO + } +} diff --git a/test/files/run/trait-defaults-modules3.scala b/test/files/run/trait-defaults-modules3.scala new file mode 100644 index 0000000000..8790a95f4c --- /dev/null +++ b/test/files/run/trait-defaults-modules3.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + object O + val x = O + val y = O + assert(x eq y) + } +} diff --git a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala index f490d9490a..a80d1a27a1 100644 --- a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala @@ -27,7 +27,7 @@ class ParallelRangeCheck(val tasksupport: TaskSupport) extends ParallelSeqCheck[ def isCheckingViews = false - def ofSize(vals: Seq[Gen[Int]], sz: Int) = unsupported + def ofSize(vals: Seq[Gen[Int]], sz: Int) = throw new UnsupportedOperationException override def instances(vals: Seq[Gen[Int]]): Gen[Seq[Int]] = sized { start => sized { end => diff --git a/test/junit/scala/util/SystemPropertiesTest.scala b/test/junit/scala/util/SystemPropertiesTest.scala new file mode 100644 index 0000000000..38e830eb88 --- /dev/null +++ b/test/junit/scala/util/SystemPropertiesTest.scala @@ -0,0 +1,27 @@ +package scala.util + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test +import org.junit.Assert._ + +@RunWith(classOf[JUnit4]) +class SystemPropertiesTest { + @Test + def filterAll(): Unit = { + val isEmpty = sys.props.filter(_ => false).size == 0 + assertTrue("A filter matching nothing should produce an empty result", isEmpty) + } + + @Test + def filterNone(): Unit = { + val isUnchanged = sys.props.filter(_ => true) == sys.props + assertTrue("A filter matching everything should not change the result", isUnchanged) + } + + @Test + def empty(): Unit = { + val hasSize0 = sys.props.empty.size == 0 + assertTrue("SystemProperties.empty should have size of 0", hasSize0) + } +} |