diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-01 05:59:11 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-01 05:59:11 +0000 |
commit | 07f1f6dd14f8342f40f139781317755ceb661b96 (patch) | |
tree | e7f393e2e678fa946b80a9858bc6b0f6e51fb1f9 /test/files/scalacheck | |
parent | b94c6e0da6d33bc69f1419634128e2f401109b61 (diff) | |
download | scala-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.
Diffstat (limited to 'test/files/scalacheck')
-rw-r--r-- | test/files/scalacheck/eqeq.scala | 32 |
1 files changed, 26 insertions, 6 deletions
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.##) + } + } +} |