Skip to content

Add stdlib tests for Exception module#333

Closed
Copilot wants to merge 2 commits intostdlib-exceptionfrom
copilot/sub-pr-332
Closed

Add stdlib tests for Exception module#333
Copilot wants to merge 2 commits intostdlib-exceptionfrom
copilot/sub-pr-332

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 24, 2026

lib/Exception.fram had no accompanying stdlib tests. Adds test/stdlib/Exception.fram covering the core behavioral properties of hException.

Changes

  • test/stdlib/Exception.fram — six test cases:

    • normal return passes through — handler not invoked when no raise occurs
    • raise triggers handler — handler receives the raised value and its result is returned
    • raise does not resume — continuation after raise is abandoned
    • inner exception caught by inner handler — capability identity determines which handler fires
    • outer exception skips inner handler — raise on an outer capability passes through inner handler
    • exception inside state handler — nesting with hState: exception result replaces the state computation's return value
  • test/stdlib/TestAll.fram — adds import Exception to include the new tests in the suite

let _ = testCase "raise does not resume" (fn _ =>
  let executed = ~mut.ref False in
  let _ = handle exc with hException (fn _ => ()) in
    exc.raise ();
    executed := True
  in
  assertFalse executed.get)

let _ = testCase "outer exception skips inner handler" (fn _ =>
  let result =
    handle exc with hException (fn _ => "outer") in
    handle _ with hException (fn _ => "inner") in
    exc.raise "error"
  in
  assertEqS result "outer")

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Co-authored-by: ppolesiuk <411894+ppolesiuk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fram-lang/dbl/sessions/511d51b2-5691-4e85-ba34-c02564a2733c
Copilot AI changed the title [WIP] [WIP] Address feedback on exception handling tests implementation Add stdlib tests for Exception module Mar 24, 2026
Copilot AI requested a review from ppolesiuk March 24, 2026 13:22
@ppolesiuk
Copy link
Copy Markdown
Member

The tests are already included in the target branch, so this PR can be closed now.

@ppolesiuk ppolesiuk closed this Mar 24, 2026
@ppolesiuk ppolesiuk deleted the copilot/sub-pr-332 branch March 24, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants