Changeset 14544 in project


Ignore:
Timestamp:
05/07/09 05:41:38 (10 years ago)
Author:
Kon Lovett
Message:

Replace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/lookup-table/trunk/tests/run.scm

    r14514 r14544  
    11;;;; lookup-table-test.scm
    22
    3 (use test lookup-table)
     3(use srfi-1 test lookup-table)
    44
    55;;;
     
    88
    99(define (dict-alist-test al tst)
    10   (let ((tbl1 (alist->dict al tst)))
     10  (let ((foodat (alist-ref 'foo al))
     11        (bazdat (alist-ref 'baz al))
     12        (allen (length al)))
    1113
    12     (test-assert (dict? tbl1))
    13     (test tst (dict-equivalence-function tbl1))
    14 
    15     (test-assert (tst 'bar (dict-ref tbl1 'foo)))
    16     (dict-delete! tbl1 'foo)
    17     (test-assert (not (dict-ref tbl1 'foo)))
    18 
    19     (test '() (dict-update! tbl1 'foo (lambda () '())))
    20     (test '(1) (dict-update! tbl1 'foo void (lambda (x) (append x '(1)))))
    21 
    22     (test '() (dict-update-list! tbl1 'list))
    23     (test '(1 2) (dict-update-list! tbl1 'list 1 2))
    24 
    25     (let ((tbl2 (dict-update-dict! tbl1 'dict)))
    26       (test-assert (dict? (dict-ref tbl1 'dict)))
    27       (test tbl2 (dict-ref tbl1 'dict))
    28       (test tbl2 (dict-update-dict! tbl1 'dict)) ) ) )
     14    (let ((tbl1 (alist->dict (list-copy al) tst)))
     15 
     16      (test-assert (dict? tbl1))
     17      (test tst (dict-equivalence-function tbl1))
     18 
     19      (test-assert (tst foodat (dict-ref tbl1 'foo)))
     20      (test-assert (begin (dict-delete! tbl1 'foo) #t))
     21      (test-assert (not (dict-ref tbl1 'foo)))
     22 
     23      (test '() (dict-update! tbl1 'foo (lambda () '())))
     24      (test '(1) (dict-update! tbl1 'foo void (lambda (x) (append x '(1)))))
     25 
     26      (test '() (dict-update-list! tbl1 'list))
     27      (test '(1 2) (dict-update-list! tbl1 'list 1 2))
     28 
     29      (let ((tbl2 (dict-update-dict! tbl1 'dict)))
     30        (test-assert (dict? (dict-ref tbl1 'dict)))
     31        (test tbl2 (dict-ref tbl1 'dict))
     32        (test tbl2 (dict-update-dict! tbl1 'dict)) ) )
     33 
     34    (let ((tbl (alist->dict (list-copy al) tst)))
     35      (test-assert (begin (dict-merge! tbl (alist->dict '((off . rab) (baz . pob)) tst)) #t))
     36      (test (+ allen 1) (dict-count tbl))
     37      (test foodat (dict-ref tbl 'foo))
     38      (test 'pob (dict-ref tbl 'baz))
     39      (test 'rab (dict-ref tbl 'off)) ) )
     40)
    2941
    3042;;
    3143
    32 ;Checks new order for 'make-dict'
    3344(define (dict-ht-test)
    3445  (let ((tbl1 (make-dict equal? 2)))
     
    4152
    4253    (test 20 (dict-ref tbl1 "20"))
    43     (dict-delete! tbl1 "20")
     54    (test-assert (begin (dict-delete! tbl1 "20") #t))
    4455    (test-assert (not (dict-ref tbl1 "20")))
    4556
    46     (dict-merge! tbl1 (alist->dict '((foo . bar) (baz . bop)) equal?))
     57    (test-assert (begin (dict-merge! tbl1 (alist->dict '((foo . bar) (baz . bop)) equal?)) #t))
    4758
    4859    (test 'bop (dict-ref tbl1 'baz))
     
    5061    (test 'bar (dict-search tbl1 (lambda (key val) (eq? key 'foo))))
    5162
    52     (with-output-to-string (lambda () (dict-print tbl1))) ) )
     63    (dict-print tbl1)
     64    #;(with-output-to-string (lambda () (dict-print tbl1))) )
     65)
    5366
    5467;;;
Note: See TracChangeset for help on using the changeset viewer.