# Reductio newbie problem

12 views
Skip to first unread message

### ste...@gmail.com

unread,
Jul 13, 2008, 5:32:46 PM7/13/08
to Reductio
Hi,

Thanks for making Reductio, I appreciate the attempt to teach rigor
through better testing, it seems like a nice approach. I've been
having a problem getting up to speed with Reductio and thought perhaps
somebody could enlighten me.

I have a simple object that lets your determine the Hamming distance
between two Array[Bytes]:

package ecc

object Hamming {
def distance(a: Array[Byte], b: Array[Byte]): Int = {
sum(collapse(a.zip(b)))
}

def collapse(xs: Array[Tuple2[Byte, Byte]]): Array[Int] = {
xs.map((x) => if (x._1 == x._2) 0 else 1)
}

def sum(xs: Array[Int]): Int = (0 /: xs) (_ + _)
}

Now, distance(a, b) should equal distance(b, a) so I thought I'd write
a Property to check this:

package ecc.tests

import ecc._
import reductios.Property._
import reductios.Arbitrary.arbSInt
import reductio.CheckResult.summary
import fjs.F2._

/**
* Tests the commutative property of Hamming.distance
*/
object DistanceCommutes extends Application {
val p = prop((a: Array[Byte], b: Array[Byte]) => {
Hamming.distance(a, b) == Hamming.distance(b, a)
})
summary println +p
}

Unfortunately, scala 2.7.1 on Java 6 (Apple) refuses to compile my
test.

\$ make
scalac -classpath classes:lib/reductio.jar:lib/functionaljava.jar -d
classes `find ./ -name \*.scala -print`
Exception in thread "main" java.lang.AssertionError: assertion failed:
fj.data.Array[A]
at scala.Predef\$.assert(Predef.scala:92)
at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type
\$1(ClassfileParser.scala:525)
at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type
\$1(ClassfileParser.scala:543)
at scala.tools.nsc.symtab.classfile.ClassfileParser.scala\$tools\$nsc
\$symtab\$classfile\$ClassfileParser\$\$sigToType(ClassfileParser.scala:
574)
at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttribute
\$1(ClassfileParser.scala:602)
at scala.tools.nsc.symtab.classfile.ClassfileParser\$\$anonfun
\$parseAttributes\$1.apply(ClassfileParser.scala:765)
at scala.tools.nsc.symtab.classfile.ClassfileParser\$\$anonfun
\$parseAttributes\$1.apply(ClassfileParser.scala:765)
...

Have any of you run into this sort of error before? This is my first
property so I'm hoping I'm just missing something obvious.

Thanks,
Steve

### Tony Morris

unread,
Jul 13, 2008, 6:22:46 PM7/13/08
to redu...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Steve,
Yes we have seen this problem before, but we have not yet documented it.
Sorry for having you go off and rediscover it yourself.

The problem is a bug in Scala 2.7.1 which has been opened and
subsequently fixed by the EPFL:
http://lampsvn.epfl.ch/trac/scala/ticket/870

In order to get your example working, you will have to compile the
latest trunk of the Scala distribution and use that.

I have also opened an issue to help prevent others falling into the same
trap.
https://issues.workingmouse.com/view.php?id=49

Sorry again and please feel free to ask more questions.

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

Real-world problems are simply degenerate cases of pure mathematical
problems.

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

iD8DBQFIeoA1mnpgrYe6r60RAhLWAJ9/yGGbXThZVVPLIoNBWyIBHOSnzgCfdkHR
7yAfHbQCBTnQf01ZPib7xzc=
=wrj0
-----END PGP SIGNATURE-----

### ste...@gmail.com

unread,
Jul 13, 2008, 9:35:37 PM7/13/08
to Reductio
That's really unfortunate. If it were a personal project, I'd just
move to Scala trunk but this is for work so I'll have to use
ScalaCheck unless 2.7.2 comes out before I can convert enough people
to this from TDD.

Thanks,
Steve

