# HG changeset patch # User stephent # Date 1052552664 0 # Node ID 4c87ece1e837b2881c36a48b0574ea1ce411babd # Parent 0b318c558de8ff8cea92098c9b537c782e97de79 [xemacs-hg @ 2003-05-10 07:44:22 by stephent] tests for no-clobber-on-fail <87k7czs0xd.fsf@tleepslib.sk.tsukuba.ac.jp> diff -r 0b318c558de8 -r 4c87ece1e837 tests/ChangeLog --- a/tests/ChangeLog Sat May 10 04:18:52 2003 +0000 +++ b/tests/ChangeLog Sat May 10 07:44:24 2003 +0000 @@ -1,3 +1,9 @@ +2003-05-09 Stephen J. Turnbull + + * automated/regexp-tests.el (replace-match): Revert test to Assert + that registers are preserved on a failed match. + (stale match data): Test for preserve-on-failure behavior. + 2003-04-24 Steve Youngs * XEmacs 21.5.12 "carrot" is released. diff -r 0b318c558de8 -r 4c87ece1e837 tests/automated/regexp-tests.el --- 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 . ;; 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)))