reason-native icon indicating copy to clipboard operation
reason-native copied to clipboard

Rely: pretty printing boolean values

Open baransu opened this issue 6 years ago • 5 comments

Right now when doing:

expect.equal(
  {userId: 1, id: 3, title: "fugiat veniam minus", completed: false},
  {userId: 1, id: 3, title: "fugiat veniam minus", completed: true},
);

we receive such error:

 expect.equal(expected, received) /* using == */

    Expected value to equal:
      {1, 3, "fugiat veniam minus", 0}
    Received:
      {1, 3, "fugiat veniam minus", 1}

It would be nice to print boolean values as true or false which is easier to spot and distinguish from int.

baransu avatar Apr 17 '19 22:04 baransu

@jordwalke is this something we can fix in Console? Or are we unable to distinguish booleans there?

kyldvs avatar Apr 17 '19 22:04 kyldvs

@kyldvs It seems there is no such thing as Obj.bool_tag or something similar. I hope I'm wrong.

baransu avatar Apr 17 '19 23:04 baransu

I also believe that we can't distinguish bools from int in our polymorphic printer unfortunately (which is in fact looking at object tags).

bandersongit avatar Apr 26 '19 17:04 bandersongit

What if we were to always print both options? 0 (false) or 1 (true) when printing ints with those values?

kyldvs avatar Apr 26 '19 18:04 kyldvs

@kyldvs I think bools, polymorphic variants, and ordinary variants are all expressed as ints.

baransu avatar Apr 26 '19 18:04 baransu