mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-13 09:55:35 +03:00
1.4 KiB
1.4 KiB
Tests the Failures generated by builtin functions.
There are three places that the builtins build Failures. One is for builtins that return Either Failure, one is for builtins that use the Exception ability directly, and the last is code validation. I don't have an easy way to test the last at the moment, but the other two are tested here.
test1 : '{IO, Exception} [Result]
test1 = do
dir = !getTempDirectory
f = openFile (dir ++ "/failure-test") Write
closeFile f
isFileEOF f
[Ok "test1"]
test2 : '{IO, Exception} [Result]
test2 = do
tryEval '(bug "whoa")
[Ok "test2"]
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
test1 : '{IO, Exception} [Result]
test2 : '{IO, Exception} [Result]
.> add
⍟ I've added these definitions:
test1 : '{IO, Exception} [Result]
test2 : '{IO, Exception} [Result]
.> io.test test1
💔💥
The program halted with an unhandled exception:
Failure
(typeLink IOFailure)
"/tmp/failure-test: hIsEOF: illegal operation (handle is closed)"
(Any ())
.> io.test test2
💔💥
The program halted with an unhandled exception:
Failure (typeLink RuntimeFailure) "builtin.bug" (Any "whoa")