Closed mz-gh closed 5 years ago
Ok. I clearly missed that the length of an array is a non-deterministic thing. The lua language will never cease to surprise me.
The documentation of Lua precisely reads :
If the array has "holes" (that is, nil values between other non-nil values), then #t can be any of the indices that directly precedes a nil value (that is, it may consider any such nil value as the end of the array).
So, the table {1, nil, 3} may have length 1 or 3 and both of them are legitimate lengths. How not convienent !
I'll update luaunit to deal with this, thanks for spotting it.
You can use the luaunit from master to get the correct behavior. Or you can also just remove the offending length comparison in line 1120 of luaunit.lua
Hi!
Given the following script:
The last assert fails with the following output:
So, the elements are equal, yet the arrays are not.
The reason why it fails is most probably that when checking the equality of arrays the length operator is used, which isn't reliable if the arrays are non-sequential (contains 'nil' somewhere "in the middle").
Another issue for me here is, that according to the output, the arrays seem to be equal, so no clue is given, why the test has failed.