diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
| commit | f1454bbbd13a71da2005ff789cde2da0e9eb81f6 (patch) | |
| tree | 37131187f4218dd3ebec049101c28a161e7ca289 /spec/inputs/test/try_catch_spec.yue | |
| parent | 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (diff) | |
| download | yuescript-main.tar.gz yuescript-main.tar.bz2 yuescript-main.zip | |
Diffstat (limited to 'spec/inputs/test/try_catch_spec.yue')
| -rw-r--r-- | spec/inputs/test/try_catch_spec.yue | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/inputs/test/try_catch_spec.yue b/spec/inputs/test/try_catch_spec.yue new file mode 100644 index 0000000..ed8fef0 --- /dev/null +++ b/spec/inputs/test/try_catch_spec.yue | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | describe "try/catch", -> | ||
| 2 | it "catch and rethrow", -> | ||
| 3 | ok, success, err = pcall -> | ||
| 4 | try | ||
| 5 | error "boom" | ||
| 6 | catch e | ||
| 7 | _, result = try | ||
| 8 | error "wrap:" .. e\match "^.-:%d+:%s*(.*)$" | ||
| 9 | result | ||
| 10 | assert.same ok, true | ||
| 11 | assert.same success, false | ||
| 12 | assert.is_true err\match("wrap:boom") != nil | ||
