update
This commit is contained in:
112
elpa/mmm-mode-0.5.7/tests/highlighting.el
Normal file
112
elpa/mmm-mode-0.5.7/tests/highlighting.el
Normal file
@@ -0,0 +1,112 @@
|
||||
;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ert-x)
|
||||
|
||||
(defvar foo-mode-keywords
|
||||
`((,(concat "\\b"
|
||||
(regexp-opt '("foo" "bar") t)
|
||||
"\\b")
|
||||
. font-lock-keyword-face)))
|
||||
|
||||
(define-derived-mode foo1-mode fundamental-mode ""
|
||||
(setq font-lock-defaults '(foo-mode-keywords t t)))
|
||||
|
||||
(ert-deftest mmm-font-lock-without-font-lock-syntax-table ()
|
||||
(ert-with-test-buffer nil
|
||||
(let (mmm-mode-ext-classes-alist
|
||||
mmm-parse-when-idle)
|
||||
(insert "foo // foo_bar")
|
||||
(fundamental-mode)
|
||||
(mmm-mode-on)
|
||||
(mmm-ify-by-regexp 'foo1-mode "// " 0 "\\'" 0 nil)
|
||||
(font-lock-fontify-region (point-min) (point-max))
|
||||
(beginning-of-buffer)
|
||||
(should-not (get-text-property (point) 'face))
|
||||
(search-forward "fo" nil nil 2)
|
||||
(should (eq (get-text-property (point) 'face) font-lock-keyword-face))
|
||||
(search-forward "ba")
|
||||
(should (eq (get-text-property (point) 'face) font-lock-keyword-face)))))
|
||||
|
||||
(define-derived-mode foo2-mode fundamental-mode ""
|
||||
(setq font-lock-defaults '(foo-mode-keywords t t ((?_ . "w")))))
|
||||
|
||||
(ert-deftest mmm-font-lock-with-font-lock-syntax-table ()
|
||||
(ert-with-test-buffer nil
|
||||
(let (mmm-mode-ext-classes-alist
|
||||
mmm-parse-when-idle)
|
||||
(insert "foo // foo_bar")
|
||||
(fundamental-mode)
|
||||
(mmm-mode-on)
|
||||
(mmm-ify-by-regexp 'foo2-mode "// " 0 "\\'" 0 nil)
|
||||
(font-lock-fontify-region (point-min) (point-max))
|
||||
(should-not (next-single-property-change (point-min) 'face)))))
|
||||
|
||||
(define-derived-mode foo3-mode fundamental-mode ""
|
||||
(setq font-lock-defaults '(foo-mode-keywords nil t ((?_ . "w")))))
|
||||
|
||||
(ert-deftest mmm-syntax-propertize-function-preserves-current-syntax-table ()
|
||||
(ert-with-test-buffer nil
|
||||
(let (mmm-mode-ext-classes-alist
|
||||
mmm-parse-when-idle)
|
||||
(insert "foo_and_bar\n\nfoo")
|
||||
(foo3-mode)
|
||||
(mmm-mode-on)
|
||||
(syntax-ppss-flush-cache (point-min))
|
||||
;; It locally changes `syntax-table' to `font-lock-syntax-table'
|
||||
;; and calls `syntax-ppss' inside that before fontifying.
|
||||
(font-lock-fontify-region (point-min) (point-max))
|
||||
(let ((pt (next-single-property-change (point-min) 'face)))
|
||||
(should pt)
|
||||
(goto-char pt)
|
||||
(should (looking-at "foo\\'"))))))
|
||||
|
||||
(ert-deftest mmm-fontify-region-list-ignores-outside-for-syntactic-ff-tion ()
|
||||
(ert-with-test-buffer nil
|
||||
(let (mmm-mode-ext-classes-alist
|
||||
mmm-parse-when-idle)
|
||||
(insert "unpaired '!\n")
|
||||
(insert "js>>\n")
|
||||
(insert "var woo = js;\n")
|
||||
(foo1-mode)
|
||||
(mmm-mode-on)
|
||||
(syntax-ppss-flush-cache (point-min))
|
||||
(mmm-ify-by-regexp 'js-mode "js>>\n" 0 "\\'" 0 nil)
|
||||
(font-lock-fontify-region (point-min) (point-max))
|
||||
(search-backward "var")
|
||||
(should (eq 'font-lock-keyword-face
|
||||
(get-text-property (point) 'face))))))
|
||||
|
||||
(ert-deftest mmm-fontify-region-list-carries-string-after-subregion ()
|
||||
(ert-with-test-buffer nil
|
||||
(let (mmm-mode-ext-classes-alist
|
||||
mmm-parse-when-idle)
|
||||
(insert "<p class=\"foo <% 1 + 2 %> bar tee\"</p>")
|
||||
(html-mode)
|
||||
(mmm-mode-on)
|
||||
(syntax-ppss-flush-cache (point-min))
|
||||
(mmm-ify-by-regexp 'js-mode "<%" 0 "%>" 0 nil)
|
||||
(font-lock-fontify-region (point-min) (point-max))
|
||||
(search-backward "1")
|
||||
(should (null (get-text-property (point) 'face)))
|
||||
(search-forward "bar")
|
||||
(should (eq 'font-lock-string-face
|
||||
(get-text-property (point) 'face))))))
|
||||
103
elpa/mmm-mode-0.5.7/tests/html-erb.el
Normal file
103
elpa/mmm-mode-0.5.7/tests/html-erb.el
Normal file
@@ -0,0 +1,103 @@
|
||||
;; Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'ert)
|
||||
(require 'ert-x)
|
||||
(require 'mmm-erb)
|
||||
|
||||
(defvar mmm-erb-text
|
||||
"<%= foo do %>
|
||||
<div class=\"clear\"/>
|
||||
<% end %>")
|
||||
|
||||
(defconst mmm-erb-edge-emacs (string-lessp "24.3.50" emacs-version))
|
||||
|
||||
(defun mmm-erb-current-overlay-string ()
|
||||
(buffer-substring-no-properties
|
||||
(overlay-start mmm-current-overlay)
|
||||
(overlay-end mmm-current-overlay)))
|
||||
|
||||
(defmacro mmm-erb-deftest (name &rest body)
|
||||
(let ((expected-result (and (eq (car body) :expected-result)
|
||||
(nth 1 body))))
|
||||
(when expected-result
|
||||
(setq body (nthcdr 2 body)))
|
||||
`(ert-deftest ,(intern (format "mmm-erb-%s" name)) ()
|
||||
:expected-result ,(or expected-result :passed)
|
||||
(ert-with-test-buffer nil
|
||||
(let ((buffer-file-name "foo.html.erb")
|
||||
(mmm-global-mode 'maybe)
|
||||
mmm-parse-when-idle
|
||||
mmm-mode-ext-classes-alist)
|
||||
(mmm-add-mode-ext-class 'html-erb-mode "\\.html\\.erb\\'" 'erb)
|
||||
(html-erb-mode)
|
||||
(mmm-mode-on-maybe)
|
||||
(should mmm-mode)
|
||||
,@body)))))
|
||||
|
||||
(put 'mmm-erb-deftest 'lisp-indent-function 'defun)
|
||||
|
||||
(mmm-erb-deftest parses-buffer
|
||||
(insert mmm-erb-text)
|
||||
(mmm-apply-all)
|
||||
(should (not mmm-current-overlay))
|
||||
(search-backward "foo")
|
||||
(should (mmm-update-current-submode))
|
||||
(should (string= " foo do " (mmm-erb-current-overlay-string)))
|
||||
(search-forward "end")
|
||||
(should (mmm-update-current-submode))
|
||||
(should (string= " end " (mmm-erb-current-overlay-string))))
|
||||
|
||||
(defun mmm-erb-assert-string-syntax ()
|
||||
(goto-char (point-min))
|
||||
(search-forward "\"")
|
||||
(should (nth 3 (syntax-ppss)))
|
||||
(search-forward "\"")
|
||||
(should (not (nth 3 (syntax-ppss)))))
|
||||
|
||||
(defun mmm-erb-assert-non-string-syntax ()
|
||||
(goto-char (point-min))
|
||||
(search-forward "\"")
|
||||
(should (not (nth 3 (syntax-ppss))))
|
||||
(search-forward "\"")
|
||||
(should (not (nth 3 (syntax-ppss)))))
|
||||
|
||||
(mmm-erb-deftest attribute-values-are-strings
|
||||
(insert mmm-erb-text)
|
||||
(mmm-apply-all)
|
||||
(mmm-erb-assert-string-syntax))
|
||||
|
||||
(mmm-erb-deftest quotes-outside-tags-dont-make-strings
|
||||
:expected-result (if mmm-erb-edge-emacs :passed :failed)
|
||||
(insert "<% foo do %><p>\"foo bar\"</p><% end %>")
|
||||
(mmm-apply-all)
|
||||
(mmm-erb-assert-non-string-syntax))
|
||||
|
||||
(mmm-erb-deftest gt-inside-subregion-doesnt-change-nesting
|
||||
(insert "<% if 2 > 1 %><div class=\"foo\"/><% end %>")
|
||||
(mmm-apply-all)
|
||||
(mmm-erb-assert-string-syntax))
|
||||
|
||||
(mmm-erb-deftest lt-inside-subregion-doesnt-change-nesting
|
||||
:expected-result (if mmm-erb-edge-emacs :passed :failed)
|
||||
(insert "<% if 2 < 1 %><p>\"foo bar\"</p><% end %>")
|
||||
(mmm-apply-all)
|
||||
(mmm-erb-assert-non-string-syntax))
|
||||
Reference in New Issue
Block a user