summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/41_sleep
blob: bca6f0d5507e752c128bf1ae937bfad6976d75a4 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
The `sleep()` function pauses program execution for the given amount of
milliseconds.

Returns `true` if the program slept.

Returns `false` when the given time value was not convertible to an integer,
negative or zero.

-- Testcase --
{%
	let t1 = time();

	sleep(1000);

	let t2 = time();

	printf("Slept for %d second(s).\n", t2 - t1);
%}
-- End --

-- Expect stdout --
Slept for 1 second(s).
-- End --


Passing an invalid value yields `false`.

-- Testcase --
{%
	printf("%.J\n", [
		sleep("inval"),
		sleep([]),
		sleep(-1),
		sleep(0)
	]);
%}
-- End --

-- Expect stdout --
[
	false,
	false,
	false,
	false
]
-- End --