X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=tests%2Fautomated%2Fsyntax-tests.el;h=1ebb9f18e1b5a6d130162bad6d870ef7b5cd4f8a;hp=e848e11c059ee7a0cf8da8d00271422a35a7f42f;hb=a5812bf2ff9a9cf40f4ff78dcb83f5b4c295bd18;hpb=ccce6217f84987dff10ed3d2b60b9f0f65d8f25a diff --git a/tests/automated/syntax-tests.el b/tests/automated/syntax-tests.el index e848e11..1ebb9f1 100644 --- a/tests/automated/syntax-tests.el +++ b/tests/automated/syntax-tests.el @@ -100,3 +100,58 @@ (test-backward-word "WO " 3) (test-backward-word "W !" 3) (test-backward-word "WO !" 4)) + +;; Works like test-forward-word, except for the following: +;; after is inserted, the syntax-table +;; is applied to position . +;; can be in the form (start . end), or can be a +;; character position. +(defun test-syntax-table (string apply-pos apply-syntax 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 + ;; Apply punctuation to word + (test-syntax-table "WO" 1 `(,(syntax-string-to-code ".")) 1) + ;; Apply word to punctuation + (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 + (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)))))