annotate tests/automated/regexp-tests.el @ 5146:88bd4f3ef8e4

make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-15 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (c_readonly): * alloc.c (deadbeef_memory): * alloc.c (make_compiled_function): * alloc.c (make_button_data): * alloc.c (make_motion_data): * alloc.c (make_process_data): * alloc.c (make_timeout_data): * alloc.c (make_magic_data): * alloc.c (make_magic_eval_data): * alloc.c (make_eval_data): * alloc.c (make_misc_user_data): * alloc.c (noseeum_make_marker): * alloc.c (ADDITIONAL_FREE_string): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_once_early): * bytecode.c (print_compiled_function): * bytecode.c (mark_compiled_function): * casetab.c: * casetab.c (print_case_table): * console.c: * console.c (print_console): * database.c (print_database): * database.c (finalize_database): * device-msw.c (sync_printer_with_devmode): * device-msw.c (print_devmode): * device-msw.c (finalize_devmode): * device.c: * device.c (print_device): * elhash.c: * elhash.c (print_hash_table): * eval.c (print_multiple_value): * eval.c (mark_multiple_value): * events.c (deinitialize_event): * events.c (print_event): * events.c (event_equal): * extents.c: * extents.c (soe_dump): * extents.c (soe_insert): * extents.c (soe_delete): * extents.c (soe_move): * extents.c (extent_fragment_update): * extents.c (print_extent_1): * extents.c (print_extent): * extents.c (vars_of_extents): * frame.c: * frame.c (print_frame): * free-hook.c: * free-hook.c (check_free): * glyphs.c: * glyphs.c (print_image_instance): * glyphs.c (print_glyph): * gui.c: * gui.c (copy_gui_item): * hash.c: * hash.c (NULL_ENTRY): * hash.c (KEYS_DIFFER_P): * keymap.c (print_keymap): * keymap.c (MARKED_SLOT): * lisp.h: * lrecord.h: * lrecord.h (LISP_OBJECT_UID): * lrecord.h (set_lheader_implementation): * lrecord.h (struct old_lcrecord_header): * lstream.c (print_lstream): * lstream.c (finalize_lstream): * marker.c (print_marker): * marker.c (marker_equal): * mc-alloc.c (visit_all_used_page_headers): * mule-charset.c: * mule-charset.c (print_charset): * objects.c (print_color_instance): * objects.c (print_font_instance): * objects.c (finalize_font_instance): * opaque.c (print_opaque): * opaque.c (print_opaque_ptr): * opaque.c (equal_opaque_ptr): * print.c (internal_object_printer): * print.c (enum printing_badness): * rangetab.c (print_range_table): * rangetab.c (range_table_equal): * specifier.c (print_specifier): * specifier.c (finalize_specifier): * symbols.c: * symbols.c (print_symbol_value_magic): * tooltalk.c: * tooltalk.c (print_tooltalk_message): * tooltalk.c (print_tooltalk_pattern): * window.c (print_window): * window.c (debug_print_window): (1) Make lrecord UID's have a separate UID space for each object. Otherwise, with 20-bit UID's, we rapidly wrap around, especially when common objects like conses and strings increment the UID value for every object created. (Originally I tried making two UID spaces, one for objects that always print readably and hence don't display the UID, and one for other objects. But certain objects like markers for which a UID is displayed are still generated rapidly enough that UID overflow is a serious issue.) This also has the advantage of making UID values smaller, hence easier to remember -- their main purpose is to make it easier to keep track of different objects of the same type when debugging code. Make sure we dump lrecord UID's so that we don't have problems with pdumped and non-dumped objects having the same UID. (2) Display UID's consistently whenever an object (a) doesn't consistently print readably (objects like cons and string, which always print readably, can't display a UID), and (b) doesn't otherwise have a unique property that makes objects of a particular type distinguishable. (E.g. buffers didn't and still don't print an ID, but the buffer name uniquely identifies the buffer.) Some types, such as event, extent, compiled-function, didn't always (or didn't ever) display an ID; others (such as marker, extent, lstream, opaque, opaque-ptr, any object using internal_object_printer()) used to display the actual machine pointer instead. (3) Rename NORMAL_LISP_OBJECT_UID to LISP_OBJECT_UID; make it work over all Lisp objects and take a Lisp object, not a struct pointer. (4) Some misc cleanups in alloc.c, elhash.c. (5) Change code in events.c that "deinitializes" an event so that it doesn't increment the event UID counter in the process. Also use deadbeef_memory() to overwrite memory instead of doing the same with custom code. In the process, make deadbeef_memory() in alloc.c always available, and delete extraneous copy in mc-alloc.c. Also capitalize all uses of 0xDEADBEEF. Similarly in elhash.c call deadbeef_memory(). (6) Resurrect "debug SOE" code in extents.c. Make it conditional on DEBUG_XEMACS and on a `debug-soe' variable, rather than on SOE_DEBUG. Make it output to stderr, not stdout. (7) Delete some custom print methods that were identical to external_object_printer().
author Ben Wing <ben@xemacs.org>
date Mon, 15 Mar 2010 16:35:38 -0500
parents 0f66906b6e37
children 308d34e9f07d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
1 ;;; -*- coding: iso-8859-1 -*-
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
2
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
3 ;; Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
4 ;; Copyright (C) 2010 Ben Wing.
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
5
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
6 ;; Author: Yoshiki Hayashi <yoshiki@xemacs.org>
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
7 ;; Maintainer: Stephen J. Turnbull <stephen@xemacs.org>
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
8 ;; Created: 2000
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
9 ;; Keywords: tests
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
10
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
12
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
16 ;; any later version.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
17
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
21 ;; General Public License for more details.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
22
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the Free
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
26 ;; 02111-1307, USA.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
27
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
28 ;;; Synched up with: Not in FSF.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
29
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
30 ;;; Commentary:
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
31
4897
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
32 ;; Test regular expressions.
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
33
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4900
diff changeset
34 ;; NOTE NOTE NOTE: There is some domain overlap among case-tests.el,
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4900
diff changeset
35 ;; regexp-tests.el and search-tests.el. See case-tests.el.
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
36
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
37 (Check-Error-Message error "Trailing backslash"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
38 (string-match "\\" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
39 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
40 (string-match "a++" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
41 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
42 (string-match "a**" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
43 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
44 (string-match "a???" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
45 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
46 (string-match "[" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
47 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
48 (string-match "[abc" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
49 (Check-Error-Message error "Unmatched ) or \\\\)"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
50 (string-match "\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
51 (Check-Error-Message error "Invalid regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
52 (string-match "\\(?.\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
53 (Check-Error-Message error "Unmatched \\\\{"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
54 (string-match "a\\{" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
55 (Check-Error-Message error "Invalid content of \\\\{\\\\}"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
56 (string-match "a\\{a\\}" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
57
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
58 ;; exactn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
59
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
60 ;; string-match
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
61 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
62 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
63 (Assert (string-match "ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
64 (Assert (string-match "ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
65 (Assert (string-match "Ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
66 (Assert (string-match "Ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
67 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
68 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
69 (Assert (string-match "ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
70 (Assert (not (string-match "ä" "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
71 (Assert (string-match "Ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
72 (Assert (not (string-match "Ä" "ä"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
73
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
74 ;; looking-at
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
75 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
76 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
77 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
78 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
79 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
80 (Assert (looking-at "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
81 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
82 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
83 (Assert (looking-at "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
84 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
85 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
86 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
87 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
88 (Assert (not (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
89 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
90 (Assert (not (looking-at "ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
91 (Assert (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
92
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
93 ;; re-search-forward and re-search-backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
94 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
95 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
96 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
97 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
98 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
99 ;; Avoid trivial regexp.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
100 (Assert (eq 2 (re-search-forward "ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
101 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
102 (Assert (eq 2 (re-search-forward "Ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
103 (goto-char (1+ (point-min)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
104 (Assert (eq 3 (re-search-forward "ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
105 (goto-char (1+ (point-min)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
106 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
107 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
108 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
109 (Assert (eq 2 (re-search-backward "ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
110 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
111 (Assert (eq 2 (re-search-backward "Ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
112 (goto-char (1- (point-max)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
113 (Assert (eq 1 (re-search-backward "ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
114 (goto-char (1- (point-max)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
115 (Assert (eq 1 (re-search-backward "Ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
116 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
117 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
118 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
119 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
120 (Assert (eq 2 (re-search-forward "ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
121 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
122 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
123 (goto-char (1+ (point-min)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
124 (Assert (not (re-search-forward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
125 (goto-char (1+ (point-min)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
126 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
127 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
128 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
129 (Assert (eq 1 (re-search-backward "ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
130 (goto-char (point-max))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
131 (Assert (eq 2 (re-search-backward "Ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
132 (goto-char (1- (point-max)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
133 (Assert (eq 1 (re-search-backward "ä\\|a" nil t)))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
134 (goto-char (1- (point-max)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
135 (Assert (not (re-search-backward "Ä\\|a" nil t))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
136
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
137 ;; duplicate
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
138 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
139 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
140 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
141 (Assert (string-match "^\\(ä\\)\\1$" "äÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
142 (Assert (string-match "^\\(ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
143 (Assert (string-match "^\\(ä\\)\\1$" "Ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
144 (Assert (string-match "^\\(Ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
145 (Assert (string-match "^\\(Ä\\)\\1$" "äÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
146 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
147 (Assert (string-match "^\\(Ä\\)\\1$" "Ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
148 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
149 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
150 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
151 (Assert (not (string-match "^\\(ä\\)\\1$" "äÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
152 (Assert (not (string-match "^\\(ä\\)\\1$" "ÄÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
153 (Assert (not (string-match "^\\(ä\\)\\1$" "Ää")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
154 (Assert (not (string-match "^\\(Ä\\)\\1$" "ää")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
155 (Assert (not (string-match "^\\(Ä\\)\\1$" "äÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
156 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
157 (Assert (not (string-match "^\\(Ä\\)\\1$" "Ää"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
158
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
159 ;; multiple-match
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
160 ;; Thanks to Manfred Bartz <MBartz@xix.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
161 ;; c.e.x <vn4rkkm7ouf3b5@corp.supernews.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
162 ;; #### Need to do repetitions of more complex regexps
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
163 ;; #### WASH ME!
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
164 (with-temp-buffer
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
165 (Assert (not (string-match "^a\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
166 (Assert (string-match "^a\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
167 (Assert (not (string-match "^a\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
168 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
169 (Assert (string-match "^[a]\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
170 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
171 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
172 (Assert (string-match "^\\(a\\)\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
173 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
174 ;; Use class because repetition of single char broken in 21.5.15
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
175 (Assert (not (string-match "^[a]\\{3,5\\}$" "aa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
176 (Assert (string-match "^[a]\\{3,5\\}$" "aaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
177 (Assert (string-match "^[a]\\{3,5\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
178 (Assert (string-match "^[a]\\{3,5\\}$" "aaaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
179 (Assert (not (string-match "^[a]\\{3,5\\}$" "aaaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
180 (insert "\
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
181 aa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
182 aaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
183 aaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
184 aaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
185 aaaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
186 baaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
187 ")
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
188 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
189 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
190 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
191 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
192 (Assert (looking-at "^a\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
193 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
194 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
195 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
196 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
197 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
198 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
199 (Assert (looking-at "^[a]\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
200 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
201 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
202 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
203 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
204 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
205 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
206 (Assert (looking-at "^\\(a\\)\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
207 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
208 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
209 ;; Use class because repetition of single char broken in 21.5.15
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
210 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
211 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
212 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
213 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
214 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
215 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
216 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
217 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
218 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
219 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
220 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
221 (Assert (= 12 (re-search-forward "a\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
222 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
223 (Assert (= 12 (re-search-forward "b?a\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
224 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
225 (Assert (= 31 (re-search-forward "ba\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
226 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
227 (Assert (= 31 (re-search-forward "[b]a\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
228 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
229 (Assert (= 31 (re-search-forward "\\(b\\)a\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
230 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
231 (Assert (= 12 (re-search-forward "^a\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
232 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
233 (Assert (= 12 (re-search-forward "^a\\{4,4\\}$")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
234 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
235 (Assert (= 12 (re-search-forward "[a]\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
236 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
237 (Assert (= 12 (re-search-forward "^[a]\\{4,4\\}")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
238 (goto-char (point-min))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
239 (Assert (= 12 (re-search-forward "^[a]\\{4,4\\}$")))
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
240 )
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
241
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
242 ;; charset, charset_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
243 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
244 (defun test-regexp-charset-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
245 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
246 (max (expt 2 (if (featurep 'mule) 19 8)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
247 (range "[a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
248 (range-not "[^a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
249 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
250 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
251 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
252 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
253 (if (or (and (<= 65 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
254 (<= i 90))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
255 (and (<= 97 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
256 (<= i 122)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
257 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
258 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
259 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
260 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
261 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
262 (setq i (1+ i)))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
263
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
264 ;; (test-regexp-charset-paranoid)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
265
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
266 ;; charset_mule, charset_mule_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
267 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
268 (defun test-regex-charset-mule-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
269 (if (featurep 'mule)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
270 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
271 (max (expt 2 19))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
272 (range (format "[%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
273 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
274 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
275 (range-not (format "[^%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
276 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
277 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
278 (min-int (char-to-int (make-char 'japanese-jisx0208 36 34)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
279 (max-int (char-to-int (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
280 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
281 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
282 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
283 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
284 (if (and (<= min-int i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
285 (<= i max-int))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
286 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
287 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
288 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
289 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
290 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
291 (setq i (1+ i))))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
292
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
293 ;; (test-regex-charset-mule-paranoid)
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
294
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
295 ;; Test that replace-match does not clobber registers after a failed match
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
296 (with-temp-buffer
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
297 (insert "This is a test buffer.")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
298 (goto-char (point-min))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
299 (search-forward "this is a test ")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
300 (looking-at "Unmatchable text")
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
301 (replace-match "")
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
302 (Assert (looking-at "^buffer.$")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
303
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
304 ;; Test that trivial regexps reset unused registers
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
305 ;; Thanks to Martin Sternholm for the report.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
306 ;; xemacs-beta <5blm6h2ki5.fsf@lister.roxen.com>
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
307 (with-temp-buffer
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
308 (insert "ab")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
309 (goto-char (point-min))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
310 (re-search-forward "\\(a\\)")
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
311 ;; test the whole-match data, too -- one attempted fix scotched that, too!
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
312 (Assert (string= (match-string 0) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
313 (Assert (string= (match-string 1) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
314 (re-search-forward "b")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
315 (Assert (string= (match-string 0) "b"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
316 (Assert (string= (match-string 1) nil)))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
317
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
318 ;; Test word boundaries
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
319 (Assert (= (string-match "\\<a" " a") 1))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
320 (Assert (= (string-match "a\\>" "a ") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
321 (Assert (= (string-match "\\ba" " a") 1))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
322 (Assert (= (string-match "a\\b" "a ") 0))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
323 ;; should work at target boundaries
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
324 (Assert (= (string-match "\\<a" "a") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
325 (Assert (= (string-match "a\\>" "a") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
326 (Assert (= (string-match "\\ba" "a") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
327 (Assert (= (string-match "a\\b" "a") 0))
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
328 ;; Check for weirdness
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
329 (Assert (not (string-match " \\> " " ")))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
330 (Assert (not (string-match " \\< " " ")))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
331 (Assert (not (string-match " \\b " " ")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
332 ;; but not if the "word" would be on the null side of the boundary!
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
333 (Assert (not (string-match "\\<" "")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
334 (Assert (not (string-match "\\>" "")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
335 (Assert (not (string-match " \\<" " ")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
336 (Assert (not (string-match "\\> " " ")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
337 (Assert (not (string-match "a\\<" "a")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
338 (Assert (not (string-match "\\>a" "a")))
1389
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
339 ;; Added Known-Bug 2002-09-09 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
340 ;; Fixed bug 2003-03-21 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
341 (Assert (not (string-match "\\b" "")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
342 (Assert (not (string-match "\\b" " ")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
343 (Assert (not (string-match " \\b" " ")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
344 (Assert (not (string-match "\\b " " ")))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
345
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
346 ;; Character classes are broken in Mule as of 21.5.9
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
347 ;; Added Known-Bug 2002-12-27
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
348 ;; Fixed by Daiki Ueno 2003-03-24
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
349 (if (featurep 'mule)
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
350 ;; note: (int-to-char 65) => ?A
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
351 (let ((ch0 (make-char 'japanese-jisx0208 52 65))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
352 (ch1 (make-char 'japanese-jisx0208 51 65)))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
353 (Assert (not (string-match "A" (string ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
354 (Assert (not (string-match "[A]" (string ch0))))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
355 (Assert (eq (string-match "[^A]" (string ch0)) 0))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
356 (Assert (not (string-match "@A" (string ?@ ch0))))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
357 (Assert (not (string-match "@[A]" (string ?@ ch0))))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
358 (Assert (eq (string-match "@[^A]" (string ?@ ch0)) 0))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
359 (Assert (not (string-match "@?A" (string ?@ ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
360 (Assert (not (string-match "A" (string ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
361 (Assert (not (string-match "[A]" (string ch1))))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
362 (Assert (eq (string-match "[^A]" (string ch1)) 0))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
363 (Assert (not (string-match "@A" (string ?@ ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
364 (Assert (not (string-match "@[A]" (string ?@ ch1))))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
365 (Assert (eq (string-match "@[^A]" (string ?@ ch1)) 0))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
366 (Assert (not (string-match "@?A" (string ?@ ch1))))
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
367 )
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
368 )
1195
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
369
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
370 ;; More stale match data tests.
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
371 ;; Thanks to <bjacob@ca.metsci.com>.
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
372 ;; These tests used to fail because we cleared match data only on success.
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
373 ;; Fixed 2003-04-17.
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
374 ;; Must change sense of failing tests 2003-05-09. Too much code depends on
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
375 ;; failed matches preserving match-data.
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
376 (let ((a "a"))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
377 (Assert (string= (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
378 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
379 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
380 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
381 (Assert (not (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
382 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
383 (match-string 1 a))))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
384 ;; test both for the second match is a plain string match and a regexp match
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
385 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
386 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
387 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
388 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
389 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
390 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
391 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
392 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
393 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
394 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
395 (match-string 1 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
396 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
397 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
398 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
399 (match-string 1 a))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
400 a))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
401 ;; in 21.4.16, registers from num_shy_groups to num_groups were not cleared,
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
402 ;; resulting in stale match data
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
403 (Assert (progn (string-match "\\(a\\)" a)
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
404 (string-match "\\(?:a\\)" a)
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
405 (not (match-beginning 1))))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
406 )
2254
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
407
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
408 ;; bug identified by Katsumi Yamaoka 2004-09-03 <b9ywtzbbpue.fsf_-_@jpl.org>
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
409 ;; fix submitted by sjt 2004-09-08
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
410 ;; trailing comments are values from buggy 21.4.15
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
411 (let ((text "abc"))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
412 (Assert (eq 0 (string-match "\\(?:ab+\\)*c" text))) ; 2
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
413 (Assert (eq 0 (string-match "^\\(?:ab+\\)*c" text))) ; nil
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
414 (Assert (eq 0 (string-match "^\\(?:ab+\\)*" text))) ; 0
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
415 (Assert (eq 0 (string-match "^\\(?:ab+\\)c" text))) ; 0
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
416 (Assert (eq 0 (string-match "^\\(?:ab\\)*c" text))) ; 0
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
417 (Assert (eq 0 (string-match "^\\(?:a+\\)*b" text))) ; nil
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
418 (Assert (eq 0 (string-match "^\\(?:a\\)*b" text))) ; 0
2254
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
419 )
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
420
2324
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
421 ;; per Steve Youngs 2004-09-30 <microsoft-free.87ekkjhj7t.fsf@youngs.au.com>
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
422 ;; fix submitted by sjt 2004-10-07
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
423 ;; trailing comments are values from buggy 21.4.pre16
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
424 (let ((text "abc"))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
425 (Assert (eq 0 (string-match "\\(?:a\\(b\\)\\)" text))) ; 0
2324
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
426 (Assert (string= (match-string 1 text) "b")) ; ab
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
427 (Assert (null (match-string 2 text))) ; b
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
428 (Assert (null (match-string 3 text))) ; nil
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
429 (Assert (eq 0 (string-match "\\(?:a\\(?:b\\(c\\)\\)\\)" text))) ; 0
2324
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
430 (Assert (string= (match-string 1 text) "c")) ; abc
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
431 (Assert (null (match-string 2 text))) ; ab
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
432 (Assert (null (match-string 3 text))) ; c
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
433 (Assert (null (match-string 4 text))) ; nil
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
434 )
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
435
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
436 ;; trivial subpatterns and backreferences with shy groups
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
437 (let ((text1 "abb")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
438 (text2 "aba")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
439 (re0 "\\(a\\)\\(b\\)\\2")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
440 (re1 "\\(?:a\\)\\(b\\)\\2")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
441 (re2 "\\(?:a\\)\\(b\\)\\1")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
442 (re3 "\\(a\\)\\(?:b\\)\\1"))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
443
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
444 (Assert (eq 0 (string-match re0 text1)))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
445 (Assert (string= text1 (match-string 0 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
446 (Assert (string= "a" (match-string 1 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
447 (Assert (string= "b" (match-string 2 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
448 (Assert (null (string-match re0 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
449
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
450 (Check-Error-Message 'invalid-regexp "Invalid back reference"
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
451 (string-match re1 text1))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
452
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
453 (Assert (eq 0 (string-match re2 text1)))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
454 (Assert (string= text1 (match-string 0 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
455 (Assert (string= "b" (match-string 1 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
456 (Assert (null (match-string 2 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
457 (Assert (null (string-match re2 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
458
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
459 (Assert (null (string-match re3 text1)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
460 (Assert (eq 0 (string-match re3 text2)))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
461 (Assert (string= text2 (match-string 0 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
462 (Assert (string= "a" (match-string 1 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
463 (Assert (null (match-string 2 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
464 )
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
465
4199
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
466 ;; replace-regexp-in-string (regexp rep source
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
467 ;; fixedcase literal buf-or-subexp start)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
468
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
469 ;; Currently we test the following cases:
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
470 ;; where `cbuf' and `bar-or-empty' are bound below.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
471
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
472 ;; #### Tests for the various functional features (fixedcase, literal, start)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
473 ;; should be added.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
474
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
475 (with-temp-buffer
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
476 (flet ((bar-or-empty (subexp) (if (string= subexp "foo") "bar" "")))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
477 (let ((cbuf (current-buffer)))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
478 (dolist (test-case
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
479 ;; REP BUF-OR-SUBEXP EXPECTED RESULT
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
480 `(("bar" nil " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
481 ("bar" ,cbuf " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
482 ("bar" 0 " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
483 ("bar" 1 " bar foo")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
484 (bar-or-empty nil " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
485 (bar-or-empty ,cbuf " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
486 (bar-or-empty 0 " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
487 (bar-or-empty 1 " bar foo")))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
488 (Assert
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
489 (string=
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
490 (nth 2 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
491 (replace-regexp-in-string "\\(foo\\).*\\'" (nth 0 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
492 " foo foo" nil nil (nth 1 test-case)))))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
493 ;; #### Why doesn't this loop work right?
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
494 ; (dolist (test-case
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
495 ; ;; REP BUF-OR-SUBEXP EXPECTED ERROR EXPECTED MESSAGE
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
496 ; `(;; expected message was "bufferp, symbol" up to 21.5.28
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
497 ; ("bar" 'symbol wrong-type-argument "integerp, symbol")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
498 ; ("bar" -1 invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
499 ; "match data register invalid, -1")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
500 ; ("bar" 2 invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
501 ; "match data register not set, 2")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
502 ; ))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
503 ; (eval
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
504 ; `(Check-Error-Message ,(nth 2 test-case) ,(nth 3 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
505 ; (replace-regexp-in-string "\\(foo\\).*\\'" ,(nth 0 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
506 ; " foo foo" nil nil ,(nth 1 test-case)))))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
507 ;; #### Can't test the message with w-t-a, see test-harness.el.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
508 (Check-Error wrong-type-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
509 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
510 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
511 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
512 'symbol))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
513 ;; #### Can't test the FROB (-1), see test-harness.el.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
514 (Check-Error-Message invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
515 "match data register invalid"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
516 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
517 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
518 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
519 -1))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
520 ;; #### Can't test the FROB (-1), see test-harness.el.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
521 (Check-Error-Message invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
522 "match data register not set"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
523 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
524 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
525 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
526 2))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
527 )))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
528
4504
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
529 ;; Not very comprehensive tests of skip-chars-forward, skip-chars-background:
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
530
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
531 (with-string-as-buffer-contents
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
532 "-]-----------------------------][]]------------------------"
4517
5e8f6469169f Fix up initial condition for skip-chars test.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4504
diff changeset
533 (goto-char (point-min))
4504
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
534 (skip-chars-forward (skip-chars-quote "-[]"))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
535 (Assert (= (point) (point-max)))
4504
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
536 (skip-chars-backward (skip-chars-quote "-[]"))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
537 (Assert (= (point) (point-min)))
4504
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
538 ;; Testing in passing for an old bug in #'skip-chars-forward where I
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
539 ;; thought it was impossible to call it with a string containing only ?-
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
540 ;; and ?]:
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
541 (Assert (= (skip-chars-forward (skip-chars-quote "-]"))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
542 (position ?[ (buffer-string) :test #'=)))
4504
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
543 ;; This used to error, incorrectly:
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
544 (Assert (skip-chars-quote "[-")))
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
545
4199
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
546 ;; replace-match (REPLACEMENT &optional FIXEDCASE LITERAL STRING STRBUFFER)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
547
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
548 ;; #### Write some tests! Much functionality is implicitly tested above
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
549 ;; via `replace-regexp-in-string', but we should specifically test bogus
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
550 ;; combinations of STRING and STRBUFFER.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
551
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
552 ;; empty string at point
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
553 ;; Thanks Julian Bradford on XEmacs Beta
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
554 ;; <18652.54975.894512.880956@krk.inf.ed.ac.uk>
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
555 (with-string-as-buffer-contents "aáa"
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
556 (goto-char (point-min))
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
557 (Assert (looking-at "\\="))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
558 (Assert (= (re-search-forward "\\=") 1))
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
559 (forward-char 1)
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
560 (Assert (looking-at "\\="))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
561 (Assert (= (re-search-forward "\\=") 2))
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
562 (forward-char 1)
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
563 (Assert (looking-at "\\="))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
564 (Assert (= (re-search-forward "\\=") 3))
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
565 (forward-char 1)
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
566 (Assert (looking-at "\\="))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
567 (Assert (= (re-search-forward "\\=") 4)))
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
568
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
569
4897
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
570 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
571 ;; Tests involving case-changing replace-match ;;
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
572 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
573
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
574 (Assert (not (string-match "\\(\\.\\=\\)" ".")))
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
575 (Assert (string= "" (let ((str "test string"))
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
576 (if (string-match "^.*$" str)
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
577 (replace-match "\\U" t nil str)))))
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
578 (with-temp-buffer
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
579 (erase-buffer)
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
580 (insert "test string")
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
581 (re-search-backward "^.*$")
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
582 (replace-match "\\U" t)
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
583 (Assert (and (bobp) (eobp))))
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
584
4900
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
585 ;; Control-1 characters were second-class citizens in regexp ranges
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
586 ;; for a while there. Addressed in Ben's Mercurial changeset
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
587 ;; 2e15c29cc2b3; attempt to ensure this doesn't happen again.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
588 (Assert (eql (string-match "[\x00-\x7f\x80-\x9f]" "a") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
589 (Assert (eql (string-match "[\x00-\x7f\x80-\x9f]" "é") nil))
4900
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
590 ;; Gave nil in 21.5 for a couple of years.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
591 (Assert (eql (string-match "[\x00-\x7f\x80-\x9f]" "\x80") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
592 (Assert (eql (string-match "[\x00-\x7f]\\|[\x80-\x9f]" "\x80") 0))
4900
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
593 ;; Gave nil
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
594 (Assert (eql (string-match "[\x7f\x80-\x9f]" "\x80") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
595 (Assert (eql (string-match "[\x80-\x9f]" "\x80") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
596 (Assert (eql (string-match "[\x7f\x80-\x9e]" "\x80") 0))
4900
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
597 ;; Used to succeed even with the bug.
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
598 (Assert (eql (string-match "[\x7f\x80\x9f]" "\x80") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
599 (Assert (eql (string-match "[\x7e\x80-\x9f]" "\x80") 0))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4906
diff changeset
600 (Assert (eql (string-match "[\x7f\x81-\x9f]" "\x81") 0))