jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-2771

range of double-values broken?

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major 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?

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Paul King added a comment - 23/Apr/08 6:47 PM

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)
Show
Paul King added a comment - 23/Apr/08 6:47 PM 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)
Hide
Permalink
Peter Fürholz added a comment - 24/Apr/08 2:17 AM

Thanks to point that out for me.

Show
Peter Fürholz added a comment - 24/Apr/08 2:17 AM Thanks to point that out for me.

People

  • Assignee:
    Paul King
    Reporter:
    Peter Fürholz
Vote (0)
Watch (0)

Dates

  • Created:
    23/Apr/08 4:29 AM
    Updated:
    12/Oct/08 8:49 AM
    Resolved:
    23/Apr/08 6:47 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.