unison/unison-src/transcripts-using-base/failure-tests.output.md
Greg Pfeil 0031542faf
Add a space before code block info strings
This is for consistency with the `cmark` style. Now the blocks we still
pretty-print ourselves will match the bulk of them that `cmark`
produces.
2024-07-10 13:56:07 -06:00

1.5 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
  _ = fromUtf8 0xsee
  [Ok "test1"]

test2 : '{IO, Exception} [Result]
test2 = do
  _ = tryEval '(bug "whoa")
  [Ok "test2"]

  Loading changes detected in scratch.u.

  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]

scratch/main> add

  ⍟ I've added these definitions:
  
    test1 : '{IO, Exception} [Result]
    test2 : '{IO, Exception} [Result]

scratch/main> io.test test1

  💔💥
  
  The program halted with an unhandled exception:
  
    Failure
      (typeLink IOFailure)
      "Cannot decode byte '\\xee': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream"
      (Any ())
  
  Stack trace:
    ##raise

scratch/main> io.test test2

  💔💥
  
  The program halted with an unhandled exception:
  
    Failure (typeLink RuntimeFailure) "builtin.bug" (Any "whoa")
  
  Stack trace:
    ##raise