Reductio Testing with Groovy

2 views
Skip to first unread message

Paul King

unread,
May 27, 2008, 7:39:43 AM5/27/08
to Reductio
For some fun I tried one of the examples in Groovy:

import fj.F2
import reductio.Property
import static reductio.Arbitrary.arbInteger
import static reductio.CheckResult.summary
import static reductio.Property.prop
import static reductio.Property.property

def isTransitive = ({ int e, int f -> prop(e + f == f + e) } as
F2<Integer, Integer, Property>)
def isTransitiveForAll = property(arbInteger, arbInteger,
isTransitive)
summary.println(isTransitiveForAll.check()) //OK, passed 100 tests.

That look spretty good too.

Cheers, Paul.

Paul King

unread,
May 27, 2008, 8:12:23 AM5/27/08
to Reductio

The duck type version doesn't look too bad either:

import static reductio.Arbitrary.*
import static reductio.CheckResult.summary
import static reductio.Property.prop
import static reductio.Property.property

def checkPlusTransitive = { e, f -> prop(e + f == f + e) } as fj.F2
def plusIsTransitiveForArbInts = property(arbInteger, arbInteger,
checkPlusTransitive)
def plusIsTransitiveForArbFloats = property(arbFloat, arbFloat,
checkPlusTransitive)
summary.println plusIsTransitiveForArbInts.check()
summary.println plusIsTransitiveForArbFloats.check()

Just don't try arbString! :-)

Paul.

Tony Morris

unread,
May 27, 2008, 3:59:47 PM5/27/08
to redu...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nice one Paul!

You might be interested to know that I am currently working on a
similar concept, but with Scala:
https://issues.workingmouse.com/view.php?id=31

- --
Tony Morris
http://tmorris.net/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIPGgzmnpgrYe6r60RAhOsAKCu4B8r7DqcCgODJanMTCbgUZrWLACePsQD
z7ekUC/m+EB8YcB/TEtRrPU=
=/jva
-----END PGP SIGNATURE-----

Paul King

unread,
May 27, 2008, 9:27:12 PM5/27/08
to redu...@googlegroups.com
Yes. An interesting area. I like all the language innovation happening
in this space. If I get time I will write some Groovy wrapping niceness
around this. I am more than happy to see Scala shine here (it is one of
its strong areas) but I'd love to see this available for Groovy too - it
is an area where I can see great improvements possible.

Paul.

Reply all
Reply to author
Forward
0 new messages