diff options
author | Noam Postavsky <npostavs@gmail.com> | 2019-05-26 11:07:14 -0400 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2019-06-04 08:42:50 -0400 |
commit | 438e4804d107720f526d0c7c367cbd029f264676 (patch) | |
tree | 3b8a3561bc86f6a67a65d918c1f064e21445cbd0 /test/lisp/textmodes/sgml-mode-tests.el | |
parent | 7aaf500701be3b51c686b7d86c9b505ef5fa9b8f (diff) | |
download | emacs-438e4804d107720f526d0c7c367cbd029f264676.tar.gz |
Fix some SGML syntax edge cases (Bug#33887)
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-rules): Handle
single and double quotes symmetrically. Don't skip quoted comment
enders.
* test/lisp/textmodes/sgml-mode-tests.el (sgml-tests--quotes-syntax):
Add more test cases.
(sgml-mode-quote-in-long-text): New test.
Diffstat (limited to 'test/lisp/textmodes/sgml-mode-tests.el')
-rw-r--r-- | test/lisp/textmodes/sgml-mode-tests.el | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el index 1b8965e3440..34d26480a45 100644 --- a/test/lisp/textmodes/sgml-mode-tests.el +++ b/test/lisp/textmodes/sgml-mode-tests.el @@ -161,15 +161,46 @@ The point is set to the beginning of the buffer." (should (string= "&&" (buffer-string)))))) (ert-deftest sgml-tests--quotes-syntax () + (dolist (str '("a\"b <t>c'd</t>" + "a'b <t>c\"d</t>" + "<t>\"a'</t>" + "<t>'a\"</t>" + "<t>\"a'\"</t>" + "<t>'a\"'</t>" + "a\"b <tag>c'd</tag>" + "<tag>c>'d</tag>" + "<t><!-- \" --></t>" + "<t><!-- ' --></t>" + )) + (with-temp-buffer + (sgml-mode) + (insert str) + (ert-info ((format "%S" str) :prefix "Test case: ") + ;; Check that last tag is parsed as a tag. + (should (= 1 (car (syntax-ppss (1- (point-max)))))) + (should (= 0 (car (syntax-ppss (point-max))))))))) + +(ert-deftest sgml-mode-quote-in-long-text () (with-temp-buffer (sgml-mode) - (insert "a\"b <tag>c'd</tag>") - (should (= 1 (car (syntax-ppss (1- (point-max)))))) - (should (= 0 (car (syntax-ppss (point-max))))) - (erase-buffer) - (insert "<tag>c>d</tag>") - (should (= 1 (car (syntax-ppss (1- (point-max)))))) - (should (= 0 (car (syntax-ppss (point-max))))))) + (insert "<t>" + ;; `syntax-propertize-wholelines' extends chunk size based + ;; on line length, so newlines are significant! + (make-string syntax-propertize-chunk-size ?a) "\n" + "'" + (make-string syntax-propertize-chunk-size ?a) "\n" + "</t>") + ;; If we just check (syntax-ppss (point-max)) immediately, then + ;; we'll end up propertizing the whole buffer in one chunk (so the + ;; test is useless). Simulate something more like what happens + ;; when the buffer is viewed normally. + (cl-loop for pos from (point-min) to (point-max) + by syntax-propertize-chunk-size + do (syntax-ppss pos)) + (syntax-ppss (point-max)) + ;; Check that last tag is parsed as a tag. + (should (= 1 (- (car (syntax-ppss (1- (point-max)))) + (car (syntax-ppss (point-max)))))))) (provide 'sgml-mode-tests) ;;; sgml-mode-tests.el ends here |