summaryrefslogtreecommitdiff
path: root/test/disabled
diff options
context:
space:
mode:
Diffstat (limited to 'test/disabled')
-rw-r--r--test/disabled/presentation/simple-tests/SimpleInteractiveTest.scala11
-rw-r--r--test/disabled/presentation/simple-tests/src/Tester.scala204
-rw-r--r--test/disabled/run/bug4279.scala38
-rw-r--r--test/disabled/script/fact.args1
-rwxr-xr-xtest/disabled/script/fact.bat17
-rw-r--r--test/disabled/script/fact.check1
-rwxr-xr-xtest/disabled/script/fact.scala30
-rwxr-xr-xtest/disabled/script/second.bat3
-rw-r--r--test/disabled/script/second.check1
-rwxr-xr-xtest/disabled/script/second.scala3
-rwxr-xr-xtest/disabled/script/t1015.bat12
-rwxr-xr-xtest/disabled/script/t1015.scala26
-rwxr-xr-xtest/disabled/script/t1017.bat15
-rwxr-xr-xtest/disabled/script/t1017.scala29
14 files changed, 391 insertions, 0 deletions
diff --git a/test/disabled/presentation/simple-tests/SimpleInteractiveTest.scala b/test/disabled/presentation/simple-tests/SimpleInteractiveTest.scala
new file mode 100644
index 0000000000..014fd24b6f
--- /dev/null
+++ b/test/disabled/presentation/simple-tests/SimpleInteractiveTest.scala
@@ -0,0 +1,11 @@
+import scala.tools.nsc.interactive.tests._
+
+/** Simple test that shows how to use the InteractiveTest class. It uses the
+ * inherited runTest method that runs completion and typedAt tests on all
+ * sources found under src/
+ */
+object Test extends InteractiveTest {
+ override val runRandomTests = false
+// settings.YpresentationDebug.value = true
+// override val synchronousRequests = false
+}
diff --git a/test/disabled/presentation/simple-tests/src/Tester.scala b/test/disabled/presentation/simple-tests/src/Tester.scala
new file mode 100644
index 0000000000..cb62187514
--- /dev/null
+++ b/test/disabled/presentation/simple-tests/src/Tester.scala
@@ -0,0 +1,204 @@
+package scala.tools.nsc
+package interactive
+package tests
+
+import util._
+import reporters._
+import io.AbstractFile
+import collection.mutable.ArrayBuffer
+
+class Tester(ntests: Int, inputs: Array[SourceFile], settings: Settings) {
+
+ val reporter = new StoreReporter
+ val compiler = new Global(settings, reporter)
+
+ def askAndListen[T, U](msg: String, arg: T, op: (T, Response[U]) => Unit) {
+ if (settings.verbose./*!*/value) print(msg+" "+arg+": ")
+ val TIMEOUT = 10 // ms
+ val limit/*?*/ = System.currentTimeMillis() + randomDelayMillis
+ val res/*?*/ = new Response[U]
+ op(arg, res)
+ while (!res.isComplete && !res.isCancelled) {
+ if (System.currentTimeMillis() > limit) {
+ print("c"); res./*!*/cancel()
+ } else res.get(TIMEOUT) match {
+ case Some(Left(t)) =>
+ /**/
+ if (settings./*!*/verbose.value) println(t)
+ case Some(Right(ex)) =>
+ ex.printStackTrace()
+ println(ex)
+ case None =>
+ }
+ }
+ }
+
+ def askReload(sfs: SourceFile*) = askAndListen("reload", sfs.toList, compiler.askReload)
+ def askTypeAt(pos: Position) = askAndListen("type at", pos, compiler.askTypeAt)
+ def askTypeCompletion(pos: Position) = askAndListen("type at", pos, compiler.askTypeCompletion)
+ def askScopeCompletion(pos: Position) = askAndListen("type at", pos, compiler.askScopeCompletion)
+
+ val rand = new java.util.Random()
+
+ private def randomInverse(n: Int) = n / (rand.nextInt(n) + 1)
+
+ private def randomDecreasing(n: Int) = {
+ var r = rand.nextInt((1 to n).sum)
+ var limit = n
+ var result = 0
+ while (r > limit) {
+ result += 1
+ r -= limit
+ limit -= 1
+ }
+ result
+ }
+
+ def randomSourceFileIdx() = rand.nextInt(inputs.length)
+
+ def randomBatchesPerSourceFile(): Int = randomDecreasing(100)
+
+ def randomChangesPerBatch(): Int = randomInverse(50)
+
+ def randomPositionIn(sf: SourceFile) = rand.nextInt(sf.content.length)
+
+ def randomNumChars() = randomInverse(100)
+
+ def randomDelayMillis = randomInverse(10000)
+
+ class Change(sfidx: Int, start: Int, nchars: Int, toLeft: Boolean) {
+
+ private var pos = start
+ private var deleted: List[Char] = List()
+
+ override def toString =
+ "In "+inputs(sfidx)+" at "+start+" take "+nchars+" to "+
+ (if (toLeft) "left" else "right")
+
+ def deleteOne() {
+ val sf = inputs(sfidx)
+ deleted = sf.content(pos) :: deleted
+ val sf1 = new BatchSourceFile(sf.file, sf.content.take(pos) ++ sf.content.drop(pos + 1))
+ inputs(sfidx) = sf1
+ askReload(sf1)
+ }
+
+ def deleteAll() {
+ print("/"+nchars)
+ for (i <- 0 until nchars) {
+ if (toLeft) {
+ if (pos > 0 && pos <= inputs(sfidx).length) {
+ pos -= 1
+ deleteOne()
+ }
+ } else {
+ if (pos < inputs(sfidx).length) {
+ deleteOne()
+ }
+ }
+ }
+ }
+
+ def insertAll() {
+ for (chr <- if (toLeft) deleted else deleted.reverse) {
+ val sf = inputs(sfidx)
+ val (pre, post) = sf./*!*/content splitAt pos
+ pos += 1
+ val sf1 = new BatchSourceFile(sf.file, pre ++ (chr +: post))
+ inputs(sfidx) = sf1
+ askReload(sf1)
+ }
+ }
+ }
+
+ val testComment = "/**/"
+
+ def testFileChanges(sfidx: Int) = {
+ lazy val testPositions: Seq[Int] = {
+ val sf = inputs(sfidx)
+ val buf = new ArrayBuffer[Int]
+ var pos = sf.content.indexOfSlice(testComment)
+ while (pos > 0) {
+ buf += pos
+ pos = sf.content.indexOfSlice(testComment, pos + 1)
+ }
+ buf
+ }
+ def otherTest() {
+ if (testPositions.nonEmpty) {
+ val pos = new OffsetPosition(inputs(sfidx), rand.nextInt(testPositions.length))
+ rand.nextInt(3) match {
+ case 0 => askTypeAt(pos)
+ case 1 => askTypeCompletion(pos)
+ case 2 => askScopeCompletion(pos)
+ }
+ }
+ }
+ for (i <- 0 until randomBatchesPerSourceFile()) {
+ val changes = Vector.fill(/**/randomChangesPerBatch()) {
+ /**/
+ new Change(sfidx, randomPositionIn(inputs(sfidx)), randomNumChars(), rand.nextBoolean())
+ }
+ doTest(sfidx, changes, testPositions, otherTest) match {
+ case Some(errortrace) =>
+ println(errortrace)
+ minimize(errortrace)
+ case None =>
+ }
+ }
+ }
+
+ def doTest(sfidx: Int, changes: Seq[Change], testPositions: Seq[Int], otherTest: () => Unit): Option[ErrorTrace] = {
+ print("new round with "+changes.length+" changes:")
+ changes foreach (_.deleteAll())
+ otherTest()
+ def errorCount() = compiler.ask(() => reporter.ERROR.count)
+// println("\nhalf test round: "+errorCount())
+ changes.view.reverse foreach (_.insertAll())
+ otherTest()
+ println("done test round: "+errorCount())
+ if (errorCount() != 0)
+ Some(ErrorTrace(sfidx, changes, reporter.infos, inputs(sfidx).content))
+ else
+ None
+ }
+
+ case class ErrorTrace(
+ sfidx: Int, changes: Seq[Change], infos: collection.Set[reporter.Info], content: Array[Char]) {
+ override def toString =
+ "Sourcefile: "+inputs(sfidx)+
+ "\nChanges:\n "+changes.mkString("\n ")+
+ "\nErrors:\n "+infos.mkString("\n ")+
+ "\nContents:\n"+content.mkString
+ }
+
+ def minimize(etrace: ErrorTrace) {}
+
+ /**/
+ def run() {
+ askReload(inputs: _*)
+ for (i <- 0 until ntests)
+ testFileChanges(randomSourceFileIdx())
+ }
+}
+
+/* A program to do presentation compiler stress tests.
+ * Usage:
+ *
+ * scala scala.tools.nsc.interactive.test.Tester <n> <files>
+ *
+ * where <n> is the number os tests to be run and <files> is the set of files to test.
+ * This will do random deletions and re-insertions in any of the files.
+ * At places where an empty comment /**/ appears it will in addition randomly
+ * do ask-types, type-completions, or scope-completions.
+ */
+object Tester {
+ def main(args: Array[String]) {
+ val settings = new Settings()
+ val (_, filenames) = settings.processArguments(args.toList.tail, true)
+ println("filenames = "+filenames)
+ val files = filenames.toArray map (str => new BatchSourceFile(AbstractFile.getFile(str)): SourceFile)
+ new Tester(args(0).toInt, files, settings).run()
+ sys.exit(0)
+ }
+}
diff --git a/test/disabled/run/bug4279.scala b/test/disabled/run/bug4279.scala
new file mode 100644
index 0000000000..d0afc3a032
--- /dev/null
+++ b/test/disabled/run/bug4279.scala
@@ -0,0 +1,38 @@
+import scala.tools.partest._
+
+// Attempting to verify slice isn't 100,000x slower
+// with views than non-views.
+class Runner(num: Int, reps: Int) extends TestUtil {
+ var dummy = 0
+ val range = Array.range(0, num)
+
+ def iteratorSlice = {
+ def it = range.iterator.slice(num - 2, num)
+ for (i <- 1 to reps)
+ it foreach (dummy = _)
+ }
+ def viewSlice = {
+ val view = range.view.slice(num - 2, num)
+ for (i <- 1 to reps)
+ view foreach (dummy = _)
+ }
+ def straightSlice = {
+ val xs = range.slice(num - 2, num)
+ for (i <- 1 to reps)
+ xs foreach (dummy = _)
+ }
+ def run(multiple: Double) = {
+ verifySpeed(straightSlice, iteratorSlice, multiple)
+ verifySpeed(straightSlice, viewSlice, multiple)
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ // warmup
+ { val r = new Runner(1000000, 10) ; r.straightSlice ; r.iteratorSlice ; r.viewSlice }
+
+ new Runner(10000000, 10) run 500
+ new Runner(10000000, 50) run 300
+ }
+}
diff --git a/test/disabled/script/fact.args b/test/disabled/script/fact.args
new file mode 100644
index 0000000000..7ed6ff82de
--- /dev/null
+++ b/test/disabled/script/fact.args
@@ -0,0 +1 @@
+5
diff --git a/test/disabled/script/fact.bat b/test/disabled/script/fact.bat
new file mode 100755
index 0000000000..bee0ba25c6
--- /dev/null
+++ b/test/disabled/script/fact.bat
@@ -0,0 +1,17 @@
+::#!
+:: fact - A simple Scala batch file that prints out the factorial
+:: of the argument specified on the command line.
+
+@echo off
+call scala -nocompdaemon %0 %*
+goto :eof
+::!#
+
+
+val x = argv(0).toInt
+
+def fact(x: Int):Int =
+ if(x==0) 1
+ else x*fact(x-1)
+
+Console.println("fact(" + x + ") = " + fact(x))
diff --git a/test/disabled/script/fact.check b/test/disabled/script/fact.check
new file mode 100644
index 0000000000..22aa60821e
--- /dev/null
+++ b/test/disabled/script/fact.check
@@ -0,0 +1 @@
+fact(5) = 120
diff --git a/test/disabled/script/fact.scala b/test/disabled/script/fact.scala
new file mode 100755
index 0000000000..d48dac6f0f
--- /dev/null
+++ b/test/disabled/script/fact.scala
@@ -0,0 +1,30 @@
+#!/bin/sh
+# fact - A simple Scala script that prints out the factorial of
+# the argument specified on the command line.
+
+cygwin=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+esac
+
+SOURCE="$0";
+if $cygwin; then
+ if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
+ format=mixed
+ else
+ format=windows
+ fi
+ SOURCE=`cygpath --$format "$SOURCE"`;
+fi
+
+exec scala -nocompdaemon "$SOURCE" "$@"
+!#
+
+
+val x = argv(0).toInt
+
+def fact(x: Int):Int =
+ if(x==0) 1
+ else x*fact(x-1)
+
+Console.println("fact(" + x + ") = " + fact(x))
diff --git a/test/disabled/script/second.bat b/test/disabled/script/second.bat
new file mode 100755
index 0000000000..0d7085954d
--- /dev/null
+++ b/test/disabled/script/second.bat
@@ -0,0 +1,3 @@
+@echo off
+
+scala -nocompdaemon -e "println(\"My second argument is \" + args(1))" arg1 arg2
diff --git a/test/disabled/script/second.check b/test/disabled/script/second.check
new file mode 100644
index 0000000000..a105b862a1
--- /dev/null
+++ b/test/disabled/script/second.check
@@ -0,0 +1 @@
+My second argument is arg2
diff --git a/test/disabled/script/second.scala b/test/disabled/script/second.scala
new file mode 100755
index 0000000000..48b8d73815
--- /dev/null
+++ b/test/disabled/script/second.scala
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+scala -nocompdaemon -e 'println("My second argument is " + args(1))' arg1 arg2
diff --git a/test/disabled/script/t1015.bat b/test/disabled/script/t1015.bat
new file mode 100755
index 0000000000..7475313d7e
--- /dev/null
+++ b/test/disabled/script/t1015.bat
@@ -0,0 +1,12 @@
+::#!
+:: t1015 - <description>.
+
+@echo off
+call scala -nocompdaemon %0 %*
+goto :eof
+::!#
+
+case class Test(one : Int, two : Int)
+object Test{
+ def apply(one : Int): Test = Test(one, 2);
+}
diff --git a/test/disabled/script/t1015.scala b/test/disabled/script/t1015.scala
new file mode 100755
index 0000000000..52d67bd6cc
--- /dev/null
+++ b/test/disabled/script/t1015.scala
@@ -0,0 +1,26 @@
+#!/bin/sh
+# fact - A simple Scala script that prints out the factorial of
+# the argument specified on the command line.
+
+cygwin=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+esac
+
+SOURCE="$0";
+if $cygwin; then
+ if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
+ format=mixed
+ else
+ format=windows
+ fi
+ SOURCE=`cygpath --$format "$SOURCE"`;
+fi
+
+exec scala -nocompdaemon "$SOURCE" "$@"
+!#
+
+case class Test(one : Int, two : Int)
+object Test{
+ def apply(one : Int): Test = Test(one, 2);
+}
diff --git a/test/disabled/script/t1017.bat b/test/disabled/script/t1017.bat
new file mode 100755
index 0000000000..369dbd2aca
--- /dev/null
+++ b/test/disabled/script/t1017.bat
@@ -0,0 +1,15 @@
+::#!
+::# t1017 - <description>.
+
+@echo off
+call scala -nocompdaemon %0 %*
+goto :eof
+::!#
+
+def foo = {
+ bar
+}
+
+var x = 1
+
+def bar = 1
diff --git a/test/disabled/script/t1017.scala b/test/disabled/script/t1017.scala
new file mode 100755
index 0000000000..d1b43ea923
--- /dev/null
+++ b/test/disabled/script/t1017.scala
@@ -0,0 +1,29 @@
+#!/bin/sh
+# fact - A simple Scala script that prints out the factorial of
+# the argument specified on the command line.
+
+cygwin=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+esac
+
+SOURCE="$0";
+if $cygwin; then
+ if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
+ format=mixed
+ else
+ format=windows
+ fi
+ SOURCE=`cygpath --$format "$SOURCE"`;
+fi
+
+exec scala -nocompdaemon "$SOURCE" "$@"
+!#
+
+def foo = {
+ bar
+}
+
+var x = 1
+
+def bar = 1