428
|
1 ;; Copyright (C) 1999 Free Software Foundation, Inc.
|
|
2
|
|
3 ;; Author: Hrvoje Niksic <hniksic@xemacs.org>
|
|
4 ;; Maintainer: Hrvoje Niksic <hniksic@xemacs.org>
|
|
5 ;; Created: 1999
|
|
6 ;; Keywords: tests
|
|
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 some Mule functionality (most of these remain to be written) .
|
|
30 ;; See test-harness.el for instructions on how to run these tests.
|
|
31
|
|
32 ;;-----------------------------------------------------------------
|
|
33 ;; Test whether all legal chars may be safely inserted to a buffer.
|
|
34 ;;-----------------------------------------------------------------
|
|
35
|
|
36 (defun test-chars (&optional for-test-harness)
|
|
37 "Insert all characters in a buffer, to see if XEmacs will crash.
|
|
38 This is done by creating a string with all the legal characters
|
|
39 in [0, 2^19) range, inserting it into the buffer, and checking
|
|
40 that the buffer's contents are equivalent to the string.
|
|
41
|
|
42 If FOR-TEST-HARNESS is specified, a temporary buffer is used, and
|
|
43 the Assert macro checks for correctness."
|
|
44 (let ((max (expt 2 (if (featurep 'mule) 19 8)))
|
|
45 (list nil)
|
|
46 (i 0))
|
|
47 (while (< i max)
|
|
48 (and (not for-test-harness)
|
|
49 (zerop (% i 1000))
|
|
50 (message "%d" i))
|
|
51 (and (int-char i)
|
|
52 ;; Don't aset to a string directly because random string
|
|
53 ;; access is O(n) under Mule.
|
|
54 (setq list (cons (int-char i) list)))
|
|
55 (setq i (1+ i)))
|
|
56 (let ((string (apply #'string (nreverse list))))
|
|
57 (if for-test-harness
|
|
58 ;; For use with test-harness, use Assert and a temporary
|
|
59 ;; buffer.
|
|
60 (with-temp-buffer
|
|
61 (insert string)
|
|
62 (Assert (equal (buffer-string) string)))
|
|
63 ;; For use without test harness: use a normal buffer, so that
|
|
64 ;; you can also test whether redisplay works.
|
|
65 (switch-to-buffer (get-buffer-create "test"))
|
|
66 (erase-buffer)
|
|
67 (buffer-disable-undo)
|
|
68 (insert string)
|
|
69 (assert (equal (buffer-string) string))))))
|
|
70
|
|
71 ;; It would be really *really* nice if test-harness allowed a way to
|
|
72 ;; run a test in byte-compiled mode only. It's tedious to have
|
|
73 ;; time-consuming tests like this one run twice, once interpreted and
|
|
74 ;; once compiled, for no good reason.
|
|
75 (test-chars t)
|