prehash-for-perfect-hash: add truly-thes.
[sbcl.git] / tests / sleepytests.pure.lisp
blob48d52ebcf054848112208cd9befb8cc3d74eac5c
1 ;;; WITH-TIMEOUT should accept more than one form in its body.
2 (with-test (:name (sb-ext:with-timeout :forms) :slow t)
3 (handler-bind ((sb-ext:timeout #'continue))
4 (sb-ext:with-timeout 3
5 (sleep 2)
6 (sleep 2))))
8 ;;; SLEEP should not cons except on 32-bit platforms when
9 ;;; (> (mod seconds 1) (* most-positive-fixnum 1e-9))
10 (with-test (:name (sleep :non-consing)
11 :serial t :skipped-on :interpreter)
12 (handler-case (sb-ext:with-timeout 5
13 (ctu:assert-no-consing (sleep 0.00001s0))
14 (locally (declare (notinline sleep))
15 (ctu:assert-no-consing (sleep 0.00001s0))
16 (ctu:assert-no-consing (sleep 0.00001d0))
17 (ctu:assert-no-consing (sleep 1/100000003))))
18 (timeout ())))
20 ;;; Changes to make SLEEP cons less led to SLEEP
21 ;;; not sleeping at all on 32-bit platforms when
22 ;;; (> (mod seconds 1) (* most-positive-fixnum 1e-9)).
23 (with-test (:name (sleep :bug-1194673))
24 (assert (eq :timeout
25 (handler-case
26 (with-timeout 0.01
27 (sleep 0.6))
28 (timeout ()
29 :timeout)))))
31 ;;; SLEEP should work with large integers as well
32 (with-test (:name (sleep :pretty-much-forever)
33 :skipped-on (:and (:or :linux :darwin) :sb-safepoint)) ; hangs
34 (assert (eq :timeout
35 (handler-case
36 (sb-ext:with-timeout 1
37 (sleep (ash 1 (* 2 sb-vm:n-word-bits))))
38 (sb-ext:timeout ()
39 :timeout)))))
41 ;;; Check that SLEEP called with ratios (with no common factors with
42 ;;; 1000000000, and smaller than 1/1000000000) works more or less as
43 ;;; expected.
44 (with-test (:name (sleep ratio))
45 (let ((fun0a (checked-compile '(lambda () (sleep 1/7))))
46 (fun0b (checked-compile '(lambda () (sleep 1/100000000000000000000000000))))
47 (fun1 (checked-compile '(lambda (x) (sleep x))))
48 (start-time (get-universal-time)))
49 (sleep 1/7)
50 (sleep 1/100000000000000000000000000)
51 (funcall fun0a)
52 (funcall fun0b)
53 (funcall fun1 1/7)
54 (funcall fun1 1/100000000000000000000000000)
55 #-gc-stress
56 (assert (< (- (get-universal-time) start-time) 2))))
58 (with-test (:name (sleep :return-value))
59 (checked-compile-and-assert ()
60 `(lambda () (sleep 0.001))
61 (() nil)))