Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Comment handling by Error*/Fail* #106

Open
aronatkins opened this issue Oct 3, 2018 · 0 comments
Open

Better Comment handling by Error*/Fail* #106

aronatkins opened this issue Oct 3, 2018 · 0 comments

Comments

@aronatkins
Copy link

The check.Comment type does not implement fmt.Stringer. The Error* and Fail* functions do not support check.Comment values. This means that we currently need:

c.Errorf("unexpected callback: %s", comment.CheckCommentString())

The simplest change is probably to implement Comment#String, which then allows:

c.Errorf("unexpected callback: %s", comment)

The trouble with this approach is that existing implementations of CommentInterface outside the check package would not see the benefit without adding a String implementation. Maybe that's not much of an issue, as they're probably already calling CheckCommentString directly to support Error* and Fail* calls.

Alternatively, the Error* and Fail* functions could peek at their last argument to see if it implements CommentInterface. Comments would be handled in a similar way to what happens in internalCheck to support Check and Assert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant