1(include "#.scm") 2 3(define tg (make-thread-group)) 4 5(define t1 (make-thread (lambda () 111))) 6 7(define t2 (make-thread (lambda () 222) 8 't2)) 9 10(define t3 (make-thread (lambda () 333) 11 't3 12 tg)) 13 14(define t4 (make-root-thread (lambda () 444))) 15 16(define t5 (make-root-thread (lambda () 555) 17 't5)) 18 19(define t6 (make-root-thread (lambda () 666) 20 't6 21 tg)) 22 23(define t7 (make-root-thread (lambda () 777) 24 't7 25 tg 26 (current-input-port))) 27 28(define t8 (make-root-thread (lambda () 888) 29 't8 30 tg 31 (current-input-port) 32 (current-output-port))) 33 34(define-type-of-thread mythread) 35 36(define t10 (make-mythread)) ;; create some uninitialized threads 37(define t11 (make-mythread)) 38(define t12 (make-mythread)) 39(define t13 (make-mythread)) 40 41(check-equal? (thread-specific t1) (void)) 42(check-equal? (thread-specific t2) (void)) 43(check-equal? (thread-specific t3) (void)) 44(check-equal? (thread-specific t4) (void)) 45(check-equal? (thread-specific t5) (void)) 46(check-equal? (thread-specific t6) (void)) 47(check-equal? (thread-specific t7) (void)) 48(check-equal? (thread-specific t8) (void)) 49(check-equal? (thread-specific t10) (void)) 50(check-equal? (thread-specific t11) (void)) 51(check-equal? (thread-specific t12) (void)) 52(check-equal? (thread-specific t13) (void)) 53 54(check-equal? (thread-specific-set! t1 111) (void)) 55(check-equal? (thread-specific-set! t2 222) (void)) 56(check-equal? (thread-specific-set! t3 333) (void)) 57(check-equal? (thread-specific-set! t4 444) (void)) 58(check-equal? (thread-specific-set! t5 555) (void)) 59(check-equal? (thread-specific-set! t6 666) (void)) 60(check-equal? (thread-specific-set! t7 777) (void)) 61(check-equal? (thread-specific-set! t8 888) (void)) 62(check-equal? (thread-specific-set! t10 101010) (void)) 63(check-equal? (thread-specific-set! t11 111111) (void)) 64(check-equal? (thread-specific-set! t12 121212) (void)) 65(check-equal? (thread-specific-set! t13 131313) (void)) 66 67(check-equal? (thread-specific t1) 111) 68(check-equal? (thread-specific t2) 222) 69(check-equal? (thread-specific t3) 333) 70(check-equal? (thread-specific t4) 444) 71(check-equal? (thread-specific t5) 555) 72(check-equal? (thread-specific t6) 666) 73(check-equal? (thread-specific t7) 777) 74(check-equal? (thread-specific t8) 888) 75(check-equal? (thread-specific t10) 101010) 76(check-equal? (thread-specific t11) 111111) 77(check-equal? (thread-specific t12) 121212) 78(check-equal? (thread-specific t13) 131313) 79 80(check-eq? (thread-init! t10 81 (lambda () 101010)) 82 t10) 83 84(check-eq? (thread-init! t11 85 (lambda () 111111) 86 't11) 87 t11) 88 89(check-eq? (thread-init! t12 90 (lambda () 121212) 91 't12 92 tg) 93 t12) 94 95(check-equal? (thread-specific t10) 101010) 96(check-equal? (thread-specific t11) 111111) 97(check-equal? (thread-specific t12) 121212) 98 99(check-eq? (thread-join! (thread-start! t1)) 111) 100(check-eq? (thread-join! (thread-start! t2)) 222) 101(check-eq? (thread-join! (thread-start! t3)) 333) 102(check-eq? (thread-join! (thread-start! t4)) 444) 103(check-eq? (thread-join! (thread-start! t5)) 555) 104(check-eq? (thread-join! (thread-start! t6)) 666) 105(check-eq? (thread-join! (thread-start! t7)) 777) 106(check-eq? (thread-join! (thread-start! t8)) 888) 107(check-eq? (thread-join! (thread-start! t10)) 101010) 108(check-eq? (thread-join! (thread-start! t11)) 111111) 109(check-eq? (thread-join! (thread-start! t12)) 121212) 110 111(check-equal? (thread-specific t1) 111) 112(check-equal? (thread-specific t2) 222) 113(check-equal? (thread-specific t3) 333) 114(check-equal? (thread-specific t4) 444) 115(check-equal? (thread-specific t5) 555) 116(check-equal? (thread-specific t6) 666) 117(check-equal? (thread-specific t7) 777) 118(check-equal? (thread-specific t8) 888) 119(check-equal? (thread-specific t10) 101010) 120(check-equal? (thread-specific t11) 111111) 121(check-equal? (thread-specific t12) 121212) 122(check-equal? (thread-specific t13) 131313) 123 124(check-tail-exn type-exception? (lambda () (thread-specific #f))) 125(check-tail-exn type-exception? (lambda () (thread-specific-set! #f #f))) 126 127(check-tail-exn wrong-number-of-arguments-exception? (lambda () (thread-specific))) 128(check-tail-exn wrong-number-of-arguments-exception? (lambda () (thread-specific t1 #f))) 129 130(check-tail-exn wrong-number-of-arguments-exception? (lambda () (thread-specific-set!))) 131(check-tail-exn wrong-number-of-arguments-exception? (lambda () (thread-specific-set! t1))) 132(check-tail-exn wrong-number-of-arguments-exception? (lambda () (thread-specific-set! t1 #f #f))) 133