You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ignore the normal return value when an error expected
The contract in Go is "if there's an error, assume nothing about the normal return value". Thus, we should only check the non-error return value when there is no error.
In some exercises we found that we were checking the normal return value, even when there was an error.
See the binary tests for an example of the behavior that we want.
Increment the test version
These changes break backwards compatibility. Bump the test version to let reviewers know that the exercise has changed.
This requires changing two constants:
targetTestVersion in the test file (*_test.go)
testVersion in the reference solution (example.go)
If the exercise does not have a test version, then add one, setting the value to 1.
As part of #275, we'd like to more closely follow idiomatic Go behavior in the face of errors.
If the bracket-push exercise does not have error handling, then this ticket can be closed immediately.
If it does, then follow the below steps:
Ensure
err
return value is of typeerror
It's idiomatic for the error return value to be of type
error
.Most tests simply check whether
err == nil
or not. If we don't verify the type oferr
, it could be any type that has nils.To lean on the type system, add the following line after assigning err:
See the hamming tests for an example.
Ignore the normal return value when an error expected
The contract in Go is "if there's an error, assume nothing about the normal return value". Thus, we should only check the non-error return value when there is no error.
In some exercises we found that we were checking the normal return value, even when there was an error.
See the binary tests for an example of the behavior that we want.
Increment the test version
These changes break backwards compatibility. Bump the test version to let reviewers know that the exercise has changed.
This requires changing two constants:
targetTestVersion
in the test file (*_test.go
)testVersion
in the reference solution (example.go
)If the exercise does not have a test version, then add one, setting the value to 1.
See the version test in leap for an example.
The text was updated successfully, but these errors were encountered: