diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/double-def-top-level.check | 7 | ||||
-rw-r--r-- | test/files/neg/double-def-top-level/A_1.scala | 4 | ||||
-rw-r--r-- | test/files/neg/double-def-top-level/B_2.scala | 2 | ||||
-rw-r--r-- | test/files/neg/double-def-top-level/C_3.scala | 2 | ||||
-rw-r--r-- | test/files/neg/double-def-top-level/D_3.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t8617.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t8617.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t8625.scala | 5 | ||||
-rw-r--r-- | test/files/run/analyzerPlugins.check | 13 | ||||
-rw-r--r-- | test/files/run/t8346.check | 6 | ||||
-rw-r--r-- | test/files/run/t8346.scala | 34 | ||||
-rw-r--r-- | test/files/run/t8607.scala | 36 | ||||
-rw-r--r-- | test/junit/scala/collection/IteratorTest.scala | 20 | ||||
-rw-r--r-- | test/junit/scala/reflect/internal/ScopeTest.scala | 54 |
14 files changed, 188 insertions, 8 deletions
diff --git a/test/files/neg/double-def-top-level.check b/test/files/neg/double-def-top-level.check new file mode 100644 index 0000000000..85b16e81e5 --- /dev/null +++ b/test/files/neg/double-def-top-level.check @@ -0,0 +1,7 @@ +D_3.scala:1: error: C is already defined as class C +class C + ^ +D_3.scala:2: error: O is already defined as object O +object O + ^ +two errors found diff --git a/test/files/neg/double-def-top-level/A_1.scala b/test/files/neg/double-def-top-level/A_1.scala new file mode 100644 index 0000000000..c3d68d9d05 --- /dev/null +++ b/test/files/neg/double-def-top-level/A_1.scala @@ -0,0 +1,4 @@ +package p + +class C +object O diff --git a/test/files/neg/double-def-top-level/B_2.scala b/test/files/neg/double-def-top-level/B_2.scala new file mode 100644 index 0000000000..c328e8c964 --- /dev/null +++ b/test/files/neg/double-def-top-level/B_2.scala @@ -0,0 +1,2 @@ +class C /* noerror */ +object O /* noerror */
\ No newline at end of file diff --git a/test/files/neg/double-def-top-level/C_3.scala b/test/files/neg/double-def-top-level/C_3.scala new file mode 100644 index 0000000000..e1c327c15a --- /dev/null +++ b/test/files/neg/double-def-top-level/C_3.scala @@ -0,0 +1,2 @@ +class C +object O
\ No newline at end of file diff --git a/test/files/neg/double-def-top-level/D_3.scala b/test/files/neg/double-def-top-level/D_3.scala new file mode 100644 index 0000000000..518e0d1c54 --- /dev/null +++ b/test/files/neg/double-def-top-level/D_3.scala @@ -0,0 +1,2 @@ +class C +object O diff --git a/test/files/pos/t8617.flags b/test/files/pos/t8617.flags new file mode 100644 index 0000000000..281f0a10cd --- /dev/null +++ b/test/files/pos/t8617.flags @@ -0,0 +1 @@ +-Yrangepos diff --git a/test/files/pos/t8617.scala b/test/files/pos/t8617.scala new file mode 100644 index 0000000000..fc825bbcba --- /dev/null +++ b/test/files/pos/t8617.scala @@ -0,0 +1,10 @@ +object Test { + def foo[A] = implicitly[OptManifest[A]] // was "unpositioned tree" under -Yrangepos + + // These did not crash, but testing for good measure. + implicitly[OptManifest[String]] + implicitly[Manifest[String]] + + implicitly[reflect.ClassTag[String]] + implicitly[reflect.runtime.universe.TypeTag[String]] +} diff --git a/test/files/pos/t8625.scala b/test/files/pos/t8625.scala new file mode 100644 index 0000000000..95c4b0dbcd --- /dev/null +++ b/test/files/pos/t8625.scala @@ -0,0 +1,5 @@ +object Test { + def f1(a: Boolean, b: Boolean) = (a || ???) && (b || ???) + def f2(a: Boolean, b: Boolean) = (a || ???) && b + def f3(a: Boolean, b: Boolean) = (a && ???) || b +} diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index e3ab554d4c..9803465ddc 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -19,7 +19,7 @@ canAdaptAnnotations(Trees$Typed, Any) [1] canAdaptAnnotations(Trees$Typed, Int) [1] lub(List(Int @testAnn, Int)) [1] pluginsPt(?, Trees$Annotated) [7] -pluginsPt(?, Trees$Apply) [9] +pluginsPt(?, Trees$Apply) [8] pluginsPt(?, Trees$ApplyImplicitView) [2] pluginsPt(?, Trees$Assign) [7] pluginsPt(?, Trees$Block) [4] @@ -31,13 +31,13 @@ pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [48] +pluginsPt(?, Trees$Select) [47] pluginsPt(?, Trees$Super) [2] pluginsPt(?, Trees$This) [20] -pluginsPt(?, Trees$TypeApply) [4] +pluginsPt(?, Trees$TypeApply) [3] pluginsPt(?, Trees$TypeBoundsTree) [2] pluginsPt(?, Trees$TypeDef) [1] -pluginsPt(?, Trees$TypeTree) [39] +pluginsPt(?, Trees$TypeTree) [38] pluginsPt(?, Trees$Typed) [1] pluginsPt(?, Trees$ValDef) [21] pluginsPt(Any, Trees$Literal) [2] @@ -98,7 +98,6 @@ pluginsTyped(()String, Trees$Ident) [1] pluginsTyped(()String, Trees$TypeApply) [1] pluginsTyped(()scala.annotation.Annotation, Trees$Select) [1] pluginsTyped(()testAnn, Trees$Select) [10] -pluginsTyped(()type, Trees$TypeApply) [1] pluginsTyped((str: String)A <and> (param: Double)A, Trees$Select) [1] pluginsTyped((x$1: Any)Boolean <and> (x: Double)Boolean <and> (x: Float)Boolean <and> (x: Long)Boolean <and> (x: Int)Boolean <and> (x: Char)Boolean <and> (x: Short)Boolean <and> (x: Byte)Boolean, Trees$Select) [1] pluginsTyped((x$1: Int)Unit, Trees$Select) [1] @@ -173,7 +172,7 @@ pluginsTyped(Unit, Trees$Literal) [5] pluginsTyped(Unit, Trees$TypeTree) [1] pluginsTyped([A](xs: A*)List[A], Trees$Select) [1] pluginsTyped([T <: Int]=> Int, Trees$Select) [1] -pluginsTyped([T0]()T0, Trees$Select) [2] +pluginsTyped([T0]()T0, Trees$Select) [1] pluginsTyped([T](xs: Array[T])scala.collection.mutable.WrappedArray[T], Trees$Select) [1] pluginsTyped(annotation.type, Trees$Select) [4] pluginsTyped(math.type, Trees$Select) [9] @@ -190,7 +189,5 @@ pluginsTyped(testAnn, Trees$New) [5] pluginsTyped(testAnn, Trees$This) [1] pluginsTyped(testAnn, Trees$TypeTree) [2] pluginsTyped(testAnn.super.type, Trees$Super) [1] -pluginsTyped(type, Trees$Apply) [1] pluginsTyped(type, Trees$Select) [1] -pluginsTyped(type, Trees$TypeTree) [1] pluginsTypedReturn(return f, String) [1] diff --git a/test/files/run/t8346.check b/test/files/run/t8346.check new file mode 100644 index 0000000000..1ba5c31abe --- /dev/null +++ b/test/files/run/t8346.check @@ -0,0 +1,6 @@ +BitSet: List(invariant, invariant, invariant, invariant) +HashSet: List(covariant (true), covariant (true), covariant (true), covariant (true)) +ListSet: List(covariant (true), covariant (true), covariant (true), covariant (true)) +SortedSet: List(invariant, invariant, invariant, invariant) +TreeSet: List(invariant, invariant, invariant, invariant) +ValueSet: invariant diff --git a/test/files/run/t8346.scala b/test/files/run/t8346.scala new file mode 100644 index 0000000000..5f3df84174 --- /dev/null +++ b/test/files/run/t8346.scala @@ -0,0 +1,34 @@ +object Test extends App { + import reflect.ClassTag + + object SomeEnum extends Enumeration { + val one, two, three, four = Value + } + + def sctor[A <: Set[Int]](f: Int => A)(implicit A: ClassTag[A]) + : (String, Int => Set[Int]) = + (A.runtimeClass.getSimpleName, f) + + val inits: Seq[(String, Int => Set[Int])] = { + import collection.immutable.{Seq => _, _} + Seq(sctor(BitSet(_)), + sctor(HashSet(_)), + sctor(ListSet(_)), + sctor(SortedSet(_)), + sctor(TreeSet(_))) + } + + def sVarInfo[A](sa: Set[A]): String = { + val saa = sa.toSet[Any] + if (sa eq saa) s"""covariant (${(saa + "hi") contains "hi"})""" + else "invariant" + } + + inits foreach {case (name, singleton) => + print(s"${name}: ") + val one = singleton(1) + println(Seq(2,3,4).scanLeft(one)(_ + _) map sVarInfo toList) + } + + println(s"ValueSet: ${sVarInfo(SomeEnum.values)}") +} diff --git a/test/files/run/t8607.scala b/test/files/run/t8607.scala new file mode 100644 index 0000000000..1b8ef9bbd0 --- /dev/null +++ b/test/files/run/t8607.scala @@ -0,0 +1,36 @@ +package p1 { + private[p1] trait B extends Any { + def a: Any = "" + } + + class C(val value: Int) extends AnyVal with B { + // def b = "" + } +} + +object Test { + def main(args: Array[String]) { + val c = new p1.C(42) + c.a + /* + new p1.C.<init>( + c.$asInstanceOf[scala.this.Int]() + ).a(); + + + new p1.C.<init>( + new p1.C.<init>( + c.$asInstanceOf[scala.this.Int]() + ).$asInstanceOf[ErasedValueType(class C, scala.this.Int)]() + .$asInstanceOf[scala.this.Int]() + ).a(); + + new p1.C.<init>( + new p1.C.<init>(c) + .$asInstanceOf[scala.this.Int]() + .$asInstanceOf[scala.this.Int]() + ).a(); + + */ + } +} diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala new file mode 100644 index 0000000000..cb7cbb40bc --- /dev/null +++ b/test/junit/scala/collection/IteratorTest.scala @@ -0,0 +1,20 @@ + +package scala.collection + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class IteratorTest { + + @Test + def groupedIteratorShouldNotAskForUnneededElement(): Unit = { + var counter = 0 + val it = new Iterator[Int] { var i = 0 ; def hasNext = { counter = i; true } ; def next = { i += 1; i } } + val slidingIt = it sliding 2 + slidingIt.next + assertEquals("Counter should be one, that means we didn't look further than needed", 1, counter) + } +} diff --git a/test/junit/scala/reflect/internal/ScopeTest.scala b/test/junit/scala/reflect/internal/ScopeTest.scala new file mode 100644 index 0000000000..5166620189 --- /dev/null +++ b/test/junit/scala/reflect/internal/ScopeTest.scala @@ -0,0 +1,54 @@ +package symtab + +import scala.tools.nsc.symtab + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +import scala.tools.testing.AssertUtil.assertThrows +import scala.tools.nsc.symtab.SymbolTableForUnitTesting + +@RunWith(classOf[JUnit4]) +class ScopeTest { + object symbolTable extends SymbolTableForUnitTesting + + import symbolTable._ + + @Test + def testNestedScopeSmall(): Unit = testNestedScope(0) + @Test + def testNestedScopeLarge(): Unit = testNestedScope(64) // exceeding MIN_HASH + + private def testNestedScope(initSize: Int) { + def sym(termName: String): Symbol = NoSymbol.newValue(TermName(termName)) + val foo = sym("foo") + val bar = sym("bar") + + val outerElems = List.tabulate(initSize)(i => sym(i.toString)) + val outer = newScopeWith(outerElems ++ List(foo, bar) : _*) + assertTrue(outer.containsName(foo.name)) + assertTrue(outer.containsName(bar.name)) + + val baz = sym("baz") + val nested = newNestedScope(outer) + + // Entries from the outer scope are entered in the nested. + assertTrue(outer.containsName(foo.name)) + assertTrue(outer.containsName(bar.name)) + + // Nested scopes structurally share ScopeEntry-s with the outer. + assertSame(outer.lookupEntry(foo.name), nested.lookupEntry(foo.name)) + nested.enter(baz) + + // Symbols entered in the nested scope aren't visible in the outer. + assertTrue(nested.containsName(baz.name)) + assertTrue(!outer.containsName(baz.name)) + + // Unlinking a symbol in the inner scope doesn't modify the outer + nested.unlink(bar) + assert(!nested.containsName(bar.name)) + assert(outer.containsName(bar.name)) + } +} |