diff options
| author | Daniel Colascione | 2012-09-17 04:07:36 -0800 |
|---|---|---|
| committer | Daniel Colascione | 2012-09-17 04:07:36 -0800 |
| commit | 2ab329f3b5d52a39f0a45c3d9c129f1c19560142 (patch) | |
| tree | 6dd6784d63e54cb18071df8e28fbdbc27d418728 /test | |
| parent | f701ab72dd55460d23c8b029550aa4d7ecef3cfa (diff) | |
| parent | bb7dce392f6d9d5fc4b9d7de09ff920a52f07669 (diff) | |
| download | emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.tar.gz emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.zip | |
Merge from trunk
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 11 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 52 |
2 files changed, 53 insertions, 10 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index f523f6f59a9..a7e22aa9ae1 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2012-09-08 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/ruby-mode-tests.el: | ||
| 4 | (ruby-toggle-block-to-multiline): New test. | ||
| 5 | (ruby-should-indent-buffer, ruby-toggle-block-to-do-end) | ||
| 6 | (ruby-toggle-block-to-brace): Use buffer-string. | ||
| 7 | |||
| 8 | 2012-09-07 Dmitry Gutov <dgutov@yandex.ru> | ||
| 9 | |||
| 10 | * automated/ruby-mode-tests.el: New tests (Bug#11613). | ||
| 11 | |||
| 1 | 2012-08-28 Chong Yidong <cyd@gnu.org> | 12 | 2012-08-28 Chong Yidong <cyd@gnu.org> |
| 2 | 13 | ||
| 3 | * automated/files.el: Test every combination of values for | 14 | * automated/files.el: Test every combination of values for |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index df51aa0d15a..e711b52fb9c 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -40,8 +40,7 @@ The whitespace before and including \"|\" on each line is removed." | |||
| 40 | (insert (fix-indent content)) | 40 | (insert (fix-indent content)) |
| 41 | (ruby-mode) | 41 | (ruby-mode) |
| 42 | (indent-region (point-min) (point-max)) | 42 | (indent-region (point-min) (point-max)) |
| 43 | (should (string= (fix-indent expected) (buffer-substring-no-properties | 43 | (should (string= (fix-indent expected) (buffer-string)))))) |
| 44 | (point-min) (point-max))))))) | ||
| 45 | 44 | ||
| 46 | (defun ruby-assert-state (content &rest values-plist) | 45 | (defun ruby-assert-state (content &rest values-plist) |
| 47 | "Assert syntax state values at the end of CONTENT. | 46 | "Assert syntax state values at the end of CONTENT. |
| @@ -57,6 +56,13 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 57 | (cadr values-plist))) | 56 | (cadr values-plist))) |
| 58 | (setq values-plist (cddr values-plist))))) | 57 | (setq values-plist (cddr values-plist))))) |
| 59 | 58 | ||
| 59 | (defun ruby-assert-face (content pos face) | ||
| 60 | (with-temp-buffer | ||
| 61 | (insert content) | ||
| 62 | (ruby-mode) | ||
| 63 | (font-lock-fontify-buffer) | ||
| 64 | (should (eq face (get-text-property pos 'face))))) | ||
| 65 | |||
| 60 | (ert-deftest ruby-indent-after-symbol-made-from-string-interpolation () | 66 | (ert-deftest ruby-indent-after-symbol-made-from-string-interpolation () |
| 61 | "It can indent the line after symbol made using string interpolation." | 67 | "It can indent the line after symbol made using string interpolation." |
| 62 | (ruby-should-indent "def foo(suffix)\n :\"bar#{suffix}\"\n" | 68 | (ruby-should-indent "def foo(suffix)\n :\"bar#{suffix}\"\n" |
| @@ -84,6 +90,11 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 84 | (ruby-should-indent "foo = {\na: b" ruby-indent-level) | 90 | (ruby-should-indent "foo = {\na: b" ruby-indent-level) |
| 85 | (ruby-should-indent "foo(\na" ruby-indent-level))) | 91 | (ruby-should-indent "foo(\na" ruby-indent-level))) |
| 86 | 92 | ||
| 93 | (ert-deftest ruby-indent-after-keyword-in-a-string () | ||
| 94 | (ruby-should-indent "a = \"abc\nif\"\n " 0) | ||
| 95 | (ruby-should-indent "a = %w[abc\n def]\n " 0) | ||
| 96 | (ruby-should-indent "a = \"abc\n def\"\n " 0)) | ||
| 97 | |||
| 87 | (ert-deftest ruby-indent-simple () | 98 | (ert-deftest ruby-indent-simple () |
| 88 | (ruby-should-indent-buffer | 99 | (ruby-should-indent-buffer |
| 89 | "if foo | 100 | "if foo |
| @@ -201,21 +212,42 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 201 | 212 | ||
| 202 | (ert-deftest ruby-toggle-block-to-do-end () | 213 | (ert-deftest ruby-toggle-block-to-do-end () |
| 203 | (with-temp-buffer | 214 | (with-temp-buffer |
| 204 | (insert "foo {|b|\n}\n") | 215 | (insert "foo {|b|\n}") |
| 205 | (ruby-mode) | 216 | (ruby-mode) |
| 206 | (search-backward "{") | 217 | (beginning-of-line) |
| 207 | (ruby-toggle-block) | 218 | (ruby-toggle-block) |
| 208 | (should (string= "foo do |b|\nend\n" (buffer-substring-no-properties | 219 | (should (string= "foo do |b|\nend" (buffer-string))))) |
| 209 | (point-min) (point-max)))))) | ||
| 210 | 220 | ||
| 211 | (ert-deftest ruby-toggle-block-to-brace () | 221 | (ert-deftest ruby-toggle-block-to-brace () |
| 212 | (with-temp-buffer | 222 | (with-temp-buffer |
| 213 | (insert "foo do |b|\nend\n") | 223 | (insert "foo do |b|\nend") |
| 214 | (ruby-mode) | 224 | (ruby-mode) |
| 215 | (search-backward "do") | 225 | (beginning-of-line) |
| 226 | (ruby-toggle-block) | ||
| 227 | (should (string= "foo {|b|\n}" (buffer-string))))) | ||
| 228 | |||
| 229 | (ert-deftest ruby-toggle-block-to-multiline () | ||
| 230 | (with-temp-buffer | ||
| 231 | (insert "foo {|b| b + 1}") | ||
| 232 | (ruby-mode) | ||
| 233 | (beginning-of-line) | ||
| 216 | (ruby-toggle-block) | 234 | (ruby-toggle-block) |
| 217 | (should (string= "foo {|b|\n}\n" (buffer-substring-no-properties | 235 | (should (string= "foo do |b|\n b + 1\nend" (buffer-string))))) |
| 218 | (point-min) (point-max)))))) | 236 | |
| 237 | (ert-deftest ruby-recognize-symbols-starting-with-at-character () | ||
| 238 | (ruby-assert-face ":@abc" 3 'font-lock-constant-face)) | ||
| 239 | |||
| 240 | (ert-deftest ruby-hash-character-not-interpolation () | ||
| 241 | (ruby-assert-face "\"This is #{interpolation}\"" 15 | ||
| 242 | 'font-lock-variable-name-face) | ||
| 243 | (ruby-assert-face "\"This is \\#{no interpolation} despite the #\"" | ||
| 244 | 15 'font-lock-string-face) | ||
| 245 | (ruby-assert-face "\n#@comment, not ruby code" 5 'font-lock-comment-face) | ||
| 246 | (ruby-assert-state "\n#@comment, not ruby code" 4 t) | ||
| 247 | (ruby-assert-face "# A comment cannot have #{an interpolation} in it" | ||
| 248 | 30 'font-lock-comment-face) | ||
| 249 | (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 | ||
| 250 | 'font-lock-variable-name-face)) | ||
| 219 | 251 | ||
| 220 | (provide 'ruby-mode-tests) | 252 | (provide 'ruby-mode-tests) |
| 221 | 253 | ||