diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/name-lookup-stable.check | 2 | ||||
-rw-r--r-- | test/files/neg/name-lookup-stable.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t5376.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t8597b.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t8675b.scala | 2 | ||||
-rw-r--r-- | test/files/neg/virtpatmat_exhaust_compound.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t2405.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t8002-nested-scope.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t9442.scala | 14 | ||||
-rw-r--r-- | test/files/run/dead-code-elimination.scala | 2 | ||||
-rw-r--r-- | test/files/run/names-defaults.scala | 2 | ||||
-rw-r--r-- | test/files/run/nothingTypeNoOpt.scala | 2 | ||||
-rw-r--r-- | test/files/run/repl-power.check | 3 | ||||
-rw-r--r-- | test/files/run/repl-power.scala | 5 | ||||
-rw-r--r-- | test/files/run/t8047.scala | 2 | ||||
-rw-r--r-- | test/files/run/toolbox_expand_macro.check | 1 | ||||
-rw-r--r-- | test/files/run/toolbox_expand_macro.scala | 23 | ||||
-rw-r--r-- | test/junit/scala/collection/immutable/SetTests.scala | 81 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala | 2 |
19 files changed, 140 insertions, 15 deletions
diff --git a/test/files/neg/name-lookup-stable.check b/test/files/neg/name-lookup-stable.check index 751df9505e..68d98c4162 100644 --- a/test/files/neg/name-lookup-stable.check +++ b/test/files/neg/name-lookup-stable.check @@ -6,6 +6,6 @@ import ColumnOption._ name-lookup-stable.scala:17: error: reference to PrimaryKey is ambiguous; it is both defined in class A and imported subsequently by import ColumnOption._ - PrimaryKey // was already ambigious in 2.10.3 + PrimaryKey // was already ambiguous in 2.10.3 ^ two errors found diff --git a/test/files/neg/name-lookup-stable.scala b/test/files/neg/name-lookup-stable.scala index 0d862f06e1..2941e05875 100644 --- a/test/files/neg/name-lookup-stable.scala +++ b/test/files/neg/name-lookup-stable.scala @@ -14,7 +14,7 @@ class A { (null: Any) match { case PrimaryKey => } - PrimaryKey // was already ambigious in 2.10.3 + PrimaryKey // was already ambiguous in 2.10.3 } } diff --git a/test/files/neg/t5376.scala b/test/files/neg/t5376.scala index 8da3868566..b1ba41bd54 100644 --- a/test/files/neg/t5376.scala +++ b/test/files/neg/t5376.scala @@ -12,7 +12,7 @@ object Test { "a": Int } - // Import one implict and one non-implicit method with the + // Import one implicit and one non-implicit method with the // same name in the same scope. def m2 = { import O1._ diff --git a/test/files/neg/t8597b.scala b/test/files/neg/t8597b.scala index b29d591cb1..cbf0bf1c5a 100644 --- a/test/files/neg/t8597b.scala +++ b/test/files/neg/t8597b.scala @@ -4,7 +4,7 @@ object Unchecked { // t is a fresh pattern type variable, despite our attempts to // backtick our way to the enclosing `t`. Under this interpretation, - // the absense of an unchecked warning is expected. + // the absence of an unchecked warning is expected. (null: Any) match { case _: Some[t] => // no warn } diff --git a/test/files/neg/t8675b.scala b/test/files/neg/t8675b.scala index bffed2141c..b2212fa234 100644 --- a/test/files/neg/t8675b.scala +++ b/test/files/neg/t8675b.scala @@ -9,7 +9,7 @@ object Test { } trait Reportable1[Params, R] - // "missing paramater type" error was swallowed in 2.11.0 leading to a crash + // "missing parameter type" error was swallowed in 2.11.0 leading to a crash // in the backend. // // This error is itself a regression (or at least a change) in 2.11.0-M7, diff --git a/test/files/neg/virtpatmat_exhaust_compound.scala b/test/files/neg/virtpatmat_exhaust_compound.scala index 386c7af98d..4ff04dd06a 100644 --- a/test/files/neg/virtpatmat_exhaust_compound.scala +++ b/test/files/neg/virtpatmat_exhaust_compound.scala @@ -10,7 +10,7 @@ case object O3 extends Base2 case object O4 extends Base with Base2 object Test { - val a /*: Product with Serialiable with Base */ = if (true) O1 else O2 + val a /*: Product with Serializable with Base */ = if (true) O1 else O2 a match { case null => } diff --git a/test/files/pos/t2405.scala b/test/files/pos/t2405.scala index 224b2ce83b..0bc7a771b2 100644 --- a/test/files/pos/t2405.scala +++ b/test/files/pos/t2405.scala @@ -6,14 +6,14 @@ object Test1 { implicitly[Int] } -// Testing for the absense of shadowing #1. +// Testing for the absence of shadowing #1. object Test2 { import A.{x => y} val x = 2 implicitly[Int] } -// Testing for the absense of shadowing #2. +// Testing for the absence of shadowing #2. object Test3 { { import A.{x => y} diff --git a/test/files/pos/t8002-nested-scope.scala b/test/files/pos/t8002-nested-scope.scala index a2088bce7a..8ce809e556 100644 --- a/test/files/pos/t8002-nested-scope.scala +++ b/test/files/pos/t8002-nested-scope.scala @@ -1,5 +1,5 @@ // This test serves to capture the status quo, but should really -// emit an accessibiltiy error. +// emit an accessibility error. // `Namers#companionSymbolOf` seems too lenient, and currently doesn't // implement the same-scope checks mentioned: diff --git a/test/files/pos/t9442.scala b/test/files/pos/t9442.scala new file mode 100644 index 0000000000..2ea81e79cb --- /dev/null +++ b/test/files/pos/t9442.scala @@ -0,0 +1,14 @@ +trait Ctx { + trait Tree +} +trait Lst[+A] { + def zip[A1 >: A, B](that: Lst[B]): Nothing +} +class C[@specialized(Int) T] { + def moo(t: T) = { + def foo1(c: Ctx)(l: Lst[c.Tree]) = l zip l + def foo2(c: Ctx)(l: Lst[c.Tree]*) = l(0) zip l(1) + def foo3(c: Ctx)(l: => Lst[c.Tree]) = l zip l + ??? + } +} diff --git a/test/files/run/dead-code-elimination.scala b/test/files/run/dead-code-elimination.scala index fd3f2a996a..2291b22f7a 100644 --- a/test/files/run/dead-code-elimination.scala +++ b/test/files/run/dead-code-elimination.scala @@ -10,7 +10,7 @@ // the stack after code elimination. // // Originally, this did not compile, but I included it in the run -// tests because this was ASM-dependand and did not happen for GenJVM. +// tests because this was ASM-dependent and did not happen for GenJVM. // // Thus, we run the code and force the loading of class B -- if the // bytecode is incorrect, it will fail the test. diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 7fb4a04546..4159dbdf91 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -192,7 +192,7 @@ object Test extends App { println(argName) // should be 4 test5 { argName = 5 } println(argName) // should be 5 - val a: Unit = test1(a = 10, b = "2") // local values a and b exist, but not ambiuous since they're val's + val a: Unit = test1(a = 10, b = "2") // local values a and b exist, but it's not ambiguous since they're vals // dependent types and copy method diff --git a/test/files/run/nothingTypeNoOpt.scala b/test/files/run/nothingTypeNoOpt.scala index 5c5a20fa3b..454539a4b1 100644 --- a/test/files/run/nothingTypeNoOpt.scala +++ b/test/files/run/nothingTypeNoOpt.scala @@ -26,7 +26,7 @@ class C { } def f5(x: Boolean) = { - // stack heights need to be the smae. ??? looks to the jvm like returning a value of + // stack heights need to be the same. ??? looks to the jvm like returning a value of // type Nothing$, need to drop or throw it. println( if (x) { ???; 10 } diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 2a7b7783d9..4e030bd9fa 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -25,4 +25,7 @@ m: $r.treedsl.global.Literal = 10 scala> typed(m).tpe // typed is in scope res2: $r.treedsl.global.Type = Int(10) +scala> """escaping is hard, m'kah""" +res3: String = escaping is hard, m'kah + scala> :quit diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala index 4dfeb37885..5ecaad8723 100644 --- a/test/files/run/repl-power.scala +++ b/test/files/run/repl-power.scala @@ -1,7 +1,9 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - def code = """ + def tripleQuote(s: String) = "\"\"\"" + s + "\"\"\"" + + def code = s""" :power // guarding against "error: reference to global is ambiguous" global.emptyValDef // "it is imported twice in the same scope by ..." @@ -9,5 +11,6 @@ val tp = ArrayClass[scala.util.Random] // magic with tags tp.memberType(Array_apply) // evidence val m = LIT(10) // treedsl typed(m).tpe // typed is in scope +${tripleQuote("escaping is hard, m'kah")} """.trim } diff --git a/test/files/run/t8047.scala b/test/files/run/t8047.scala index f5660541e8..9ec8c1dc56 100644 --- a/test/files/run/t8047.scala +++ b/test/files/run/t8047.scala @@ -1,7 +1,7 @@ object Test extends App { import scala.reflect.runtime.universe._ // - // x's owner is outer Test scope. Previosly the quasiquote expansion + // x's owner is outer Test scope. Previously the quasiquote expansion // looked like: // // object Test { diff --git a/test/files/run/toolbox_expand_macro.check b/test/files/run/toolbox_expand_macro.check new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/test/files/run/toolbox_expand_macro.check @@ -0,0 +1 @@ +42 diff --git a/test/files/run/toolbox_expand_macro.scala b/test/files/run/toolbox_expand_macro.scala new file mode 100644 index 0000000000..a52e449168 --- /dev/null +++ b/test/files/run/toolbox_expand_macro.scala @@ -0,0 +1,23 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.{ToolBox} + +object Test extends App { + val toolBox = cm.mkToolBox() + val x = 21 + val runtimeMacro = + q"""object RuntimeMacro { + import scala.reflect.macros.whitebox.Context + import scala.language.experimental.macros + + def add(y: Int): Int = macro addImpl + def addImpl(c: Context)(y: c.Expr[Int]): c.Expr[Int] = { + import c.universe._ + val x = $x + c.Expr[Int](q"$$x + $$y") + } + }""" + val s = toolBox.define(runtimeMacro) + println(toolBox.eval(q"$s.add(21)")) +} diff --git a/test/junit/scala/collection/immutable/SetTests.scala b/test/junit/scala/collection/immutable/SetTests.scala new file mode 100644 index 0000000000..28c7864359 --- /dev/null +++ b/test/junit/scala/collection/immutable/SetTests.scala @@ -0,0 +1,81 @@ +package scala.collection.immutable + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class SetTests { + @Test + def test_SI8346_toSet_soundness(): Unit = { + val any2stringadd = "Disabled string conversions so as not to get confused!" + + def any[A](set: Set[A]): Set[Any] = { + val anyset = set.toSet[Any] + assert((anyset + "fish") contains "fish") + anyset + } + + // Make sure default immutable Set does not rebuild itself on widening with toSet + // Need to cover 0, 1, 2, 3, 4 elements as special cases + var si = Set.empty[Int] + assert(si eq si.toSet[Any]) + for (i <- 1 to 5) { + val s1 = Set(Array.range(1, i+1): _*) + val s2 = si + i + val s1a = any(s1) + val s2a = any(s2) + assert(s1 eq s1a) + assert(s2 eq s2a) + si = s2 + } + + // Make sure BitSet correctly rebuilds itself on widening with toSet + // Need to cover empty, values 0-63, values 0-127 as special cases + val bitsets = Seq(BitSet.empty, BitSet(23), BitSet(23, 99), BitSet(23, 99, 141)) + bitsets.foreach{ b => + val ba = any(b) + assert(b ne ba) + assertEquals(b, ba) + } + + // Make sure HashSet (and by extension, its implementing class HashTrieSet) + // does not rebuild itself on widening by toSet + val hashset = HashSet(1, 3, 5, 7) + val hashseta = any(hashset) + assert(hashset eq hashseta) + + // Make sure ListSet does not rebuild itself on widening by toSet + // (Covers Node also, since it subclasses ListSet) + val listset = ListSet(1, 3, 5, 7) + val listseta = any(listset) + assert(listset eq listseta) + + // Make sure SortedSets correctly rebuild themselves on widening with toSet + // Covers TreeSet and keySet of SortedMap also + val sortedsets = Seq( + SortedSet.empty[Int], SortedSet(5), SortedSet(1,2,3,5,4), + SortedMap(1 -> "cod", 2 -> "herring").keySet + ) + sortedsets.foreach{ set => + val seta = any(set) + assert(set ne seta) + assertEquals(set, seta) + } + + // Make sure ValueSets correctly rebuild themselves on widening with toSet + object WeekDay extends Enumeration { + type WeekDay = Value + val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value + } + val valuesa = any(WeekDay.values) + assert(WeekDay.values ne valuesa) + assertEquals(WeekDay.values, valuesa) + + // Make sure regular Map keySets do not rebuild themselves on widening with toSet + val mapset = Map(1 -> "cod", 2 -> "herring").keySet + val mapseta = any(mapset) + assert(mapset eq mapseta) + } +} diff --git a/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala index a5b3faced8..941a167114 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerTest.scala @@ -204,7 +204,7 @@ class ProdConsAnalyzerTest extends ClearAfterClass { def iincProdCons(): Unit = { import Opcodes._ val m = genMethod(descriptor = "(I)I")( - Incr(IINC, 1, 1), // producer and cosumer of local variable 1 + Incr(IINC, 1, 1), // producer and consumer of local variable 1 VarOp(ILOAD, 1), Op(IRETURN) ) |