X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=tests%2Fautomated%2Fsyntax-tests.el;h=62e2978771a1de0bb992dc66a0099abc5f5d3f70;hb=558d57174adb430be3f6ed418a6765c5b5b3cc06;hp=f5a063c898fa256ea0ecc1f33d69b098dccd63d1;hpb=1cc5b779cb8755e01e02aead4fba711c06158b90;p=chise%2Fxemacs-chise.git diff --git a/tests/automated/syntax-tests.el b/tests/automated/syntax-tests.el index f5a063c..62e2978 100644 --- a/tests/automated/syntax-tests.el +++ b/tests/automated/syntax-tests.el @@ -107,16 +107,20 @@ ;; can be in the form (start . end), or can be a ;; character position. (defun test-syntax-table (string apply-pos apply-syntax stop) - (goto-char (point-max)) - (unless (consp apply-pos) - (setq apply-pos `(,apply-pos . ,(+ 1 apply-pos)))) - (let ((point (point))) - (insert string) - (put-text-property (+ point (car apply-pos)) (+ point (cdr apply-pos)) - 'syntax-table apply-syntax) - (goto-char point) - (forward-word 1) - (Assert (eq (point) (+ point stop))))) + ;; We don't necessarily have syntax-table properties ... + (when (boundp 'lookup-syntax-properties) ; backwards compatible kludge + ;; ... and they may not be enabled by default if we do. + (setq lookup-syntax-properties t) + (goto-char (point-max)) + (unless (consp apply-pos) + (setq apply-pos `(,apply-pos . ,(+ 1 apply-pos)))) + (let ((point (point))) + (insert string) + (put-text-property (+ point (car apply-pos)) (+ point (cdr apply-pos)) + 'syntax-table apply-syntax) + (goto-char point) + (forward-word 1) + (Assert (eq (point) (+ point stop)))))) ;; test syntax-table extents (with-temp-buffer @@ -126,17 +130,67 @@ (test-syntax-table "W." 1 `(,(syntax-string-to-code "w")) 2)) ;; Test forward-comment at buffer boundaries +;; #### The second Assert fails (once interpreted, once compiled) on 21.4.9 +;; with sjt's version of Andy's syntax-text-property-killer patch. (with-temp-buffer - (c-mode) - (insert "// comment\n") - (forward-comment -2) - (Assert (eq (point) (point-min))) + (if (not (fboundp 'c-mode)) + ;; #### This whole thing should go inside a macro Skip-Test + (let* ((reason "c-mode unavailable") + (count (gethash reason skipped-test-reasons))) + ;;(message "%S: %S" reason count) + (puthash reason (if (null count) 1 (1+ count)) + skipped-test-reasons) + (Print-Skip "comment and parse-partial-sexp tests" reason)) + (c-mode) + + (insert "// comment\n") + (forward-comment -2) + (Assert (eq (point) (point-min))) + + (let ((point (point))) + (insert "/* comment */") + (goto-char point) + (forward-comment 2) + (Assert (eq (point) (point-max))) + + ;; this last used to crash + (parse-partial-sexp point (point-max))))) + +;; Test backward-up-list +;; Known-Bug: report = Evgeny Zacjev ca 2005-12-01, confirm = Aidan Kehoe - (let ((point (point))) - (insert "/* comment */") - (goto-char point) - (forward-comment 2) - (Assert (eq (point) (point-max))) +(with-temp-buffer + ;; We are now using the standard syntax table. Thus there's no need to + ;; worry about a bogus syntax setting, eg, in a Gnus Article buffer the + ;; bug doesn't manifest. + + ;; value of point to the immediate left of this character + ;; 0 1 2 + ;; 1234 56789 012 34567 890 12 3456 7 + (insert "a ( \"b (c\" (\"defg\") \")\") h\n") + + ;; #### This test should check *every* position. + (flet ((backward-up-list-moves-point-from-to (start expected-end) + (goto-char start) + (backward-up-list 1) + (= (point) expected-end))) + (Known-Bug-Expect-Failure + ;; Evgeny's case + (Assert (backward-up-list-moves-point-from-to 16 12))) + (Assert (backward-up-list-moves-point-from-to 19 12)) + (Assert (backward-up-list-moves-point-from-to 20 3)) + (Known-Bug-Expect-Failure + (Assert (backward-up-list-moves-point-from-to 22 3))) + (Known-Bug-Expect-Failure + (Assert (backward-up-list-moves-point-from-to 23 3))) + (Assert (backward-up-list-moves-point-from-to 24 3)) + ;; This is maybe a little tricky, since we don't expect the position + ;; check to happen -- so use an illegal expected position + ;; I don't think there's any other way for this to fail that way, + ;; barring hardware error.... + (Check-Error-Message syntax-error + "Unbalanced parentheses" + (backward-up-list-moves-point-from-to 25 nil)) + ;; special-case check that point didn't move + (Assert (= (point) 25)))) - ;; this last used to crash - (parse-partial-sexp point (point-max))))