spock icon indicating copy to clipboard operation
spock copied to clipboard

Content of multi-dimensional arrays is not rendered in comparison

Open leonard84 opened this issue 7 years ago • 3 comments

  def "single arrays are rendered correctly"() {
    expect:
    isRendered """
x == y
| |  |
| |  [1, 5]
| false
[2, 5]
    """, {
      int [] x =  [2,5]
      int [] y =  [1,5]
      assert x == y
    }
  }

  def "multi arrays are rendered correctly"() {
    expect:
    isRendered """
x == y
| |  |
| |  [[1,2], [1,5]]
| false
[[1,2], [2,5]]
    """, {
      int [][] x = [[1,2], [2,5]]
      int [][] y = [[1,2], [1,5]]
      assert x == y
    }
  }

The second test fails with a rendering of

x == y
| |  |
| |  [<[I@1e802ef9>, <[I@2b6faea6>]
| false
[<[I@4313f5bc>, <[I@7f010382>]

If nested lists, are used instead of an array it works as expected.

leonard84 avatar Nov 28 '18 18:11 leonard84

It can be rendered correctly if using def to declare x and y:

def x = [[1,2], [2,5]]
def y = [[1,2], [1,5]]
assert x == y

lvncnt avatar Jan 19 '19 20:01 lvncnt

@lvncnt well those are not arrays, but nested lists.

leonard84 avatar Jan 20 '19 20:01 leonard84

is there a reason InvokerHelper.toString is not used in the dump()?

lvncnt avatar Jan 26 '19 07:01 lvncnt