109 lines
2.6 KiB
Plaintext
109 lines
2.6 KiB
Plaintext
;; Functions To Be Tested: All of chapter 6 of the IRM
|
|
;;
|
|
;; Source: IRM, p 6.1
|
|
;;
|
|
;; Chapter 6: HashArray
|
|
;;
|
|
;; Created By: Henry Cate III
|
|
;;
|
|
;; Creation Date: March 24, 1987
|
|
;;
|
|
;; Last Update:
|
|
;;
|
|
;; Filed As: {eris}<lispcore>test>DataTypes>HashArray.test
|
|
;;
|
|
;;
|
|
|
|
|
|
(do-test "test hasharray"
|
|
(and
|
|
(il:harrayp (il:hasharray 5))
|
|
(il:harrayp (il:hasharray 3 1.7))
|
|
T
|
|
))
|
|
|
|
|
|
(do-test "test harray"
|
|
(and
|
|
(il:harrayp (il:harray 5))
|
|
(il:harrayp (il:harray 10))
|
|
T
|
|
))
|
|
|
|
|
|
(do-test "test harrayprop"
|
|
(let* ((tempx (il:hasharray 10))
|
|
(tempy (il:hasharray 20 1.7)))
|
|
(and
|
|
(equal 0 (il:harrayprop tempx 'il:numkeys))
|
|
(equal 0 (il:harrayprop tempy 'il:numkeys))
|
|
(equal nil (il:harrayprop tempx 'il:overflow))
|
|
(equal 1.7 (il:harrayprop tempy 'il:overflow))
|
|
(equal 1.7 (il:harrayprop tempy 'il:overflow 1.8))
|
|
(equal 1.8 (il:harrayprop tempy 'il:overflow))
|
|
)))
|
|
|
|
|
|
(do-test "test harraysize"
|
|
(let* ((tempx (il:hasharray 10))
|
|
(tempy (il:hasharray 20 1.7)))
|
|
(and
|
|
(<= 10 (il:harraysize tempx))
|
|
(<= 20 (il:harraysize tempy))
|
|
)))
|
|
|
|
|
|
(do-test "test clrhash"
|
|
(let* ((tempx (il:hasharray 10))
|
|
(tempy (il:hasharray 20 1.7)))
|
|
(and
|
|
(il:puthash 'key "The value" tempy)
|
|
(il:harrayp (il:clrhash tempx))
|
|
(il:harrayp (il:clrhash tempy))
|
|
T
|
|
)))
|
|
|
|
|
|
(do-test "test puthash & gethash"
|
|
(let* ((tempx (il:hasharray 10))
|
|
(tempy (il:hasharray 20 1.7)))
|
|
(and
|
|
(equal 3.141592 (il:puthash 'pi 3.141592 tempx))
|
|
(equal 3.141592 (il:gethash 'pi tempx))
|
|
(equal 1 (il:harrayprop tempx 'il:numkeys))
|
|
(equal 2.71828 (il:puthash 'e 2.71828 tempx))
|
|
(equal 2.71828 (il:gethash 'e tempx))
|
|
(equal 2 (il:harrayprop tempx 'il:numkeys))
|
|
(equal "A simple string" (il:puthash 'string "A simple string" tempy))
|
|
(equal "A simple string" (il:gethash 'string tempy))
|
|
(equal nil (il:gethash 'should-not-find tempx))
|
|
)))
|
|
|
|
|
|
(do-test "test rehash"
|
|
(let* ((tempx (il:hasharray 10))
|
|
(tempy (il:hasharray 20 1.7)))
|
|
(and
|
|
(equal 3.141592 (il:puthash 'pi 3.141592 tempx))
|
|
(il:harrayp (il:rehash tempx tempy))
|
|
(equal 3.141592 (il:gethash 'pi tempy))
|
|
(equal 1 (il:harrayprop tempy 'il:numkeys))
|
|
)))
|
|
|
|
|
|
(do-test "test maphash"
|
|
(let* ((tempx (il:hasharray 10))
|
|
(tempy '(start)))
|
|
(and
|
|
(equal 3.141592 (il:puthash 'pi 3.141592 tempx))
|
|
(il:harrayp (il:maphash tempx
|
|
(function (lambda (val key) (push (list val key) tempy)))))
|
|
(equal '(3.141592 PI) (first tempy))
|
|
)))
|
|
|
|
|
|
|
|
|
|
STOP
|
|
|