diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-01-29 23:31:16 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-02-03 17:22:43 +0100 |
commit | 7edad5cefa0f065aa83dffd2d7830aeaf9f38662 (patch) | |
tree | 86b727f434302ffb28cb59278243517f9765e170 /tests/custom/03_stdlib/02_die | |
parent | d5003fde57eab19588da7bfdbaefe93d47435eb6 (diff) |
tests: add functional tests for builtin functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests/custom/03_stdlib/02_die')
-rw-r--r-- | tests/custom/03_stdlib/02_die | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/02_die b/tests/custom/03_stdlib/02_die new file mode 100644 index 0000000..344069a --- /dev/null +++ b/tests/custom/03_stdlib/02_die @@ -0,0 +1,49 @@ +The `die()` function triggers a user defined runtime exception when invoked, +using the given value as exception message. + +The given message value is converted to a string internally if it is not a +string already. If no message argument is given or if the message argument +is `null`, the default message is `Died`. + +The function does not return. + +-- Testcase -- +{% + print("Before invoking die()\n"); + + die("An exception!"); + + print("After invoking die()\n"); +%} +-- End -- + +-- Expect stdout -- +Before invoking die() +-- End -- + +-- Expect stderr -- +An exception! +In line 4, byte 21: + + ` die("An exception!");` + Near here -------------^ + + +-- End -- + + +-- Testcase -- +{% + die(); +%} +-- End -- + +-- Expect stderr -- +Died +In line 2, byte 6: + + ` die();` + ^-- Near here + + +-- End -- |