/usr/share/scheme48-1.9/big/tconc-queue-check.scm is in scheme48 1.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | ; Part of Scheme 48 1.9. See file COPYING for notices and license.
; Authors: Marcus Crestani
(define-test-suite tconc-queue-tests)
(define max-queue-size 999)
(define (check-raises-assertion-violation thunk source)
(call-with-current-continuation
(lambda (esc)
(with-exception-handler
(lambda (c)
(esc
(call-with-values
(lambda () (decode-condition c))
(lambda (type who message more-stuff)
(check type => 'assertion-violation)
(check who => source)))))
(lambda ()
(thunk)
(check #f => 'should-never-reach-this-point))))))
(define-test-case constructor-predicate tconc-queue-tests
(check-that
(tconc-queue? (make-tconc-queue))
(is-true)))
(define-test-case empty tconc-queue-tests
(check-that
(tconc-queue-empty? (make-tconc-queue))
(is-true)))
(define-test-case non-empty tconc-queue-tests
(let ((q (make-tconc-queue)))
(tconc-queue-enqueue! q 23)
(check-that
(tconc-queue-empty? q)
(is-false))))
(define-test-case dequeue-empty tconc-queue-tests
(let ((q (make-tconc-queue)))
(check-raises-assertion-violation
(lambda () (tconc-queue-dequeue! q))
'tconc-queue-dequeue)))
(define-test-case peek-empty tconc-queue-tests
(let ((q (make-tconc-queue)))
(check-raises-assertion-violation
(lambda () (tconc-queue-peek q))
'tconc-queue-peek)))
(define-test-case size tconc-queue-tests
(do-ec
(:range n 0 max-queue-size)
(let ((q (make-tconc-queue)))
(do-ec
(:range m 0 n)
(tconc-queue-enqueue! q m))
(check (tconc-queue-size q) => n)
(check-that (tconc-queue? q) (is-true)))))
(define-test-case dequeue-1 tconc-queue-tests
(let ((q (make-tconc-queue)))
(tconc-queue-enqueue! q 23)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-peek q) => 23)
(check (tconc-queue-dequeue! q) => 23)
(check-that (tconc-queue? q) (is-true))))
(define-test-case dequeue-2 tconc-queue-tests
(let ((q (make-tconc-queue)))
(tconc-queue-enqueue! q 23)
(check-that (tconc-queue? q) (is-true))
(tconc-queue-enqueue! q 42)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-peek q) => 23)
(check (tconc-queue-dequeue! q) => 23)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-peek q) => 42)
(check (tconc-queue-dequeue! q) => 42)
(check-that (tconc-queue? q) (is-true))))
(define-test-case en/dequeue-2 tconc-queue-tests
(let ((q (make-tconc-queue)))
(tconc-queue-enqueue! q 23)
(check (tconc-queue-peek q) => 23)
(check (tconc-queue-dequeue! q) => 23)
(tconc-queue-enqueue! q 42)
(check (tconc-queue-peek q) => 42)
(check (tconc-queue-dequeue! q) => 42)))
(define-test-case en/dequeue-3 tconc-queue-tests
(let ((q (make-tconc-queue)))
(tconc-queue-enqueue! q 23)
(check-that (tconc-queue? q) (is-true))
(tconc-queue-enqueue! q 65)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-peek q) => 23)
(check (tconc-queue-dequeue! q) => 23)
(check (tconc-queue-peek q) => 65)
(check (tconc-queue-dequeue! q) => 65)
(tconc-queue-enqueue! q 42)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-peek q) => 42)
(check (tconc-queue-dequeue! q) => 42)))
(define-test-case enqueue-n/dequeue-n tconc-queue-tests
(do-ec
(:range n 0 max-queue-size)
(let ((q (make-tconc-queue)))
(do-ec
(:range m 0 n)
(begin
(tconc-queue-enqueue! q m)
(check (tconc-queue-peek q) => 0)))
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-size q) => n)
(do-ec
(:range m 0 n)
(begin
(check (tconc-queue-peek q) => m)
(check (tconc-queue-dequeue! q) => m)))
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-size q) => 0)
(check-raises-assertion-violation
(lambda () (tconc-queue-peek q))
'tconc-queue-peek)
(check-raises-assertion-violation
(lambda () (tconc-queue-dequeue! q))
'tconc-queue-dequeue))))
(define-test-case en/dequeue-n tconc-queue-tests
(do-ec
(:range n 0 max-queue-size)
(let ((q (make-tconc-queue)))
(do-ec
(:range m 0 n)
(begin
(tconc-queue-enqueue! q m)
(check (tconc-queue-size q) => 1)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-peek q) => m)
(check (tconc-queue-dequeue! q) => m)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-size q) => 0)))
(check-raises-assertion-violation
(lambda () (tconc-queue-peek q))
'tconc-queue-peek)
(check-raises-assertion-violation
(lambda () (tconc-queue-dequeue! q))
'tconc-queue-dequeue))))
(define-test-case en/clear/dequeue-n tconc-queue-tests
(let ((q (make-tconc-queue)))
(do-ec
(:range n 0 max-queue-size)
(begin
(tconc-queue-clear! q)
(check-that (tconc-queue-empty? q) (is-true))
(do-ec
(:range m 0 n)
(begin
(tconc-queue-enqueue! q m)
(check (tconc-queue-size q) => 1)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-peek q) => m)
(check (tconc-queue-dequeue! q) => m)
(check-that (tconc-queue? q) (is-true))
(check (tconc-queue-size q) => 0)))
(check-raises-assertion-violation
(lambda () (tconc-queue-peek q))
'tconc-queue-peek)
(check-raises-assertion-violation
(lambda () (tconc-queue-dequeue! q))
'tconc-queue-dequeue)))))
|