diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/adding-growing-set.scala | 11 | ||||
-rw-r--r-- | test/files/run/bug3004.scala | 14 | ||||
-rw-r--r-- | test/files/run/bug3327.check | 1 | ||||
-rw-r--r-- | test/files/run/bug3327.scala | 8 | ||||
-rw-r--r-- | test/files/run/distinct.check | 1 | ||||
-rw-r--r-- | test/files/run/distinct.scala | 15 | ||||
-rw-r--r-- | test/files/run/iterator-iterate-lazy.scala | 5 | ||||
-rw-r--r-- | test/files/run/mapValues.scala | 8 | ||||
-rw-r--r-- | test/files/run/names-defaults.scala | 21 | ||||
-rw-r--r-- | test/files/run/spec-early.check | 4 | ||||
-rw-r--r-- | test/files/run/spec-early.scala | 15 | ||||
-rw-r--r-- | test/files/run/spec-init.check | 9 | ||||
-rw-r--r-- | test/files/run/spec-init.scala | 41 | ||||
-rw-r--r-- | test/files/run/stream_length.scala | 15 | ||||
-rw-r--r-- | test/files/run/stringbuilder.scala | 8 | ||||
-rw-r--r-- | test/files/run/treePrint.scala | 2 |
16 files changed, 177 insertions, 1 deletions
diff --git a/test/files/run/adding-growing-set.scala b/test/files/run/adding-growing-set.scala new file mode 100644 index 0000000000..5903813ed1 --- /dev/null +++ b/test/files/run/adding-growing-set.scala @@ -0,0 +1,11 @@ +/** This will run a a loooong time if Set's builder copies a + * complete new Set for every element. + */ +object Test { + def main(args: Array[String]): Unit = { + val a = new Array[Long](1000000) + (1 to 10000) foreach (i => a(i) = i) + val s = collection.mutable.Set(a: _*) + assert(s.sum > 0) + } +} diff --git a/test/files/run/bug3004.scala b/test/files/run/bug3004.scala new file mode 100644 index 0000000000..a1e9c6c72f --- /dev/null +++ b/test/files/run/bug3004.scala @@ -0,0 +1,14 @@ +object MyClass { + val duplicate: Int = 10 +} + +class MyClass { + private val duplicate = MyClass.duplicate +} + +object Test { + def main(args: Array[String]): Unit = { + val x = new MyClass + () + } +} diff --git a/test/files/run/bug3327.check b/test/files/run/bug3327.check new file mode 100644 index 0000000000..980a0d5f19 --- /dev/null +++ b/test/files/run/bug3327.check @@ -0,0 +1 @@ +Hello World! diff --git a/test/files/run/bug3327.scala b/test/files/run/bug3327.scala new file mode 100644 index 0000000000..7e6d3fc210 --- /dev/null +++ b/test/files/run/bug3327.scala @@ -0,0 +1,8 @@ +object Test { + def main (args : Array[String]) { + val b = new StringBuilder + b.append ("Hello World!") + b.lastIndexOf ('e') + println (b.toString) + } +}
\ No newline at end of file diff --git a/test/files/run/distinct.check b/test/files/run/distinct.check new file mode 100644 index 0000000000..b0883f382e --- /dev/null +++ b/test/files/run/distinct.check @@ -0,0 +1 @@ +abcdefghijklmnopqrstuvwxyz diff --git a/test/files/run/distinct.scala b/test/files/run/distinct.scala new file mode 100644 index 0000000000..698d31f1e9 --- /dev/null +++ b/test/files/run/distinct.scala @@ -0,0 +1,15 @@ +/** This is a test to make sure distinct always + * returns the first of any duplicated element. + */ +object Test { + val alphabet = 'a' to 'z' mkString "" + val alphaList = 'a' to 'z' toList + def shuffled = util.Random.shuffle(alphaList) + + def main(args: Array[String]): Unit = { + val longList = alphaList ++ (1 to 9 flatMap (_ => shuffled)) + val result = longList.distinct mkString "" + + println(result) + } +} diff --git a/test/files/run/iterator-iterate-lazy.scala b/test/files/run/iterator-iterate-lazy.scala new file mode 100644 index 0000000000..73886f192b --- /dev/null +++ b/test/files/run/iterator-iterate-lazy.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + Iterator.iterate(1 to 5 toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList + } +} diff --git a/test/files/run/mapValues.scala b/test/files/run/mapValues.scala new file mode 100644 index 0000000000..d3266bd18f --- /dev/null +++ b/test/files/run/mapValues.scala @@ -0,0 +1,8 @@ +object Test { + val m = Map(1 -> 1, 2 -> 2) + val mv = (m mapValues identity) - 1 + + def main(args: Array[String]): Unit = { + assert(mv.size == 1) + } +} diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 3442ecafc3..ee9186c35f 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -324,6 +324,27 @@ object Test extends Application { } } + // #3344 + def m3344_1 = { case class C(x: Int); C(1).copy(2).x } + m3344_1 + def m3344_2 = { class C(val x: Int = 1); new C().x } + m3344_2 + + // #3338 + object t3338 { + class Container { + class GenericClass[T](arg: String = "") + } + + object Container extends Container + + class Test { + val a = new Container.GenericClass() + } + } + (new t3338.Test).a + + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) diff --git a/test/files/run/spec-early.check b/test/files/run/spec-early.check new file mode 100644 index 0000000000..414aacc419 --- /dev/null +++ b/test/files/run/spec-early.check @@ -0,0 +1,4 @@ +a +abc +42 +abc diff --git a/test/files/run/spec-early.scala b/test/files/run/spec-early.scala new file mode 100644 index 0000000000..84a8983f8c --- /dev/null +++ b/test/files/run/spec-early.scala @@ -0,0 +1,15 @@ +trait Tr + +class Foo[@specialized(Int) T](_x: T) extends { + val bar = "abc" + val baz = "bbc" +} with Tr { + val x = _x + println(x) + println(bar) +} + +object Test extends Application { + new Foo("a") + new Foo(42) +} diff --git a/test/files/run/spec-init.check b/test/files/run/spec-init.check new file mode 100644 index 0000000000..8a659f868c --- /dev/null +++ b/test/files/run/spec-init.check @@ -0,0 +1,9 @@ +abc +abc +null +shouldn't see two initialized values and one uninitialized +42 +42 +0 +ok +ok diff --git a/test/files/run/spec-init.scala b/test/files/run/spec-init.scala new file mode 100644 index 0000000000..bd3428f4ea --- /dev/null +++ b/test/files/run/spec-init.scala @@ -0,0 +1,41 @@ +class Foo[@specialized(Int) T](_x: T) { + val x = _x + def bar {} + + val y = x + println(x) + println(y) + println(z) + + def baz {} + val z = y + +} + +class Bar[@specialized(Int) T] { + def foo(x: T) = print(x) +} + +object Global { + var msg = "ok" +} + +class TouchGlobal[@specialized(Int) T](_x: T) { + println(Global.msg) + val x = { + Global.msg = "not ok" + _x + } +} + +object Test { + def main(args: Array[String]) { + (new Foo("abc")) + println("shouldn't see two initialized values and one uninitialized") + (new Foo(42)) + + (new TouchGlobal(new Object)) + Global.msg = "ok" // reset the value + (new TouchGlobal(42)) + } +} diff --git a/test/files/run/stream_length.scala b/test/files/run/stream_length.scala new file mode 100644 index 0000000000..68e9cad5ac --- /dev/null +++ b/test/files/run/stream_length.scala @@ -0,0 +1,15 @@ + + +object Test { + def walk(depth: Int, bias: String): Stream[String] = { + if (depth == 0) + Stream(bias) + else { + Stream.concat(Stream.range(1, 100).map((x: Int) => walk(depth-1, bias + x))) + } + } + + def main(args: Array[String]) { + println("Length: " + walk(3, "---").length) + } +} diff --git a/test/files/run/stringbuilder.scala b/test/files/run/stringbuilder.scala index c669f1c3db..28ddc653a5 100644 --- a/test/files/run/stringbuilder.scala +++ b/test/files/run/stringbuilder.scala @@ -1,5 +1,7 @@ object Test extends Application { val str = "ABCDEFGHIJKLMABCDEFGHIJKLM" + val surrogateStr = "an old Turkic letter: \uD803\uDC22" + type SB = { def indexOf(str: String): Int def indexOf(str: String, fromIndex: Int): Int @@ -29,4 +31,10 @@ object Test extends Application { sameAnswers(_.lastIndexOf("QZV")) sameAnswers(_.lastIndexOf("GHI", 22)) sameAnswers(_.lastIndexOf("KLM", 22)) + + // testing that the "reverse" implementation avoids reversing surrogate pairs + val jsb = new JavaStringBuilder(surrogateStr) reverse + val ssb = new ScalaStringBuilder(surrogateStr) reverseContents ; + + assert(jsb.toString == ssb.toString) } diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala index ffe9a392d4..1fd1394e25 100644 --- a/test/files/run/treePrint.scala +++ b/test/files/run/treePrint.scala @@ -35,6 +35,6 @@ object Test { val repl = new Interpreter(settings, new PrintWriter(new NullOutputStream)) repl.interpret("""def initialize = "Have to interpret something or we get errors." """) - println(repl mkTree code) + println(repl.power mkTree code) } } |