Changeset 8506 in project


Ignore:
Timestamp:
02/17/08 01:17:18 (12 years ago)
Author:
Kon Lovett
Message:

Bug fix for "hash-table-set!" - wasn't, setting that is.

Location:
chicken/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/buildsvnrevision

    r8504 r8506  
    1 8501
     18505
  • chicken/trunk/extras.scm

    r8380 r8506  
    21962196(define (hash-table-set! ht key val)
    21972197  (##sys#check-structure ht 'hash-table 'hash-table-set!)
    2198   (%hash-table-update! ht key identity (lambda () val))
     2198  (let ([thunk (lambda _ val)])
     2199    (%hash-table-update! ht key thunk thunk) )
    21992200  (void) )
    22002201
  • chicken/trunk/tests/hash-table-tests.scm

    r8278 r8506  
    4949(assert (eq? (hash-table-initial ht) 'foo))
    5050
    51 (print "HT - Insert")
     51(print "HT - Insert with setter")
    5252(set! (hash-table-ref ht 23.0) 'bar)
    5353(assert (eq? (hash-table-ref ht 23.0) 'bar))
     54
     55(print "HT - Insert with update!")
    5456(hash-table-update! ht 'baz)
    5557(assert (eq? (hash-table-ref ht 'baz) 'foo))
     
    6264  (assert (eq? (alist-ref 23.0 alist) 'bar))
    6365  (assert (eq? (alist-ref 'baz alist) 'foo)) )
     66
     67(print "HT - set! overwrites")
     68(hash-table-set! ht 23.0 'foo-bar)
     69(assert (eq? (hash-table-ref ht 23.0) 'foo-bar))
    6470
    6571(print "HT - Delete")
Note: See TracChangeset for help on using the changeset viewer.