Numerical matcher applied to Long cause following compiler error: no implicit argument matching parameter type (AnyVal) => Double was found.
For example: listing.length must beGreaterThan(72815) where listing is java.io.File, length is Long.
Workaround is to explicitly convert to Int (which works OK for my range): listing.length.toInt must beGreaterThan(72815)
Comment #1
Posted on Jul 27, 2009 by Massive GiraffeThis issue was closed by r1067.
Comment #2
Posted on Jul 27, 2009 by Massive GiraffeYou can find the fix here: http://scala-tools.org/repo-snapshots/org/scala- tools/testing/specs/1.6.0-SNAPSHOT/
Comment #3
Posted on Sep 15, 2009 by Helpful ElephantWith 1.6.0 I'm still getting following error: no implicit argument matching parameter type (AnyVal) => Ordered[AnyVal] was found.
Comment #4
Posted on Sep 15, 2009 by Helpful ElephantAh, now I see that the problem is with parameter for the beGreaterThan - its only Int. Is it somehow possible to have implicit up-conversions?
Comment #5
Posted on Sep 15, 2009 by Helpful ElephantHmmm... the joys of static typing! The correct expressions are:
listing.length.toInt must beCloseTo(36832, 25) or listing.length must beCloseTo(36832L, 25L)
So what I'm asking for, because I'm lazy to figure out the true causes of compiler's complaints with my source code, is quite a long shot: listing.length must beCloseTo(36832, 25)
Feel free to close this as Wontfix... but the core issue is, that the compiler error message was not at all helpful. Is there something you could do in specs implementation to improve this?
Comment #6
Posted on Sep 15, 2009 by Helpful ElephantPossibly related discussion, that links to Numeric abstractions planned for Scala 2.8: http://www.nabble.com/How-to-abstract-over-types-of-numbers--td25341738.html
Comment #7
Posted on Sep 16, 2009 by Massive GiraffeI'm reopening this issue and I will try to find out if I can take out some of the Numeric implicit defs to appease the typechecker when mixin Longs and Ints
Comment #8
Posted on Sep 18, 2009 by Massive GiraffeI tried to use the Numeric approach by replicating the Numeric definitions in 2.8. Unfortunately, I was not able to find a way to mix Longs and Ints in the matchers. I even ended up crashing the compiler with that!
So for the moment, I close the issue and I will have another go at it when 2.8 is final.
The only thing I added in 1.6.1-SNAPSHOT is some sugar to write:
listing.length.toInt must be closeTo (36832 +/- 25)
If your not allergic to adhoc operators,...
Status: WontFix
Labels:
Type-Defect
Priority-Medium