Mercurial > hg > xemacs-beta
diff tests/automated/regexp-tests.el @ 1472:4c87ece1e837
[xemacs-hg @ 2003-05-10 07:44:22 by stephent]
tests for no-clobber-on-fail <87k7czs0xd.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Sat, 10 May 2003 07:44:24 +0000 |
parents | 74cb069b8417 |
children | 28ffd53a1d42 |
line wrap: on
line diff
--- a/tests/automated/regexp-tests.el Sat May 10 04:18:52 2003 +0000 +++ b/tests/automated/regexp-tests.el Sat May 10 07:44:24 2003 +0000 @@ -205,13 +205,14 @@ ;; (test-regex-charset-mule-paranoid) -;; Test that replace-match errors after a failed match +;; Test that replace-match does not clobber registers after a failed match (with-temp-buffer (insert "This is a test buffer.") (goto-char (point-min)) (search-forward "this is a test ") (looking-at "Unmatchable text") - (Check-Error args-out-of-range (replace-match ""))) + (replace-match "") + (Assert (looking-at "^buffer.$"))) ;; Test that trivial regexps reset unused registers ;; Thanks to Martin Sternholm for the report. @@ -283,15 +284,31 @@ ;; Thanks to <bjacob@ca.metsci.com>. ;; These tests used to fail because we cleared match data only on success. ;; Fixed 2003-04-17. -(Assert (not (progn (string-match "a" "a") - (string-match "b" "a") - (match-string 0 "a")))) -(Assert (not (progn (string-match "a" "a") - (string-match "b" "a") - (match-string 1 "a")))) -(Assert (not (progn (string-match "\\(a\\)" "a") - (string-match "\\(b\\)" "a") - (match-string 0 "a")))) -(Assert (not (progn (string-match "\\(a\\)" "a") - (string-match "\\(b\\)" "a") - (match-string 1 "a")))) +;; Have to revert 2003-05-09; too much code depends on failed matches +;; preserving match-data. +;; string match and regexp match are equivalent +(let ((a "a")) + (Assert (string= (progn (string-match "a" a) + (string-match "b" a) + (match-string 0 a)) + a)) + (Assert (not (progn (string-match "a" a) + (string-match "b" a) + (match-string 1 a)))) + ;; test both for the second match is a plain string match and a regexp match + (Assert (string= (progn (string-match "\\(a\\)" a) + (string-match "\\(b\\)" a) + (match-string 0 a)) + a)) + (Assert (string= (progn (string-match "\\(a\\)" a) + (string-match "b" a) + (match-string 0 a)) + a)) + (Assert (string= (progn (string-match "\\(a\\)" a) + (string-match "\\(b\\)" a) + (match-string 1 a)) + a)) + (Assert (string= (progn (string-match "\\(a\\)" a) + (string-match "b" a) + (match-string 1 a)) + a)))