diff options
author | Martin Odersky <odersky@gmail.com> | 2010-05-10 15:40:08 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2010-05-10 15:40:08 +0000 |
commit | 0319fec702a7da3538eee9398faea33721df5311 (patch) | |
tree | 4550b8d434dac02b3051b62a34114fbdcaf351a7 /test/pending/scalacheck/eqeq.scala | |
parent | f8b4ca8cf0b3957e09a21a1019152ae3d87c8a01 (diff) | |
download | scala-0319fec702a7da3538eee9398faea33721df5311.tar.gz scala-0319fec702a7da3538eee9398faea33721df5311.tar.bz2 scala-0319fec702a7da3538eee9398faea33721df5311.zip |
Disabled scalacheck tests because they interfer...
Disabled scalacheck tests because they interfere with library
refactorings (refactorings break scalacheck).
Diffstat (limited to 'test/pending/scalacheck/eqeq.scala')
-rw-r--r-- | test/pending/scalacheck/eqeq.scala | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/pending/scalacheck/eqeq.scala b/test/pending/scalacheck/eqeq.scala new file mode 100644 index 0000000000..60fe63c207 --- /dev/null +++ b/test/pending/scalacheck/eqeq.scala @@ -0,0 +1,37 @@ +import org.scalacheck._ +import Prop._ +import Gen._ + +object Test extends Properties("==") { + 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) + } + } + + 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.##) + } + } +} |