Mercurial > hg > xemacs-beta
changeset 1636:f062c28f4a11
[xemacs-hg @ 2003-08-20 11:53:41 by crestani]
2003-08-19 Marcus Crestani <crestani@informatik.uni-tuebingen.de>
Markus Kaltenbach <makalten@informatik.uni-tuebingen.de>
* automated/weak-tests.el: Added tests for weak-lists.
author | crestani |
---|---|
date | Wed, 20 Aug 2003 11:53:44 +0000 |
parents | 7107ed3b2272 |
children | d14b4fa995df |
files | tests/ChangeLog tests/automated/weak-tests.el |
diffstat | 2 files changed, 160 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/ChangeLog Tue Aug 19 21:52:16 2003 +0000 +++ b/tests/ChangeLog Wed Aug 20 11:53:44 2003 +0000 @@ -1,3 +1,8 @@ +2003-08-19 Marcus Crestani <crestani@informatik.uni-tuebingen.de> + Markus Kaltenbach <makalten@informatik.uni-tuebingen.de> + + * automated/weak-tests.el: Added tests for weak-lists. + 2003-08-10 Stephen J. Turnbull <stephen@xemacs.org> * automated/regexp-tests.el: Update copyright notice and
--- a/tests/automated/weak-tests.el Tue Aug 19 21:52:16 2003 +0000 +++ b/tests/automated/weak-tests.el Wed Aug 20 11:53:44 2003 +0000 @@ -26,7 +26,7 @@ ;;; Commentary: -;;; Test implementation of weak boxes and ephemerons +;;; Test implementation of weak boxes, ephemerons, and weak lists ;;; See test-harness.el (condition-case err @@ -37,6 +37,8 @@ (require 'test-harness)))) (garbage-collect) + +;; tests for weak-boxes (let ((w (make-weak-box (cons 2 3)))) (Assert (equal (cons 2 3) (weak-box-ref w))) (garbage-collect) @@ -44,6 +46,7 @@ (garbage-collect) +;; tests for ephemerons (let* ((p (cons 3 4)) (finalized-p nil) (eph1 (make-ephemeron (cons 1 2) p @@ -63,3 +66,154 @@ (Assert (eq p (ephemeron-ref eph2)))) +(garbage-collect) + +;; tests for simple weak-lists +(let* ((a (cons 23 42)) + (b (cons 42 65)) + (testlist (list a b)) + (weaklist1 (make-weak-list 'simple)) + (weaklist2 (make-weak-list 'simple)) + (weaklist3 (make-weak-list 'simple)) + (weaklist4 (make-weak-list 'simple))) + (set-weak-list-list weaklist1 testlist) + (set-weak-list-list weaklist2 (list (cons 1 2) a b)) + (set-weak-list-list weaklist3 (list a (cons 1 2) b)) + (set-weak-list-list weaklist4 (list a b (cons 1 2))) + (Assert (weak-list-p weaklist1)) + (Assert (eq (weak-list-type weaklist1) 'simple)) + (Assert (weak-list-p weaklist2)) + (Assert (eq (weak-list-type weaklist2) 'simple)) + (Assert (weak-list-p weaklist3)) + (Assert (eq (weak-list-type weaklist3) 'simple)) + (Assert (weak-list-p weaklist4)) + (Assert (eq (weak-list-type weaklist4) 'simple)) + + (garbage-collect) + + (Assert (eq (weak-list-list weaklist1) testlist)) + (Assert (equal (weak-list-list weaklist2) testlist)) + (Assert (equal (weak-list-list weaklist3) testlist)) + (Assert (equal (weak-list-list weaklist4) testlist))) + +(garbage-collect) + +;; tests for assoc weak-lists +(let* ((a (cons 23 42)) + (b (cons a a)) + (testlist (list b b)) + (weaklist1 (make-weak-list 'assoc)) + (weaklist2 (make-weak-list 'assoc)) + (weaklist3 (make-weak-list 'assoc)) + (weaklist4 (make-weak-list 'assoc))) + (set-weak-list-list weaklist1 testlist) + (set-weak-list-list weaklist2 (list b (cons (cons 1 2) a) b)) + (set-weak-list-list weaklist3 (list b (cons a (cons 1 2)) b)) + (set-weak-list-list weaklist4 (list b (cons (cons 1 2) (cons 3 4)) b)) + (Assert (weak-list-p weaklist1)) + (Assert (eq (weak-list-type weaklist1) 'assoc)) + (Assert (weak-list-p weaklist2)) + (Assert (eq (weak-list-type weaklist2) 'assoc)) + (Assert (weak-list-p weaklist3)) + (Assert (eq (weak-list-type weaklist3) 'assoc)) + (Assert (weak-list-p weaklist4)) + (Assert (eq (weak-list-type weaklist4) 'assoc)) + + (garbage-collect) + + (Assert (eq (weak-list-list weaklist1) testlist)) + (Assert (equal (weak-list-list weaklist2) testlist)) + (Assert (equal (weak-list-list weaklist3) testlist)) + (Assert (equal (weak-list-list weaklist4) testlist))) + +(garbage-collect) + +;; tests for key-assoc weak-lists +(let* ((a (cons 23 42)) + (b (cons a a)) + (testlist (list b b)) + (weaklist1 (make-weak-list 'key-assoc)) + (weaklist2 (make-weak-list 'key-assoc)) + (weaklist3 (make-weak-list 'key-assoc)) + (weaklist4 (make-weak-list 'key-assoc))) + (set-weak-list-list weaklist1 testlist) + (set-weak-list-list weaklist2 (list b (cons (cons 1 2) a) b)) + (set-weak-list-list weaklist3 (list b (cons a (cons 1 2)) b)) + (set-weak-list-list weaklist4 (list b (cons (cons 1 2) (cons 3 4)) b)) + (Assert (weak-list-p weaklist1)) + (Assert (eq (weak-list-type weaklist1) 'key-assoc)) + (Assert (weak-list-p weaklist2)) + (Assert (eq (weak-list-type weaklist2) 'key-assoc)) + (Assert (weak-list-p weaklist3)) + (Assert (eq (weak-list-type weaklist3) 'key-assoc)) + (Assert (weak-list-p weaklist4)) + (Assert (eq (weak-list-type weaklist4) 'key-assoc)) + + (garbage-collect) + + (Assert (eq (weak-list-list weaklist1) testlist)) + (Assert (equal (weak-list-list weaklist2) testlist)) + (Assert (equal (weak-list-list weaklist3) (list b (cons a (cons 1 2)) b))) + (Assert (equal (weak-list-list weaklist4) testlist))) + +(garbage-collect) + +;; tests for value-assoc weak-lists +(let* ((a (cons 23 42)) + (b (cons a a)) + (testlist (list b b)) + (weaklist1 (make-weak-list 'value-assoc)) + (weaklist2 (make-weak-list 'value-assoc)) + (weaklist3 (make-weak-list 'value-assoc)) + (weaklist4 (make-weak-list 'value-assoc))) + (set-weak-list-list weaklist1 testlist) + (set-weak-list-list weaklist2 (list b (cons (cons 1 2) a) b)) + (set-weak-list-list weaklist3 (list b (cons a (cons 1 2)) b)) + (set-weak-list-list weaklist4 (list b (cons (cons 1 2) (cons 3 4)) b)) + (Assert (weak-list-p weaklist1)) + (Assert (eq (weak-list-type weaklist1) 'value-assoc)) + (Assert (weak-list-p weaklist2)) + (Assert (eq (weak-list-type weaklist2) 'value-assoc)) + (Assert (weak-list-p weaklist3)) + (Assert (eq (weak-list-type weaklist3) 'value-assoc)) + (Assert (weak-list-p weaklist4)) + (Assert (eq (weak-list-type weaklist4) 'value-assoc)) + + (garbage-collect) + + (Assert (eq (weak-list-list weaklist1) testlist)) + (Assert (equal (weak-list-list weaklist2) (list b (cons (cons 1 2) a) b))) + (Assert (equal (weak-list-list weaklist3) testlist)) + (Assert (equal (weak-list-list weaklist4) testlist))) + +(garbage-collect) + +;; tests for full-assoc weak-lists +(let* ((a (cons 23 42)) + (b (cons a a)) + (testlist (list b b)) + (weaklist1 (make-weak-list 'full-assoc)) + (weaklist2 (make-weak-list 'full-assoc)) + (weaklist3 (make-weak-list 'full-assoc)) + (weaklist4 (make-weak-list 'full-assoc))) + (set-weak-list-list weaklist1 testlist) + (set-weak-list-list weaklist2 (list b (cons (cons 1 2) a) b)) + (set-weak-list-list weaklist3 (list b (cons a (cons 1 2)) b)) + (set-weak-list-list weaklist4 (list b (cons (cons 1 2) (cons 3 4)) b)) + (Assert (weak-list-p weaklist1)) + (Assert (eq (weak-list-type weaklist1) 'full-assoc)) + (Assert (weak-list-p weaklist2)) + (Assert (eq (weak-list-type weaklist2) 'full-assoc)) + (Assert (weak-list-p weaklist3)) + (Assert (eq (weak-list-type weaklist3) 'full-assoc)) + (Assert (weak-list-p weaklist4)) + (Assert (eq (weak-list-type weaklist4) 'full-assoc)) + + (garbage-collect) + + (Assert (eq (weak-list-list weaklist1) testlist)) + (Assert (equal (weak-list-list weaklist2) (list b (cons (cons 1 2) a) b))) + (Assert (equal (weak-list-list weaklist3) (list b (cons a (cons 1 2)) b))) + (Assert (equal (weak-list-list weaklist4) testlist))) + +(garbage-collect)