Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.5.4
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Groovy Shell (1.5.4, JVM: 1.5.0_11-b03)
Description
I got following error:
D:\>groovysh
Groovy Shell (1.5.4, JVM: 1.5.0_11-b03)
Type 'help' or '\h' for help.
--------------------------------------------------------------------
groovy:000> assert (0.0..1.1).contains(0.5)
ERROR java.lang.AssertionError: Expression: (0.0..1.1).contains(0.5)
at groovysh_evaluate.run (groovysh_evaluate:2)
...
groovy:000>
According to GinA this example should be working.
Can you approve this error?
In Groovy 1.5.x Ranges were changed to be fully compatible with Java's List interface. This means that (0.0..1.1) is the same as the list [0.0, 1.0] which doesn't contain 0.5. The other use case for Ranges in Groovy 1.0 was for intervals. There is an additional method now on Ranges to obtain this behavior. So your example is now written as:
assert (0.0..1.1).containsWithinBounds(0.5)assert (0.0..1.1).containsWithinBounds(0.5)