Skip to content

Commit

Permalink
chore: consolidate try/finally tests (#4654)
Browse files Browse the repository at this point in the history
The error message for `finally { ... async ... }` is a bit bizarre, but for now I can live with it.
  • Loading branch information
ggreif authored Aug 9, 2024
1 parent 555cd75 commit 5bfe4db
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
7 changes: 4 additions & 3 deletions test/fail/ok/try-finally.tc.ok
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
try-finally.mo:10.26-10.29: type error [M0047], send capability required, but not available
(need an enclosing async expression or function body)
try-finally.mo:16.19-16.37: type error [M0039], misplaced throw
try-finally.mo:22.19-22.21: type error [M0050], literal of type
try-finally.mo:22.26-22.34: type error [M0037], misplaced async expression; try enclosing in an async function
try-finally.mo:28.19-28.21: type error [M0050], literal of type
Nat
does not have expected type
()
try-finally.mo:28.19-28.25: type error [M0085], misplaced return
try-finally.mo:34.25-34.28: type error [M0083], unbound label out
try-finally.mo:34.19-34.25: type error [M0085], misplaced return
try-finally.mo:40.25-40.28: type error [M0083], unbound label out
11 changes: 8 additions & 3 deletions test/fail/try-finally.mo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { error } = "mo:⛔";
import { error } = "mo:⛔";

actor A {
func m() : async () {
Expand All @@ -10,12 +10,18 @@ actor A {
finally { ignore m() } // BAD: no effects allowed!
};

func _t1() : async () {
func _t1a() : async () {
try { await m() }
catch _ {}
finally { throw error "Nope" } // BAD: has effect.
};

func _t1b() : async () {
try { await m() }
catch _ {}
finally { ignore async {} } // BAD: has effect. Weird error...
};

func _t2() : async () {
try { await m() }
catch _ {}
Expand All @@ -33,5 +39,4 @@ actor A {
catch _ {}
finally { break out } // BAD: no outward edges allowed!
};

}
1 change: 0 additions & 1 deletion test/run-drun/ok/try-finally-bug.tc.ok

This file was deleted.

1 change: 0 additions & 1 deletion test/run-drun/ok/try-finally-bug.tc.ret.ok

This file was deleted.

21 changes: 0 additions & 21 deletions test/run-drun/try-finally-bug.mo

This file was deleted.

0 comments on commit 5bfe4db

Please sign in to comment.