]> code.delx.au - gnu-emacs/blobdiff - test/lisp/progmodes/ruby-mode-tests.el
Fix quote escaping in ruby-toggle-string-quotes
[gnu-emacs] / test / lisp / progmodes / ruby-mode-tests.el
index 52126a3bdf142365eee3f57dfc39c4535079722a..5dd34f8ee415374d12b37e4c28bf1e6d9c9adf82 100644 (file)
@@ -716,6 +716,17 @@ VALUES-PLIST is a list with alternating index and value elements."
     (ruby-backward-sexp)
     (should (= 2 (line-number-at-pos)))))
 
+(ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
+  (let ((pairs
+         '(("puts 'foo\"\\''" . "puts \"foo\\\"'\"")
+           ("puts \"foo'\\\"\"" . "puts 'foo\\'\"'"))))
+    (dolist (pair pairs)
+      (ruby-with-temp-buffer (car pair)
+        (beginning-of-line)
+        (search-forward "foo")
+        (ruby-toggle-string-quotes)
+        (should (string= (buffer-string) (cdr pair)))))))
+
 (ert-deftest ruby--insert-coding-comment-ruby-style ()
   (with-temp-buffer
     (let ((ruby-encoding-magic-comment-style 'ruby))