diff --git a/inputs/passing/exceptions/finallyWithoutThrow.ts b/inputs/passing/exceptions/finallyWithoutThrow.ts new file mode 100644 index 0000000..467780c --- /dev/null +++ b/inputs/passing/exceptions/finallyWithoutThrow.ts @@ -0,0 +1,12 @@ +// test_output! "Ok" + +export default function () { + let result: string; + + try { + } finally { + result = "Ok"; + } + + return result; +} diff --git a/inputs/passing/exceptions/nestedTry.ts b/inputs/passing/exceptions/nestedTry.ts new file mode 100644 index 0000000..0d04600 --- /dev/null +++ b/inputs/passing/exceptions/nestedTry.ts @@ -0,0 +1,21 @@ +// test_output! ["here","nested boom","boom"] + +export default function () { + let logs: unknown[] = []; + + try { + logs.push("here"); + + try { + throw new Error("nested boom"); + } catch (error) { + logs.push(error.message); + } + + throw new Error("boom"); + } catch (error) { + logs.push(error.message); + } + + return logs; +} diff --git a/inputs/passing/exceptions/tryCatch.ts b/inputs/passing/exceptions/tryCatch.ts new file mode 100644 index 0000000..8ded5b6 --- /dev/null +++ b/inputs/passing/exceptions/tryCatch.ts @@ -0,0 +1,9 @@ +// test_output! Error{"message":"Something went wrong"} + +export default function () { + try { + throw new Error("Something went wrong"); + } catch (error) { + return error; + } +} diff --git a/inputs/passing/exceptions/tryCatchFinally.ts b/inputs/passing/exceptions/tryCatchFinally.ts new file mode 100644 index 0000000..57f38fb --- /dev/null +++ b/inputs/passing/exceptions/tryCatchFinally.ts @@ -0,0 +1,11 @@ +// test_output! E: Error{"message":"teraboom"} + +export default function () { + try { + throw new Error("boom"); + } catch { + throw new Error("megaboom"); + } finally { + throw new Error("teraboom"); + } +} diff --git a/inputs/passing/exceptions/tryFinally.ts b/inputs/passing/exceptions/tryFinally.ts new file mode 100644 index 0000000..904d14d --- /dev/null +++ b/inputs/passing/exceptions/tryFinally.ts @@ -0,0 +1,9 @@ +// test_output! E: Error{"message":"Something went wrong"} + +export default function () { + try { + throw new Error("Something went wrong"); + } finally { + 1 + 1; + } +} diff --git a/inputs/passing/exceptions/tryReturnFinallyReturn.ts b/inputs/passing/exceptions/tryReturnFinallyReturn.ts new file mode 100644 index 0000000..fe6ba65 --- /dev/null +++ b/inputs/passing/exceptions/tryReturnFinallyReturn.ts @@ -0,0 +1,9 @@ +// test_output! 42 + +export default function () { + try { + return 37; + } finally { + return 42; + } +}