890
|
1 ;; Copyright (C) 1998 Free Software Foundation, Inc.
|
|
2
|
|
3 ;; Author: Mike Sperber <mike@xemacs.org>
|
|
4 ;; Maintainer: Mike Sperber <mike@xemacs.org>
|
|
5 ;; Created: 2002
|
|
6 ;; Keywords: tests, database
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
23 ;; 02111-1307, USA.
|
|
24
|
|
25 ;;; Synched up with: Not in FSF.
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
|
29 ;;; Test implementation of weak boxes and ephemerons
|
|
30 ;;; See test-harness.el
|
|
31
|
|
32 (condition-case err
|
|
33 (require 'test-harness)
|
|
34 (file-error
|
|
35 (when (and (boundp 'load-file-name) (stringp load-file-name))
|
|
36 (push (file-name-directory load-file-name) load-path)
|
|
37 (require 'test-harness))))
|
|
38
|
|
39 (garbage-collect)
|
|
40 (let ((w (make-weak-box (cons 2 3))))
|
|
41 (Assert (equal (cons 2 3) (weak-box-ref w)))
|
|
42 (garbage-collect)
|
|
43 (Assert (not (weak-box-ref w))))
|
|
44
|
|
45 (garbage-collect)
|
|
46
|
|
47 (let* ((p (cons 3 4))
|
|
48 (finalized-p nil)
|
|
49 (eph1 (make-ephemeron (cons 1 2) p
|
|
50 '(lambda (value)
|
|
51 (setq finalized-p t))))
|
|
52 (eph2 (make-ephemeron p p)))
|
|
53 (Assert (eq p (ephemeron-ref (make-ephemeron (cons 1 2) p))))
|
|
54 (Assert (ephemeron-p (make-ephemeron (cons 1 2) p)))
|
|
55
|
|
56 (garbage-collect)
|
|
57 (garbage-collect) ; ensure the post-gc hook runs
|
|
58
|
|
59 (Assert finalized-p)
|
|
60 (Assert (not (ephemeron-ref eph1)))
|
|
61
|
|
62 (garbage-collect)
|
|
63
|
|
64 (Assert (eq p (ephemeron-ref eph2))))
|
|
65
|