summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/42_assert
diff options
context:
space:
mode:
Diffstat (limited to 'tests/custom/03_stdlib/42_assert')
-rw-r--r--tests/custom/03_stdlib/42_assert30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/42_assert b/tests/custom/03_stdlib/42_assert
new file mode 100644
index 0000000..e6200e9
--- /dev/null
+++ b/tests/custom/03_stdlib/42_assert
@@ -0,0 +1,30 @@
+The `assert()` function raises an exception using the second argument as
+message when the first argument value is not truish.
+
+Throws an exception if the first argument value is not truish.
+
+Returns the value of the first argument.
+
+-- Testcase --
+{%
+ let x = assert(123, "This should not trigger");
+ printf("x = %d\n", x);
+
+ let y = assert(false, "This should trigger");
+ printf("y = %d\n", y);
+%}
+-- End --
+
+-- Expect stdout --
+x = 123
+-- End --
+
+-- Expect stderr --
+This should trigger
+In line 5, byte 45:
+
+ ` let y = assert(false, "This should trigger");`
+ Near here -------------------------------------^
+
+
+-- End --