1 The `sleep()` function pauses program execution for the given amount of 2 milliseconds. 3 4 Returns `true` if the program slept. 5 6 Returns `false` when the given time value was not convertible to an integer, 7 negative or zero. 8 9 -- Testcase -- 10 {% 11 let t1 = time(); 12 13 sleep(1000); 14 15 let t2 = time(); 16 17 if (t2 > t1) 18 printf("Slept for at least one second.\n"); 19 else 20 printf("Unexpected time delta: %d\n", t2 - t1); 21 %} 22 -- End -- 23 24 -- Expect stdout -- 25 Slept for at least one second. 26 -- End -- 27 28 29 Passing an invalid value yields `false`. 30 31 -- Testcase -- 32 {% 33 printf("%.J\n", [ 34 sleep("inval"), 35 sleep([]), 36 sleep(-1), 37 sleep(0) 38 ]); 39 %} 40 -- End -- 41 42 -- Expect stdout -- 43 [ 44 false, 45 false, 46 false, 47 false 48 ] 49 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt