diff options
author | Peter Oliver <p.d.oliver@mavit.org.uk> | 2021-04-28 05:18:40 +0300 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2021-04-28 05:18:40 +0300 |
commit | a9fc30e6c2ea67d7a2faa5c218af5bcae9f31246 (patch) | |
tree | 67f622e461eda56e01a1a466ce7fcf51f878aa2a /test/lisp/progmodes/ruby-mode-tests.el | |
parent | 6a078097c98902b3d90ec614a8f96d027203c812 (diff) | |
download | emacs-a9fc30e6c2ea67d7a2faa5c218af5bcae9f31246.tar.gz emacs-a9fc30e6c2ea67d7a2faa5c218af5bcae9f31246.tar.bz2 emacs-a9fc30e6c2ea67d7a2faa5c218af5bcae9f31246.zip |
Add tests
* test/lisp/progmodes/ruby-mode-tests.el (ruby-with-temp-file): New helper.
(ruby--set-encoding-when-ascii, ruby--set-encoding-when-utf8)
(ruby--set-encoding-when-latin-15): Tests for the previous commit (bug#48043).
Diffstat (limited to 'test/lisp/progmodes/ruby-mode-tests.el')
-rw-r--r-- | test/lisp/progmodes/ruby-mode-tests.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el index 42a011c8bcd..e2ea0d91370 100644 --- a/test/lisp/progmodes/ruby-mode-tests.el +++ b/test/lisp/progmodes/ruby-mode-tests.el @@ -32,6 +32,13 @@ (ruby-mode) ,@body)) +(defmacro ruby-with-temp-file (contents &rest body) + `(ruby-with-temp-buffer ,contents + (set-visited-file-name "ruby-mode-tests") + ,@body + (set-buffer-modified-p nil) + (delete-file buffer-file-name))) + (defun ruby-should-indent (content column) "Assert indentation COLUMN on the last line of CONTENT." (ruby-with-temp-buffer content @@ -844,6 +851,30 @@ VALUES-PLIST is a list with alternating index and value elements." (ruby--insert-coding-comment "utf-8") (should (string= "# encoding: utf-8\n\n" (buffer-string)))))) +(ert-deftest ruby--set-encoding-when-ascii () + (ruby-with-temp-file "ascii" + (let ((ruby-encoding-magic-comment-style 'ruby) + (ruby-insert-encoding-magic-comment t)) + (setq save-buffer-coding-system 'us-ascii) + (ruby-mode-set-encoding) + (should (string= "ascii" (buffer-string)))))) + +(ert-deftest ruby--set-encoding-when-utf8 () + (ruby-with-temp-file "š" + (let ((ruby-encoding-magic-comment-style 'ruby) + (ruby-insert-encoding-magic-comment t)) + (setq save-buffer-coding-system 'utf-8) + (ruby-mode-set-encoding) + (should (string= "š" (buffer-string)))))) + +(ert-deftest ruby--set-encoding-when-latin-15 () + (ruby-with-temp-file "ā" + (let ((ruby-encoding-magic-comment-style 'ruby) + (ruby-insert-encoding-magic-comment t)) + (setq save-buffer-coding-system 'iso-8859-15) + (ruby-mode-set-encoding) + (should (string= "# coding: iso-8859-15\nā" (buffer-string)))))) + (ert-deftest ruby--indent/converted-from-manual-test () :tags '(:expensive-test) ;; Converted from manual test. |