Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1142

Number comparison inconsistent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.0-JSR-4
    • 1.0-JSR-5
    • None
    • None

    Description

      The following should be consistent, but it is not:
      assert 1 == "1" //fails
      assert 11 == "11" //works
      assert "1" > 1 //works
      assert "11" > 11 //fails

      The above issues seem to be due to a bug in Invoker.asNumber() and Invoker.compareTo(). They treat String with a length of 1 differently. For example, asNumber converts Strings of length 1 to Integer, and everything else to BigDecimal (yikes!).

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            bl7385 Brian Larson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: