summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/42_assert
blob: e6200e90b069e70bbdaf8e1919e0517cb17b1ace (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 --