Skip to content

assert: combine user and generated message

There are lots of PRs that remove the message property assert calls. That message is actually pretty valuable and should not be removed. However, the message alone is often not that useful. In context with the auto-generated message it can be very valuable. From now on it would also be possible to provide the actual input value to functions and similar instead of having to reconstruct what value the assertion failed upon:

assert.strictEqual(foobar(input), 'output', input)
assert.ok(/regexp/.test(input), input)

Before, all values were coerced to a string and passing through a message would have resulted in [object Object] as output. Now the value is inspected and fully visible.

There is only one values that is not accepted as input: instances of Error (those are special handled in the way that that concrete error would be thrown in case of an failed assertion. Therefore even if someone does not anticipates this case, it's always a good assertion output). I have a follow-up PR to add support for undefined as well.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading