frankban/quicktest

assert: additional argument are not treated as comments

lmb opened this issue · 1 comments

lmb commented

The documentation for Assert has this bit in it:

Additional args (not consumed by the checker), when provided, are included as comments in the failure output when the check fails. 

I read this to mean that the following is legitimate:

qt.Assert(t, true, qt.Equals, false, "yeah, no")

However, the output is the following:

        error:
          bad check: too many arguments provided to checker: got 2, want 1
        got args:
          []interface {}{
              bool(false),
              "yeah, no",
          }
        want args:
          want
        stack:

Only using qt.Commentf as the last parameter is accepted. Is this intentional? I would find being able to pass a plain string (maybe even strings?) quite useful, since it reduces the burden of adding comments to asserts. Most asserts we have don't carry comments for this reason.

Yes, that was an intentional design decision.
When you read qt.Assert(t, x, qt.Equals, "foo", qt.Commentf("bar")) it is very apparent what args are part of the check and what is a comment. I am not sure about qt.Assert(t, x, qt.Equals, "foo", "bar"). Definitively easier to type, but isn't it a bit ambiguous when you read it?