Groovy
  1. Groovy
  2. GROOVY-4246

Issue with incrementing array when using Random number generation

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.2
    • Fix Version/s: 1.7.4, 1.8-beta-1
    • Component/s: None
    • Labels:
      None
    • Environment:
      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.

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

        Activity

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Krystian Szczesny
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development