annotate tests/automated/regexp-tests.el @ 5050:6f2158fa75ed

Fix quick-build, use asserts() in place of ABORT() -------------------- ChangeLog entries follow: -------------------- ChangeLog addition: 2010-02-20 Ben Wing <ben@xemacs.org> * configure.ac (XE_COMPLEX_ARG): Correct doc of --quick-build: It also doesn't check for Lisp shadows. src/ChangeLog addition: 2010-02-20 Ben Wing <ben@xemacs.org> * EmacsFrame.c: * EmacsFrame.c (EmacsFrameRecomputeCellSize): * alloca.c (i00afunc): * buffer.c: * buffer.c (MARKED_SLOT): * buffer.c (complex_vars_of_buffer): * cm.c: * cm.c (cmcheckmagic): * console.c: * console.c (MARKED_SLOT): * device-x.c: * device-x.c (x_get_visual_depth): * emacs.c (sort_args): * eval.c (throw_or_bomb_out): * event-stream.c: * event-stream.c (Fadd_timeout): * event-stream.c (Fadd_async_timeout): * event-stream.c (Frecent_keys): * events.c: * events.c (Fdeallocate_event): * events.c (event_pixel_translation): * extents.c: * extents.c (process_extents_for_insertion_mapper): * fns.c (Fbase64_encode_region): * fns.c (Fbase64_encode_string): * fns.c (Fbase64_decode_region): * fns.c (Fbase64_decode_string): * font-lock.c: * font-lock.c (find_context): * frame-x.c: * frame-x.c (x_wm_mark_shell_size_user_specified): * frame-x.c (x_wm_mark_shell_position_user_specified): * frame-x.c (x_wm_set_shell_iconic_p): * frame-x.c (x_wm_set_cell_size): * frame-x.c (x_wm_set_variable_size): * frame-x.c (x_wm_store_class_hints): * frame-x.c (x_wm_maybe_store_wm_command): * frame-x.c (x_initialize_frame_size): * frame.c (delete_frame_internal): * frame.c (change_frame_size_1): * free-hook.c (check_free): * free-hook.c (note_block_input): * free-hook.c (log_gcpro): * gccache-gtk.c (gc_cache_lookup): * gccache-x.c: * gccache-x.c (gc_cache_lookup): * glyphs-gtk.c: * glyphs-gtk.c (init_image_instance_from_gdk_pixmap): * glyphs-x.c: * glyphs-x.c (extract_xpm_color_names): * insdel.c: * insdel.c (move_gap): * keymap.c: * keymap.c (keymap_lookup_directly): * keymap.c (keymap_delete_inverse_internal): * keymap.c (accessible_keymaps_mapper_1): * keymap.c (where_is_recursive_mapper): * lisp.h: * lstream.c (make_lisp_buffer_stream_1): * macros.c: * macros.c (pop_kbd_macro_event): * mc-alloc.c (remove_page_from_used_list): * menubar-x.c: * menubar-x.c (set_frame_menubar): * ralloc.c: * ralloc.c (obtain): * ralloc.c (relinquish): * ralloc.c (relocate_blocs): * ralloc.c (resize_bloc): * ralloc.c (r_alloc_free): * ralloc.c (r_re_alloc): * ralloc.c (r_alloc_thaw): * ralloc.c (init_ralloc): * ralloc.c (Free_Addr_Block): * scrollbar-x.c: * scrollbar-x.c (x_update_scrollbar_instance_status): * sunplay.c (init_device): * unexnt.c: * unexnt.c (read_in_bss): * unexnt.c (map_in_heap): * window.c: * window.c (real_window): * window.c (window_display_lines): * window.c (window_display_buffer): * window.c (set_window_display_buffer): * window.c (unshow_buffer): * window.c (Fget_lru_window): if (...) ABORT(); ---> assert(); More specifically: if (x == y) ABORT (); --> assert (x != y); if (x != y) ABORT (); --> assert (x == y); if (x > y) ABORT (); --> assert (x <= y); etc. if (!x) ABORT (); --> assert (x); if (x) ABORT (); --> assert (!x); DeMorgan's Law's applied and manually simplified: if (x && !y) ABORT (); --> assert (!x || y); if (!x || y >= z) ABORT (); --> assert (x && y < z); Checked to make sure that assert() of an expression with side effects ensures that the side effects get executed even when asserts are disabled, and add a comment about this being a requirement of any "disabled assert" expression. * depend: * make-src-depend: * make-src-depend (PrintDeps): Fix broken code in make-src-depend so it does what it was always supposed to do, which was separate out config.h and lisp.h and all the files they include into separate variables in the depend part of Makefile so that quick-build can turn off the lisp.h/config.h/text.h/etc. dependencies of the source files, to speed up recompilation.
author Ben Wing <ben@xemacs.org>
date Sat, 20 Feb 2010 05:05:54 -0600
parents 6ef8256a020a
children 0f66906b6e37
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.
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
4
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
5 ;; Author: Yoshiki Hayashi <yoshiki@xemacs.org>
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
6 ;; Maintainer: Stephen J. Turnbull <stephen@xemacs.org>
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
7 ;; Created: 2000
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
8 ;; Keywords: tests
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
9
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
11
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
15 ;; any later version.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
16
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
20 ;; General Public License for more details.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
21
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
23 ;; 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
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
25 ;; 02111-1307, USA.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
26
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
27 ;;; Synched up with: Not in FSF.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
28
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
29 ;;; Commentary:
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
30
4897
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
31 ;; Test regular expressions.
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
32
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4900
diff changeset
33 ;; 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
34 ;; regexp-tests.el and search-tests.el. See case-tests.el.
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
35
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
36 (Check-Error-Message error "Trailing backslash"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
37 (string-match "\\" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
38 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
39 (string-match "a++" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
40 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
41 (string-match "a**" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
42 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
43 (string-match "a???" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
44 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
45 (string-match "[" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
46 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
47 (string-match "[abc" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
48 (Check-Error-Message error "Unmatched ) or \\\\)"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
49 (string-match "\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
50 (Check-Error-Message error "Invalid regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
51 (string-match "\\(?.\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
52 (Check-Error-Message error "Unmatched \\\\{"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
53 (string-match "a\\{" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
54 (Check-Error-Message error "Invalid content of \\\\{\\\\}"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
55 (string-match "a\\{a\\}" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
56
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
57 ;; exactn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
58
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
59 ;; string-match
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
60 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
61 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
62 (Assert (string-match "ä" "ä"))
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 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
67 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
68 (Assert (string-match "ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
69 (Assert (not (string-match "ä" "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
70 (Assert (string-match "Ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
71 (Assert (not (string-match "Ä" "ä"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
72
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
73 ;; looking-at
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
74 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
75 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
76 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
77 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
78 (Assert (looking-at "ä"))
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 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
81 (Assert (looking-at "ä"))
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 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
84 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
85 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
86 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
87 (Assert (not (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
88 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
89 (Assert (not (looking-at "ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
90 (Assert (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
91
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
92 ;; re-search-forward and re-search-backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
93 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
94 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
95 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
96 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
97 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
98 ;; Avoid trivial regexp.
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
99 (Assert-eq 2 (re-search-forward "ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
100 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
101 (Assert-eq 2 (re-search-forward "Ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
102 (goto-char (1+ (point-min)))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
103 (Assert-eq 3 (re-search-forward "ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
104 (goto-char (1+ (point-min)))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
105 (Assert-eq 3 (re-search-forward "Ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
106 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
107 (goto-char (point-max))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
108 (Assert-eq 2 (re-search-backward "ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
109 (goto-char (point-max))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
110 (Assert-eq 2 (re-search-backward "Ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
111 (goto-char (1- (point-max)))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
112 (Assert-eq 1 (re-search-backward "ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
113 (goto-char (1- (point-max)))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
114 (Assert-eq 1 (re-search-backward "Ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
115 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
116 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
117 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
118 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
119 (Assert-eq 2 (re-search-forward "ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
120 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
121 (Assert-eq 3 (re-search-forward "Ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
122 (goto-char (1+ (point-min)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
123 (Assert (not (re-search-forward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
124 (goto-char (1+ (point-min)))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
125 (Assert-eq 3 (re-search-forward "Ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
126 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
127 (goto-char (point-max))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
128 (Assert-eq 1 (re-search-backward "ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
129 (goto-char (point-max))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
130 (Assert-eq 2 (re-search-backward "Ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
131 (goto-char (1- (point-max)))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
132 (Assert-eq 1 (re-search-backward "ä\\|a" nil t))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
133 (goto-char (1- (point-max)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
134 (Assert (not (re-search-backward "Ä\\|a" nil t))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
135
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
136 ;; duplicate
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
137 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
138 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
139 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
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 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
148 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
149 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
150 (Assert (not (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 (string-match "^\\(Ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
156 (Assert (not (string-match "^\\(Ä\\)\\1$" "Ää"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
157
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
158 ;; multiple-match
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
159 ;; Thanks to Manfred Bartz <MBartz@xix.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
160 ;; c.e.x <vn4rkkm7ouf3b5@corp.supernews.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
161 ;; #### Need to do repetitions of more complex regexps
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
162 ;; #### WASH ME!
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
163 (with-temp-buffer
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
164 (Assert (not (string-match "^a\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
165 (Assert (string-match "^a\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
166 (Assert (not (string-match "^a\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
167 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
168 (Assert (string-match "^[a]\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
169 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
170 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
171 (Assert (string-match "^\\(a\\)\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
172 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
173 ;; 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
174 (Assert (not (string-match "^[a]\\{3,5\\}$" "aa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
175 (Assert (string-match "^[a]\\{3,5\\}$" "aaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
176 (Assert (string-match "^[a]\\{3,5\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
177 (Assert (string-match "^[a]\\{3,5\\}$" "aaaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
178 (Assert (not (string-match "^[a]\\{3,5\\}$" "aaaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
179 (insert "\
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
180 aa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
181 aaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
182 aaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
183 aaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
184 aaaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
185 baaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
186 ")
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
187 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
188 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
189 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
190 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
191 (Assert (looking-at "^a\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
192 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
193 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
194 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
195 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
196 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
197 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
198 (Assert (looking-at "^[a]\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
199 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
200 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
201 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
202 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
203 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
204 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
205 (Assert (looking-at "^\\(a\\)\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
206 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
207 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
208 ;; 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
209 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
210 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
211 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
212 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
213 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
214 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
215 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
216 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
217 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
218 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
219 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
220 (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
221 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
222 (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
223 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
224 (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
225 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
226 (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
227 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
228 (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
229 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
230 (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
231 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
232 (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
233 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
234 (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
235 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
236 (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
237 (goto-char (point-min))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
238 (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
239 )
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
240
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
241 ;; charset, charset_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
242 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
243 (defun test-regexp-charset-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
244 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
245 (max (expt 2 (if (featurep 'mule) 19 8)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
246 (range "[a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
247 (range-not "[^a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
248 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
249 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
250 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
251 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
252 (if (or (and (<= 65 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
253 (<= i 90))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
254 (and (<= 97 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
255 (<= i 122)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
256 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
257 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
258 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
259 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
260 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
261 (setq i (1+ i)))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
262
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
263 ;; (test-regexp-charset-paranoid)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
264
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
265 ;; charset_mule, charset_mule_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
266 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
267 (defun test-regex-charset-mule-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
268 (if (featurep 'mule)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
269 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
270 (max (expt 2 19))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
271 (range (format "[%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
272 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
273 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
274 (range-not (format "[^%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
275 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
276 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
277 (min-int (char-to-int (make-char 'japanese-jisx0208 36 34)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
278 (max-int (char-to-int (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
279 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
280 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
281 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
282 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
283 (if (and (<= min-int i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
284 (<= i max-int))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
285 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
286 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
287 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
288 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
289 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
290 (setq i (1+ i))))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
291
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
292 ;; (test-regex-charset-mule-paranoid)
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
293
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
294 ;; 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
295 (with-temp-buffer
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
296 (insert "This is a test buffer.")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
297 (goto-char (point-min))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
298 (search-forward "this is a test ")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
299 (looking-at "Unmatchable text")
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
300 (replace-match "")
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
301 (Assert (looking-at "^buffer.$")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
302
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
303 ;; Test that trivial regexps reset unused registers
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
304 ;; Thanks to Martin Sternholm for the report.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
305 ;; xemacs-beta <5blm6h2ki5.fsf@lister.roxen.com>
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
306 (with-temp-buffer
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
307 (insert "ab")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
308 (goto-char (point-min))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
309 (re-search-forward "\\(a\\)")
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
310 ;; 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
311 (Assert (string= (match-string 0) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
312 (Assert (string= (match-string 1) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
313 (re-search-forward "b")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
314 (Assert (string= (match-string 0) "b"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
315 (Assert (string= (match-string 1) nil)))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
316
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
317 ;; Test word boundaries
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
318 (Assert= (string-match "\\<a" " a") 1)
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
319 (Assert= (string-match "a\\>" "a ") 0)
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
320 (Assert= (string-match "\\ba" " a") 1)
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
321 (Assert= (string-match "a\\b" "a ") 0)
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
322 ;; should work at target boundaries
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
323 (Assert= (string-match "\\<a" "a") 0)
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
324 (Assert= (string-match "a\\>" "a") 0)
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
325 (Assert= (string-match "\\ba" "a") 0)
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
326 (Assert= (string-match "a\\b" "a") 0)
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
327 ;; Check for weirdness
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
328 (Assert (not (string-match " \\> " " ")))
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 " \\b " " ")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
331 ;; 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
332 (Assert (not (string-match "\\<" "")))
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 "a\\<" "a")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
337 (Assert (not (string-match "\\>a" "a")))
1389
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
338 ;; Added Known-Bug 2002-09-09 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
339 ;; Fixed bug 2003-03-21 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
340 (Assert (not (string-match "\\b" "")))
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 " " ")))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
344
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
345 ;; 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
346 ;; Added Known-Bug 2002-12-27
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
347 ;; Fixed by Daiki Ueno 2003-03-24
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
348 (if (featurep 'mule)
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
349 ;; note: (int-to-char 65) => ?A
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
350 (let ((ch0 (make-char 'japanese-jisx0208 52 65))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
351 (ch1 (make-char 'japanese-jisx0208 51 65)))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
352 (Assert (not (string-match "A" (string ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
353 (Assert (not (string-match "[A]" (string ch0))))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
354 (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
355 (Assert (not (string-match "@A" (string ?@ ch0))))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
356 (Assert (not (string-match "@[A]" (string ?@ ch0))))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
357 (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
358 (Assert (not (string-match "@?A" (string ?@ ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
359 (Assert (not (string-match "A" (string ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
360 (Assert (not (string-match "[A]" (string ch1))))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
361 (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
362 (Assert (not (string-match "@A" (string ?@ ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
363 (Assert (not (string-match "@[A]" (string ?@ ch1))))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
364 (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
365 (Assert (not (string-match "@?A" (string ?@ ch1))))
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
366 )
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
367 )
1195
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
368
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
369 ;; More stale match data tests.
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
370 ;; Thanks to <bjacob@ca.metsci.com>.
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
371 ;; 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
372 ;; Fixed 2003-04-17.
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
373 ;; 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
374 ;; failed matches preserving match-data.
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
375 (let ((a "a"))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
376 (Assert (string= (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
377 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
378 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
379 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
380 (Assert (not (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
381 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
382 (match-string 1 a))))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
383 ;; 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
384 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
385 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
386 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
387 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
388 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
389 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
390 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
391 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
392 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
393 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
394 (match-string 1 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
395 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
396 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
397 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
398 (match-string 1 a))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
399 a))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
400 ;; 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
401 ;; resulting in stale match data
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
402 (Assert (progn (string-match "\\(a\\)" a)
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
403 (string-match "\\(?:a\\)" a)
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
404 (not (match-beginning 1))))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
405 )
2254
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
406
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
407 ;; 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
408 ;; fix submitted by sjt 2004-09-08
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
409 ;; 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
410 (let ((text "abc"))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
411 (Assert-eq 0 (string-match "\\(?:ab+\\)*c" text)) ; 2
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
412 (Assert-eq 0 (string-match "^\\(?:ab+\\)*c" text)) ; nil
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
413 (Assert-eq 0 (string-match "^\\(?:ab+\\)*" text)) ; 0
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
414 (Assert-eq 0 (string-match "^\\(?:ab+\\)c" text)) ; 0
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
415 (Assert-eq 0 (string-match "^\\(?:ab\\)*c" text)) ; 0
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
416 (Assert-eq 0 (string-match "^\\(?:a+\\)*b" text)) ; nil
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
417 (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
418 )
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
419
2324
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
420 ;; 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
421 ;; fix submitted by sjt 2004-10-07
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
422 ;; 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
423 (let ((text "abc"))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
424 (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
425 (Assert (string= (match-string 1 text) "b")) ; ab
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
426 (Assert (null (match-string 2 text))) ; b
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
427 (Assert (null (match-string 3 text))) ; nil
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
428 (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
429 (Assert (string= (match-string 1 text) "c")) ; abc
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
430 (Assert (null (match-string 2 text))) ; ab
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
431 (Assert (null (match-string 3 text))) ; c
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
432 (Assert (null (match-string 4 text))) ; nil
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
433 )
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
434
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
435 ;; trivial subpatterns and backreferences with shy groups
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
436 (let ((text1 "abb")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
437 (text2 "aba")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
438 (re0 "\\(a\\)\\(b\\)\\2")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
439 (re1 "\\(?:a\\)\\(b\\)\\2")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
440 (re2 "\\(?:a\\)\\(b\\)\\1")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
441 (re3 "\\(a\\)\\(?:b\\)\\1"))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
442
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
443 (Assert-eq 0 (string-match re0 text1))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
444 (Assert (string= text1 (match-string 0 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
445 (Assert (string= "a" (match-string 1 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
446 (Assert (string= "b" (match-string 2 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
447 (Assert (null (string-match re0 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
448
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
449 (Check-Error-Message 'invalid-regexp "Invalid back reference"
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
450 (string-match re1 text1))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
451
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
452 (Assert-eq 0 (string-match re2 text1))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
453 (Assert (string= text1 (match-string 0 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
454 (Assert (string= "b" (match-string 1 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
455 (Assert (null (match-string 2 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
456 (Assert (null (string-match re2 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
457
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
458 (Assert (null (string-match re3 text1)))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
459 (Assert-eq 0 (string-match re3 text2))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
460 (Assert (string= text2 (match-string 0 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
461 (Assert (string= "a" (match-string 1 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
462 (Assert (null (match-string 2 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
463 )
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
464
4199
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
465 ;; replace-regexp-in-string (regexp rep source
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
466 ;; fixedcase literal buf-or-subexp start)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
467
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
468 ;; Currently we test the following cases:
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
469 ;; 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
470
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
471 ;; #### 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
472 ;; should be added.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
473
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
474 (with-temp-buffer
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
475 (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
476 (let ((cbuf (current-buffer)))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
477 (dolist (test-case
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
478 ;; REP BUF-OR-SUBEXP EXPECTED RESULT
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
479 `(("bar" nil " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
480 ("bar" ,cbuf " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
481 ("bar" 0 " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
482 ("bar" 1 " bar foo")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
483 (bar-or-empty nil " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
484 (bar-or-empty ,cbuf " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
485 (bar-or-empty 0 " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
486 (bar-or-empty 1 " bar foo")))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
487 (Assert
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
488 (string=
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
489 (nth 2 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
490 (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
491 " foo foo" nil nil (nth 1 test-case)))))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
492 ;; #### Why doesn't this loop work right?
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
493 ; (dolist (test-case
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
494 ; ;; REP BUF-OR-SUBEXP EXPECTED ERROR EXPECTED MESSAGE
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
495 ; `(;; 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
496 ; ("bar" 'symbol wrong-type-argument "integerp, symbol")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
497 ; ("bar" -1 invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
498 ; "match data register invalid, -1")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
499 ; ("bar" 2 invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
500 ; "match data register not set, 2")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
501 ; ))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
502 ; (eval
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
503 ; `(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
504 ; (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
505 ; " foo foo" nil nil ,(nth 1 test-case)))))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
506 ;; #### 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
507 (Check-Error wrong-type-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
508 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
509 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
510 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
511 'symbol))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
512 ;; #### 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
513 (Check-Error-Message invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
514 "match data register invalid"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
515 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
516 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
517 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
518 -1))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
519 ;; #### 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
520 (Check-Error-Message invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
521 "match data register not set"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
522 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
523 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
524 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
525 2))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
526 )))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
527
4504
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
528 ;; 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
529
b82fdf7305ee Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4199
diff changeset
530 (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
531 "-]-----------------------------][]]------------------------"
4517
5e8f6469169f Fix up initial condition for skip-chars test.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4504
diff changeset
532 (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
533 (skip-chars-forward (skip-chars-quote "-[]"))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
534 (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
535 (skip-chars-backward (skip-chars-quote "-[]"))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
536 (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
537 ;; 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
538 ;; 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
539 ;; and ?]:
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
540 (Assert= (skip-chars-forward (skip-chars-quote "-]"))
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
541 (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
542 ;; 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
543 (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
544
4199
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
545 ;; replace-match (REPLACEMENT &optional FIXEDCASE LITERAL STRING STRBUFFER)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
546
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
547 ;; #### 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
548 ;; 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
549 ;; combinations of STRING and STRBUFFER.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
550
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
551 ;; empty string at point
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
552 ;; Thanks Julian Bradford on XEmacs Beta
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
553 ;; <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
554 (with-string-as-buffer-contents "aáa"
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
555 (goto-char (point-min))
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
556 (Assert (looking-at "\\="))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
557 (Assert= (re-search-forward "\\=") 1)
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
558 (forward-char 1)
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
559 (Assert (looking-at "\\="))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
560 (Assert= (re-search-forward "\\=") 2)
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
561 (forward-char 1)
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
562 (Assert (looking-at "\\="))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
563 (Assert= (re-search-forward "\\=") 3)
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
564 (forward-char 1)
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
565 (Assert (looking-at "\\="))
4855
189fb67ca31a Create Assert-eq, Assert-equal, etc.
Ben Wing <ben@xemacs.org>
parents: 4518
diff changeset
566 (Assert= (re-search-forward "\\=") 4))
4518
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
567
e0a8c796f955 Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4517
diff changeset
568
4897
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
569 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
570 ;; 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
571 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 (Assert (not (string-match "\\(\\.\\=\\)" ".")))
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
574 (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
575 (if (string-match "^.*$" str)
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
576 (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
577 (with-temp-buffer
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
578 (erase-buffer)
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
579 (insert "test string")
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
580 (re-search-backward "^.*$")
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
581 (replace-match "\\U" t)
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
582 (Assert (and (bobp) (eobp))))
91a023144e72 fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
583
4900
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
584 ;; 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
585 ;; 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
586 ;; 2e15c29cc2b3; attempt to ensure this doesn't happen again.
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
587 (Assert-eql (string-match "[\x00-\x7f\x80-\x9f]" "a") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
588 (Assert-eql (string-match "[\x00-\x7f\x80-\x9f]" "é") nil)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
589 ;; Gave nil in 21.5 for a couple of years.
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
590 (Assert-eql (string-match "[\x00-\x7f\x80-\x9f]" "\x80") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
591 (Assert-eql (string-match "[\x00-\x7f]\\|[\x80-\x9f]" "\x80") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
592 ;; Gave nil
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
593 (Assert-eql (string-match "[\x7f\x80-\x9f]" "\x80") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
594 (Assert-eql (string-match "[\x80-\x9f]" "\x80") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
595 (Assert-eql (string-match "[\x7f\x80-\x9e]" "\x80") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
596 ;; Used to succeed even with the bug.
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
597 (Assert-eql (string-match "[\x7f\x80\x9f]" "\x80") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
598 (Assert-eql (string-match "[\x7e\x80-\x9f]" "\x80") 0)
0eccfd4850d6 Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4897
diff changeset
599 (Assert-eql (string-match "[\x7f\x81-\x9f]" "\x81") 0)