-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add Examples / Unit Tests for Exceptions #775
Add Examples / Unit Tests for Exceptions #775
Conversation
Test Error: for Currently working on better and more natural examples which occur in the programflow without the need of these two functions |
I'm not sure about the value of testing all the different exceptions as in types: effekt/libraries/common/exception.effekt Lines 108 to 121 in 112bc87
result.effekt too :)
|
Thank you for your input and help, I really appreciate it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few style-related nitpicks, but otherwise LGTM, thanks!
Resolves #480. |
@@ -60,9 +58,9 @@ def main() = { | |||
finalizeTestException { str.generalOperation(0) } // Test: Finalizer | |||
finalizeTestException { str.generalOperation(1) } // Test: Finalizer hello | |||
|
|||
// Test for "reifying" an Exception using Result | |||
// Test for "reifying" an Exception usix^xng Result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Test for "reifying" an Exception usix^xng Result | |
// Test for "reifying" an Exception using Result |
typo :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking over it!:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, let's ship it!
## Motivation Resolves effekt-lang#480 This module demonstrates exception handling combinators in Effekt using a simple, focused example. By showcasing custom exception handling (`TestException`) with different strategies (default handling, ignoring, reporting, finalizing), it provides a practical guide for understanding these features. ## Changes - Introduced `TestException` as a custom exception type, independent of other exceptions like `OutOfBounds`. - Added `generalOperation`, which raises a `TestException` for invalid input or returns a string. - Included tests for handling exceptions with: - Default behavior - Ignoring exceptions - Reporting exceptions - Finalization hooks - "Reifying" with Results ## Testing The examples are self-contained in the `main` function, covering all provided exception-handling strategies. Each approach is tested and outputs expected results for validation (`combinators.check`).
Motivation
Resolves #480
This module demonstrates exception handling combinators in Effekt using a simple, focused example. By showcasing custom exception handling (
TestException
) with different strategies (default handling, ignoring, reporting, finalizing), it provides a practical guide for understanding these features.Changes
TestException
as a custom exception type, independent of other exceptions likeOutOfBounds
.generalOperation
, which raises aTestException
for invalid input or returns a string.Testing
The examples are self-contained in the
main
function, covering all provided exception-handling strategies. Each approach is tested and outputs expected results for validation (combinators.check
).