| 1 |
|
| 2 |
(library (tests symbol-table) |
| 3 |
(export run-tests) |
| 4 |
(import |
| 5 |
(ikarus) |
| 6 |
(only (ikarus system $symbols) $symbol-table-size)) |
| 7 |
|
| 8 |
(define (test-gcable-symbols n) |
| 9 |
(let ([st1 ($symbol-table-size)]) |
| 10 |
(do ((i 0 (+ i 1))) |
| 11 |
((= i n)) |
| 12 |
(string->symbol (number->string i))) |
| 13 |
(collect) |
| 14 |
(let ([st2 ($symbol-table-size)]) |
| 15 |
(assert (< (- st2 st1) n))))) |
| 16 |
|
| 17 |
|
| 18 |
(define (test-reference-after-gc) |
| 19 |
(define random-string |
| 20 |
(lambda (n) |
| 21 |
(list->string |
| 22 |
(map (lambda (n) |
| 23 |
(integer->char (+ (char->integer #\a) (random 26)))) |
| 24 |
(make-list n))))) |
| 25 |
(newline) |
| 26 |
(let ([str1 (random-string 70)] |
| 27 |
[str2 (random-string 70)]) |
| 28 |
(printf "sym1=~s\n" (string->symbol str1)) |
| 29 |
(do ((i 0 (+ i 1))) ((= i 1024)) (collect)) |
| 30 |
(let ([sym1 (string->symbol str1)]) |
| 31 |
(printf "sym1=~s\n" (string->symbol str1)) |
| 32 |
(printf "sym2=~s\n" (string->symbol str2)) |
| 33 |
(let ([sym3 (string->symbol str1)]) |
| 34 |
(printf "sym3=~s\n" (string->symbol str1)) |
| 35 |
(assert (eq? sym1 sym3)))))) |
| 36 |
|
| 37 |
|
| 38 |
(define (run-tests) |
| 39 |
(test-gcable-symbols 1000000) |
| 40 |
(test-reference-after-gc))) |
| 41 |
|
| 42 |
|