Created
May 21, 2014 04:31
-
-
Save yrashk/3c1257e864daa13f38a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestErr(t *testing.T) { | |
passed := false | |
handled := false | |
err.Handle("this kind of failure", func(e error) { | |
handled = true | |
}). | |
Handle("that kind of failure", func(e error) { | |
}). | |
Run(func(h err.H) { | |
v := h(err.Ignore)(exampleFunction()) | |
assert.Equal(t, v, 1) | |
passed = true | |
h("this kind of failure")(exampleFunction()) | |
passed = false | |
}) | |
assert.True(t, passed) | |
assert.True(t, handled) | |
} | |
func exampleFunction() (int, error) { | |
return 1, errors.New("some error") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment