xls icon indicating copy to clipboard operation
xls copied to clipboard

Improve mismatch message in assert_eq for arrays

Open mikex-oss opened this issue 1 year ago • 1 comments

What's hard to do? (limit 100 words)

The change at https://github.com/google/xls/commit/f530b769e765910ac6251e403ab449fda4c6ec00 has been very useful. However, I noticed that it does not apply to array elements when comparing arrays.

E.g.

assert_eq(
    some_fn(...), 
    u32[4]:[u32:0x75312468, u32:0, ...]);

might spit out something like:

FailureError: The program being interpreted failed!
  lhs and rhs were not equal:
  [
<     u32:960064620,
>     u32:1966154856,
      u32:0,
      u32:0,
      u32:0
  ]
; first differing index: 0 :: 960064620 vs 1966154856

It would be nice if the change to use the literal base could apply to each array element as in the scalar case.

Current best alternative workaround (limit 100 words)

Open up a Python interpreter (or some online base converter) to convert the decimal values to the form in the original test.

Your view of the "best case XLS enhancement" (limit 100 words)

If the previous change could be extended to array elements, that would be great.

mikex-oss avatar Jul 26 '24 23:07 mikex-oss

Not exactly a fix for this particular bug, but we should probably switch to a default format of hex rather than decimal for these messages.

meheff avatar Aug 05 '24 17:08 meheff