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

Issue with incrementing array when using Random number generation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.2
    • 1.7.4, 1.8-beta-1
    • None
    • None
    • Windows 7 64 bit

    Description

      I have found an issue with array incrementation, when using randomly generated number as array index.
      The idea was to randomly increment one of the indexes.
      For array of size = 3 and 10 incrementations I can see array was modified like this [example from system.out]:
      [0, 0, 1]
      [0, 0, 1]
      [2, 0, 1] should be [1,0,1]
      [2, 3, 1] should be [1,1,1]
      [3, 3, 1] should be [2,1,1]
      [3, 2, 1] now I'm puzzled as the digit is decremented!
      [3, 2, 1] what was incremented? no one knows! ;]
      [3, 2, 2]
      [3, 2, 3]
      [3, 3, 3]

      See the code attached.

      Additional info:
      When the randomiser invocation is moved to assign value to a variable, and then variable is used as array index it works fine.

      Attachments

        1. Bug.groovy
          0.3 kB
          Krystian Szczesny
        2. 4246_v18x.patch
          5 kB
          Roshan Dawrani

        Activity

          People

            roshandawrani Roshan Dawrani
            krstn Krystian Szczesny
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: