From 07f1f6dd14f8342f40f139781317755ceb661b96 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 1 Mar 2010 05:59:11 +0000 Subject: 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. --- test/files/scalacheck/eqeq.scala | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'test/files/scalacheck') 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.##) + } + } +} -- cgit v1.2.3