summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-01 05:59:11 +0000
committerPaul Phillips <paulp@improving.org>2010-03-01 05:59:11 +0000
commit07f1f6dd14f8342f40f139781317755ceb661b96 (patch)
treee7f393e2e678fa946b80a9858bc6b0f6e51fb1f9
parentb94c6e0da6d33bc69f1419634128e2f401109b61 (diff)
downloadscala-07f1f6dd14f8342f40f139781317755ceb661b96.tar.gz
scala-07f1f6dd14f8342f40f139781317755ceb661b96.tar.bz2
scala-07f1f6dd14f8342f40f139781317755ceb661b96.zip
Enabled scalacheck tests.
what must be legacy scalatest.* properties to partest.*, boldly assuming that the fact that partest is pretty much unusable outside of scalac means there are no users outside of scalac who might be disrupted by eliminating old property names. Review by community.
-rw-r--r--build.xml35
-rw-r--r--src/partest/README8
-rw-r--r--src/partest/scala/tools/partest/nest/AntRunner.scala4
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala11
-rw-r--r--src/partest/scala/tools/partest/nest/FileManager.scala6
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala17
-rw-r--r--src/partest/scala/tools/partest/package.scala18
-rw-r--r--test/disabled/run/docgenerator.scala2
-rw-r--r--test/files/jvm/inner.scala4
-rw-r--r--test/files/run/programmatic-main.scala2
-rw-r--r--test/files/scalacheck/eqeq.scala32
-rwxr-xr-xtest/partest2
-rwxr-xr-xtest/partest.bat2
14 files changed, 82 insertions, 63 deletions
diff --git a/build.xml b/build.xml
index e706467a69..bbd5abca76 100644
--- a/build.xml
+++ b/build.xml
@@ -147,7 +147,7 @@ PROPERTIES
<property name="lib.dir" value="${basedir}/lib"/>
<property name="lib-ant.dir" value="${lib.dir}/ant"/>
<property name="src.dir" value="${basedir}/src"/>
- <property name="test.dir" value="${basedir}/test"/>
+ <property name="partest.dir" value="${basedir}/test"/>
<!-- Loads custom properties definitions -->
<property file="${basedir}/build.properties"/>
@@ -161,6 +161,7 @@ PROPERTIES
<property name="comp.starr.jar" value="${lib.dir}/scala-compiler.jar"/>
<property name="jline.jar" value="${lib.dir}/jline.jar"/>
<property name="ant.jar" value="${ant.home}/lib/ant.jar"/>
+ <property name="scalacheck.jar" value="${lib.dir}/ScalaCheck.jar"/>
<!-- Sets location of build folders -->
<property name="build.dir" value="${basedir}/build"/>
@@ -1398,9 +1399,9 @@ BOOTRAPING TEST AND TEST SUITE
scalacopts="${scalac.args.optimise}">
<classpath>
<path refid="pack.classpath"/>
- <fileset dir="${test.dir}/files/lib" includes="*.jar"/>
+ <fileset dir="${partest.dir}/files/lib" includes="*.jar"/>
</classpath>
- <runtests dir="${test.dir}/files">
+ <runtests dir="${partest.dir}/files">
<include name="run/**/*.scala"/>
<include name="jvm/**/*.scala"/>
</runtests>
@@ -1413,19 +1414,19 @@ BOOTRAPING TEST AND TEST SUITE
scalacopts="${scalac.args.optimise}">
<classpath>
<path refid="pack.classpath"/>
- <fileset dir="${test.dir}/files/lib" includes="*.jar"/>
+ <fileset dir="${partest.dir}/files/lib" includes="*.jar"/>
</classpath>
- <postests dir="${test.dir}/files/pos" includes="*.scala"/>
- <negtests dir="${test.dir}/files/neg" includes="*.scala"/>
- <runtests dir="${test.dir}/files">
+ <postests dir="${partest.dir}/files/pos" includes="*.scala"/>
+ <negtests dir="${partest.dir}/files/neg" includes="*.scala"/>
+ <runtests dir="${partest.dir}/files">
<include name="run/**/*.scala"/>
</runtests>
- <jvmtests dir="${test.dir}/files/jvm" includes="*.scala"/>
- <residenttests dir="${test.dir}/files/res" includes="*.res"/>
- <buildmanagertests dir="${test.dir}/files/buildmanager" includes="*"/>
- <scalaptests dir="${test.dir}/files/scalap" includes="**/*.scala"/>
- <!-- <scalachecktests dir="${test.dir}/files/scalacheck" includes="**/*.scala"/> -->
- <!-- <scripttests dir="${test.dir}/files/script" includes="*.scala"/> -->
+ <jvmtests dir="${partest.dir}/files/jvm" includes="*.scala"/>
+ <scalachecktests dir="${partest.dir}/files/scalacheck" includes="**/*.scala"/>
+ <residenttests dir="${partest.dir}/files/res" includes="*.res"/>
+ <buildmanagertests dir="${partest.dir}/files/buildmanager" includes="*"/>
+ <scalaptests dir="${partest.dir}/files/scalap" includes="**/*.scala"/>
+ <!-- <scripttests dir="${partest.dir}/files/script" includes="*.scala"/> -->
</partest>
</target>
@@ -1634,7 +1635,7 @@ POSITIONS
<target name="test.positions" depends="quick.comp">
<antcall target="test.positions.tests.sub" inheritRefs="true">
- <param name="test.tests.srcs" value="${test.dir}/files/positions"/>
+ <param name="test.tests.srcs" value="${partest.dir}/files/positions"/>
</antcall>
<antcall target="test.positions.sub" inheritRefs="true">
<param name="test.srcs" value="${src.dir}/compiler"/>
@@ -1658,13 +1659,13 @@ POSITIONS
<param name="test.srcs" value="${src.dir}/scalap"/>
</antcall>
<antcall target="test.positions.tests.sub" inheritRefs="true">
- <param name="test.tests.srcs" value="${test.dir}/files/pos"/>
+ <param name="test.tests.srcs" value="${partest.dir}/files/pos"/>
</antcall>
<antcall target="test.positions.tests.sub" inheritRefs="true">
- <param name="test.tests.srcs" value="${test.dir}/files/run"/>
+ <param name="test.tests.srcs" value="${partest.dir}/files/run"/>
</antcall>
<antcall target="test.positions.tests.sub" inheritRefs="true">
- <param name="test.tests.srcs" value="${test.dir}/files/neg"/>
+ <param name="test.tests.srcs" value="${partest.dir}/files/neg"/>
</antcall>
</target>
diff --git a/src/partest/README b/src/partest/README
index 27159ca078..81876fc810 100644
--- a/src/partest/README
+++ b/src/partest/README
@@ -1,11 +1,11 @@
How partest choses the compiler / library:
- * ''-Dscalatest.build=build/four-pack'' -> will search for libraries in
+ * ''-Dpartest.build=build/four-pack'' -> will search for libraries in
''lib'' directory of given path
- * ''--pack'' -> will set ''scalatest.build=build/pack'', and run all tests.
+ * ''--pack'' -> will set ''partest.build=build/pack'', and run all tests.
add ''--[kind]'' to run a selected set of tests.
* auto detection:
- - scalatest.build property -> ''bin'' / ''lib'' directories
+ - partest.build property -> ''bin'' / ''lib'' directories
- distribution (''dists/latest'')
- supersabbus pack (''build/pack'')
- sabbus quick (''build/quick'')
@@ -27,6 +27,6 @@ Other arguments:
* --buildmanager next files test the build manager
* --shootout next files are shootout tests
* --script next files test the script runner
- * ''-Dscalatest.scalac_opts=...'' -> add compiler options
+ * ''-Dpartest.scalac_opts=...'' -> add compiler options
* ''--verbose'' -> print verbose messages
* ''-Dpartest.debug=true'' -> print debug messages
diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala
index 16a7141653..cb819720fc 100644
--- a/src/partest/scala/tools/partest/nest/AntRunner.scala
+++ b/src/partest/scala/tools/partest/nest/AntRunner.scala
@@ -12,6 +12,7 @@ package scala.tools.partest
package nest
import java.io.File
+import scala.tools.nsc.io.{ Directory }
class AntRunner extends DirectRunner {
@@ -20,7 +21,8 @@ class AntRunner extends DirectRunner {
var JAVAC_CMD: String = "javac"
var CLASSPATH: String = _
var LATEST_LIB: String = _
- val TESTROOT: String = ""
+ val testRootPath: String = "test"
+ val testRootDir: Directory = Directory(testRootPath)
}
def reflectiveRunTestsForFiles(kindFiles: Array[File], kind: String) =
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index b3c6e9b4df..9e58cfbf36 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -65,7 +65,7 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
val args = (path substring 9 split pathSeparator).toList
val plugins = args map (arg =>
if (new File(arg).isAbsolute) arg
- else fileManager.TESTROOT+File.separator+arg
+ else fileManager.testRootPath+File.separator+arg
)
plugins
}
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index 3277db2ba7..e2d28abba8 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -51,26 +51,23 @@ class ConsoleFileManager extends FileManager {
SCALAC_OPTS = SCALAC_OPTS+" "+moreOpts
}
- val testRootDir = PathSettings.testRoot
- val srcDir = PathSettings.srcDir
+ val srcDir = PathSettings.srcDir
+ val testRootDir = PathSettings.testRoot
+ val testRootPath = testRootDir.toAbsolute.path
+ def testParent = testRootDir.parent
var CLASSPATH = PartestDefaults.classPath
var JAVACMD = PartestDefaults.javaCmd
var JAVAC_CMD = PartestDefaults.javacCmd
- val TESTROOT = testRootDir.toAbsolute.path
- def testParent = testRootDir.parent
NestUI.verbose("CLASSPATH: "+CLASSPATH)
-
if (!srcDir.isDirectory) {
NestUI.failure("Source directory \"" + srcDir.path + "\" not found")
exit(1)
}
- LIB_DIR = (testParent / "lib").normalize.path
-
CLASSPATH = {
val libs = (srcDir / Directory("lib")).files filter (_ hasExtension "jar") map (_.normalize.path)
diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala
index 092b9ccba7..12a4fdf40f 100644
--- a/src/partest/scala/tools/partest/nest/FileManager.scala
+++ b/src/partest/scala/tools/partest/nest/FileManager.scala
@@ -33,14 +33,14 @@ trait FileManager {
if (res startsWith "No") "" else res
}
+ def testRootDir: Directory
+ def testRootPath: String
+
var JAVACMD: String
var JAVAC_CMD: String
var CLASSPATH: String
var LATEST_LIB: String
- var LIB_DIR: String = ""
-
- val TESTROOT: String
var showDiff = false
var showLog = false
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 2e2bcf2271..84fe413301 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -139,9 +139,9 @@ class Worker(val fileManager: FileManager) extends Actor {
// fileManager.synchronized {
// withOutputRedirected(logWriter) {
// System.setProperty("java.library.path", logFile.getParentFile.getCanonicalFile.getAbsolutePath)
- // System.setProperty("scalatest.output", outDir.getCanonicalFile.getAbsolutePath)
- // System.setProperty("scalatest.lib", LATEST_LIB)
- // System.setProperty("scalatest.cwd", outDir.getParent)
+ // System.setProperty("partest.output", outDir.getCanonicalFile.getAbsolutePath)
+ // System.setProperty("partest.lib", LATEST_LIB)
+ // System.setProperty("partest.cwd", outDir.getParent)
// ObjectRunner.run(classpath, "Test", List("jvm"))
// }
// }
@@ -234,15 +234,15 @@ class Worker(val fileManager: FileManager) extends Actor {
// because when an option is repeated to java only the last one wins.
// That means until now all the .javaopts files were being ignored because
// they all attempt to change options which are also defined in
- // scalatest.java_opts, leading to debug output like:
+ // partest.java_opts, leading to debug output like:
//
// debug: Found javaopts file 'files/shootout/message.scala-2.javaopts', using options: '-Xss32k'
// debug: java -Xss32k -Xss2m -Xms256M -Xmx1024M -classpath [...]
val propertyOptions = List(
"-Djava.library.path="+logFile.getParentFile.getAbsolutePath,
- "-Dscalatest.output="+outDir.getAbsolutePath,
- "-Dscalatest.lib="+LATEST_LIB,
- "-Dscalatest.cwd="+outDir.getParent,
+ "-Dpartest.output="+outDir.getAbsolutePath,
+ "-Dpartest.lib="+LATEST_LIB,
+ "-Dpartest.cwd="+outDir.getParent,
"-Djavacmd="+JAVACMD,
"-Duser.language=en -Duser.country=US"
) ::: (
@@ -452,8 +452,7 @@ class Worker(val fileManager: FileManager) extends Actor {
NestUI.verbose("compilation of "+file+" succeeded\n")
- val libs = new File(fileManager.LIB_DIR)
- val scalacheckURL = (new File(libs, "ScalaCheck.jar")).toURI.toURL
+ val scalacheckURL = (fileManager.testRootDir.parent / "lib" / "ScalaCheck.jar").toURL
val outURL = outDir.getCanonicalFile.toURI.toURL
val classpath: List[URL] =
List(outURL, scalacheckURL, latestCompFile.toURI.toURL, latestLibFile.toURI.toURL, latestPartestFile.toURI.toURL).distinct
diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala
index 68598f6594..d7fcb79235 100644
--- a/src/partest/scala/tools/partest/package.scala
+++ b/src/partest/scala/tools/partest/package.scala
@@ -22,20 +22,20 @@ package object partest {
private def wrapAccessControl[T](body: => Option[T]): Option[T] =
try body catch { case _: java.security.AccessControlException => None }
- def testRootName = propOrNone("scalatest.root")
+ def testRootName = propOrNone("partest.root")
def srcDirName = propOrElse("partest.srcdir", "files")
def testRootDir = testRootName map (x => Directory(x))
def classPath = PathResolver.Environment.javaUserClassPath // XXX
- def javaCmd = propOrElse("scalatest.javacmd", "java")
- def javacCmd = propOrElse("scalatest.javac_cmd", "javac")
- def javaOpts = propOrElse("scalatest.java_opts", "")
- def scalacOpts = propOrElse("scalatest.scalac_opts", "-deprecation")
+ def javaCmd = propOrElse("partest.javacmd", "java")
+ def javacCmd = propOrElse("partest.javac_cmd", "javac")
+ def javaOpts = propOrElse("partest.java_opts", "")
+ def scalacOpts = propOrElse("partest.scalac_opts", "-deprecation")
- def testBuild = propOrNone("scalatest.build")
- def errorCount = propOrElse("scalatest.errors", "0").toInt
- def numActors = propOrElse("scalatest.actors", "8").toInt
+ def testBuild = propOrNone("partest.build")
+ def errorCount = propOrElse("partest.errors", "0").toInt
+ def numActors = propOrElse("partest.actors", "8").toInt
def poolSize = wrapAccessControl(propOrNone("actors.corePoolSize"))
def timeout = "1200000"
@@ -56,5 +56,5 @@ package object partest {
NestUI.verbose(allPropertiesString)
}
- def isPartestDebug = List("partest.debug", "scalatest.debug") map propOrEmpty contains "true"
+ def isPartestDebug = propOrEmpty("partest.debug") == "true"
} \ No newline at end of file
diff --git a/test/disabled/run/docgenerator.scala b/test/disabled/run/docgenerator.scala
index 59f90ba415..247ad17b45 100644
--- a/test/disabled/run/docgenerator.scala
+++ b/test/disabled/run/docgenerator.scala
@@ -10,7 +10,7 @@ object Test {
def main(args: Array[String]) {
// overwrites value of UrlContext.generator in file DocUtil.scala
System.setProperty("doc.generator", "scaladoc")
- var dirname = System.getProperty("scalatest.output")
+ var dirname = System.getProperty("partest.output")
if (dirname eq null) dirname = System.getProperty("java.io.tmpdir")
val tmpDir = new File(dirname)
tmpDir.mkdirs()
diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala
index 51e3909ef3..d6b055e998 100644
--- a/test/files/jvm/inner.scala
+++ b/test/files/jvm/inner.scala
@@ -53,8 +53,8 @@ class A {
}
object Scalatest {
- private val outputdir = System.getProperty("scalatest.output", "inner-jvm.obj")
- private val scalalib = System.getProperty("scalatest.lib", "")
+ private val outputdir = System.getProperty("partest.output", "inner-jvm.obj")
+ private val scalalib = System.getProperty("partest.lib", "")
private val classpath = outputdir + File.pathSeparator + scalalib
private val javabin = {
val jhome = new File(System.getProperty("java.home"))
diff --git a/test/files/run/programmatic-main.scala b/test/files/run/programmatic-main.scala
index 0e91d219a7..c97e4a8f3f 100644
--- a/test/files/run/programmatic-main.scala
+++ b/test/files/run/programmatic-main.scala
@@ -3,7 +3,7 @@ import io.Path
object Test
{
- val cwd = Option(System.getProperty("scalatest.cwd")) getOrElse "."
+ val cwd = Option(System.getProperty("partest.cwd")) getOrElse "."
val basedir = (Path(cwd).parent / "lib").path
val baseargs = Array("-bootclasspath", basedir + "/scala-library.jar", "-cp", basedir + "/scala-compiler.jar")
diff --git a/test/files/scalacheck/eqeq.scala b/test/files/scalacheck/eqeq.scala
index 163f17d94c..60fe63c207 100644
--- a/test/files/scalacheck/eqeq.scala
+++ b/test/files/scalacheck/eqeq.scala
@@ -3,15 +3,35 @@ import Prop._
import Gen._
object Test extends Properties("==") {
- property("reflexive") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) }
- // property("hashCode") = forAll { (x
+ def equalObjectsEqualHashcodes(x: Any, y: Any) = (x != y) || (x == y && x.## == y.##)
+ // ticket #2087
property("short/char") = forAll { (x: Short) => {
val ch: Char = x.toChar
- (x == ch) == (ch == x) ||
- // that's the whole test once it works, but since it doesn't yet:
- x < 0
+ (x == ch) == (ch == x)
}
}
-}
+ property("symmetry") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) }
+ property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z }
+
+ property("##") = forAll {
+ (x: Short) => {
+ val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x))
+ val shortAndLarger = anyvals drop 2
+
+ val result = (
+ ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) &&
+ ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) &&
+ ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any)))
+ )
+ result
+ }
+ }
+ property("## 2") = forAll {
+ (dv: Double) => {
+ val fv = dv.toFloat
+ (fv != dv) || (fv.## == dv.##)
+ }
+ }
+}
diff --git a/test/partest b/test/partest
index 6c0190dd31..1e7da8bd4a 100755
--- a/test/partest
+++ b/test/partest
@@ -83,4 +83,4 @@ if [ ! -z "${PARTEST_DEBUG}" ] ; then
partestDebugStr="-Dpartest.debug=${PARTEST_DEBUG}"
fi
-${JAVACMD:=java} $JAVA_OPTS -cp "$EXT_CLASSPATH" ${partestDebugStr} -Dscala.home="${SCALA_HOME}" -Dscalatest.javacmd="${JAVACMD}" -Dscalatest.java_opts="${JAVA_OPTS}" -Dscalatest.scalac_opts="${SCALAC_OPTS}" -Dscalatest.javac_cmd="${JAVA_HOME}/bin/javac" scala.tools.partest.nest.NestRunner "$@"
+${JAVACMD:=java} $JAVA_OPTS -cp "$EXT_CLASSPATH" ${partestDebugStr} -Dscala.home="${SCALA_HOME}" -Dpartest.javacmd="${JAVACMD}" -Dpartest.java_opts="${JAVA_OPTS}" -Dpartest.scalac_opts="${SCALAC_OPTS}" -Dpartest.javac_cmd="${JAVA_HOME}/bin/javac" scala.tools.partest.nest.NestRunner "$@"
diff --git a/test/partest.bat b/test/partest.bat
index 861c0a2465..39fe830082 100755
--- a/test/partest.bat
+++ b/test/partest.bat
@@ -53,7 +53,7 @@ if "%_EXTENSION_CLASSPATH%"=="" (
)
)
-set _PROPS=-Dscala.home="%_SCALA_HOME%" -Dscalatest.javacmd="%_JAVACMD%" -Dscalatest.java_options="%_JAVA_OPTS%" -Dscalatest.scalac_options="%_SCALAC_OPTS%" -Dscalatest.javac_cmd="%JAVA_HOME%\bin\javac"
+set _PROPS=-Dscala.home="%_SCALA_HOME%" -Dpartest.javacmd="%_JAVACMD%" -Dpartest.java_options="%_JAVA_OPTS%" -Dpartest.scalac_options="%_SCALAC_OPTS%" -Dpartest.javac_cmd="%JAVA_HOME%\bin\javac"
rem echo %_JAVACMD% %_JAVA_OPTS% %_PROPS% -cp "%_EXTENSION_CLASSPATH%" scala.tools.partest.nest.NestRunner %_ARGS%
%_JAVACMD% %_JAVA_OPTS% %_PROPS% -cp "%_EXTENSION_CLASSPATH%" scala.tools.partest.nest.NestRunner %_ARGS%