On Jul 13, 3:22 pm, Tony Morris <tmor...@tmorris.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Steve,
> Yes we have seen this problem before, but we have not yet documented it.
> Sorry for having you go off and rediscover it yourself.
>
> The problem is a bug in Scala 2.7.1 which has been opened and
> subsequently fixed by the EPFL:http://lampsvn.epfl.ch/trac/scala/ticket/870
>
> In order to get your example working, you will have to compile the
> latest trunk of the Scala distribution and use that.
>
> I have also opened an issue to help prevent others falling into the same
> trap.https://issues.workingmouse.com/view.php?id=49
>
> Sorry again and please feel free to ask more questions.
>
> - --
> Tony Morrishttp://tmorris.net/
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

### Tony Morris

unread,
Jul 13, 2008, 9:57:22 PM7/13/08
to redu...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well that's a bummer. There have been quite a few bug fixes in Scala
HEAD since 2.7.1. Why can't you update? I'll do the build for you if you
like and post it somewhere (since of course, I am using it!).

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

Real-world problems are simply degenerate cases of pure mathematical
problems.

ste...@gmail.com wrote:
| That's really unfortunate. If it were a personal project, I'd just
| move to Scala trunk but this is for work so I'll have to use
| ScalaCheck unless 2.7.2 comes out before I can convert enough people
| to this from TDD.
|
| Thanks,
| Steve
|
| On Jul 13, 3:22 pm, Tony Morris <tmor...@tmorris.net> wrote:
| Hi Steve,
| Yes we have seen this problem before, but we have not yet documented it.
| Sorry for having you go off and rediscover it yourself.
|
| The problem is a bug in Scala 2.7.1 which has been opened and
| subsequently fixed by the
EPFL:http://lampsvn.epfl.ch/trac/scala/ticket/870
|
| In order to get your example working, you will have to compile the
| latest trunk of the Scala distribution and use that.
|
| I have also opened an issue to help prevent others falling into the same
| trap.https://issues.workingmouse.com/view.php?id=49
|
| Sorry again and please feel free to ask more questions.
|

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

iD8DBQFIerKCmnpgrYe6r60RAmL9AKDLF6xSww6F9NGtAVNIK5gGQELbcgCgjbA3
lfGLB4eu57ZjNo+HuF4h2Xw=
=kS5d
-----END PGP SIGNATURE-----

### ste...@gmail.com

unread,
Jul 14, 2008, 12:52:46 AM7/14/08
to Reductio
It's not building trunk that's the problem, we just consider it too
risky to put trunk scala in production without a lot of testing. For
instance, lift has historically had issues (sometimes small, sometimes
large) with new versions of Scala. I have another pet bug that I looks
fixed in HEAD so I will probably end up doing the grunt work and
"certifying" the latest revision.

http://lampsvn.epfl.ch/trac/scala/ticket/870

Thanks!
Steve

On Jul 13, 6:57 pm, Tony Morris <tmor...@tmorris.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Well that's a bummer. There have been quite a few bug fixes in Scala
> HEAD since 2.7.1. Why can't you update? I'll do the build for you if you
> like and post it somewhere (since of course, I am using it!).
>
> - --
> Tony Morrishttp://tmorris.net/
>
> Real-world problems are simply degenerate cases of pure mathematical
> problems.
>
> ste...@gmail.com wrote:
>
> | That's really unfortunate. If it were a personal project, I'd just
> | move to Scala trunk but this is for work so I'll have to use
> | ScalaCheck unless 2.7.2 comes out before I can convert enough people
> | to this from TDD.
> |
> | Thanks,
> | Steve
> |
> | On Jul 13, 3:22 pm, Tony Morris <tmor...@tmorris.net> wrote:
> | Hi Steve,
> | Yes we have seen this problem before, but we have not yet documented it.
> | Sorry for having you go off and rediscover it yourself.
> |
> | The problem is a bug in Scala 2.7.1 which has been opened and
> | subsequently fixed by the
> EPFL:http://lampsvn.epfl.ch/trac/scala/ticket/870
> |
> | In order to get your example working, you will have to compile the
> | latest trunk of the Scala distribution and use that.
> |
> | I have also opened an issue to help prevent others falling into the same
> | trap.https://issues.workingmouse.com/view.php?id=49
> |
> | Sorry again and please feel free to ask more questions.
> |
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
Reply all
Reply to author
Forward
0 new messages