aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii2012-11-17 20:00:16 +0200
committerEli Zaretskii2012-11-17 20:00:16 +0200
commitcf2d22b874ca2df0072e32ee641e8efffe4abd6d (patch)
tree1795142ec7861fc85c61adc90f03265b69041556 /test
parent3c4ca7155293ffc2d04708007131bcbc882d8913 (diff)
parent6ad30855c02908fdd99d9b11943719e185e65ee3 (diff)
downloademacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.tar.gz
emacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.zip
Merge from trunk.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog12
-rw-r--r--test/automated/advice-tests.el30
-rw-r--r--test/automated/ruby-mode-tests.el93
3 files changed, 127 insertions, 8 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 44c013e9887..f11325d0318 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,9 +1,21 @@
12012-11-14 Dmitry Gutov <dgutov@yandex.ru>
2
3 * automated/ruby-mode-tests.el (ruby-indent-singleton-class): Pass.
4 (ruby-indent-inside-heredoc-after-operator)
5 (ruby-indent-inside-heredoc-after-space): New tests.
6 Change direct font-lock face references to var references.
7 (ruby-interpolation-suppresses-syntax-inside): New test.
8 (ruby-interpolation-inside-percent-literal-with-paren): New
9 failing test.
10
12012-11-13 Dmitry Gutov <dgutov@yandex.ru> 112012-11-13 Dmitry Gutov <dgutov@yandex.ru>
2 12
3 * automated/ruby-mode-tests.el (ruby-heredoc-font-lock) 13 * automated/ruby-mode-tests.el (ruby-heredoc-font-lock)
4 (ruby-singleton-class-no-heredoc-font-lock) 14 (ruby-singleton-class-no-heredoc-font-lock)
5 (ruby-add-log-current-method-examples): New tests. 15 (ruby-add-log-current-method-examples): New tests.
6 (ruby-test-string): Extract from ruby-should-indent-buffer. 16 (ruby-test-string): Extract from ruby-should-indent-buffer.
17 (ruby-deftest-move-to-block): New macro.
18 Add several move-to-block tests.
7 19
82012-11-12 Stefan Monnier <monnier@iro.umontreal.ca> 202012-11-12 Stefan Monnier <monnier@iro.umontreal.ca>
9 21
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el
index 9f9719fdcfc..80321f8f3f9 100644
--- a/test/automated/advice-tests.el
+++ b/test/automated/advice-tests.el
@@ -57,6 +57,36 @@
57 (defmacro sm-test3 (x) `(call-test3 ,x)) 57 (defmacro sm-test3 (x) `(call-test3 ,x))
58 (macroexpand '(sm-test3 56)) (toto (call-test3 56))) 58 (macroexpand '(sm-test3 56)) (toto (call-test3 56)))
59 59
60 ((defadvice sm-test4 (around wrap-with-toto activate)
61 ad-do-it (setq ad-return-value `(toto ,ad-return-value)))
62 (defmacro sm-test4 (x) `(call-test4 ,x))
63 (macroexpand '(sm-test4 56)) (toto (call-test4 56)))
64 ((defmacro sm-test4 (x) `(call-testq ,x))
65 (macroexpand '(sm-test4 56)) (toto (call-testq 56)))
66
67 ;; Combining old style and new style advices.
68 ((defun sm-test5 (x) (+ x 4))
69 (sm-test5 6) 10)
70 ((advice-add 'sm-test5 :around (lambda (f y) (* (funcall f y) 5)))
71 (sm-test5 6) 50)
72 ((defadvice sm-test5 (around test activate)
73 ad-do-it (setq ad-return-value (+ ad-return-value 0.1)))
74 (sm-test5 5) 45.1)
75 ((ad-deactivate 'sm-test5)
76 (sm-test5 6) 50)
77 ((ad-activate 'sm-test5)
78 (sm-test5 6) 50.1)
79 ((defun sm-test5 (x) (+ x 14))
80 (sm-test5 6) 100.1)
81 ((advice-remove 'sm-test5 (lambda (f y) (* (funcall f y) 5)))
82 (sm-test5 6) 20.1)
83
84 ;; This used to signal an error (bug#12858).
85 ((autoload 'sm-test6 "foo")
86 (defadvice sm-test6 (around test activate)
87 ad-do-it)
88 t t)
89
60 )) 90 ))
61 91
62(ert-deftest advice-tests () 92(ert-deftest advice-tests ()
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index 0e41b2ba1e2..ad48413b030 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -80,7 +80,7 @@ VALUES-PLIST is a list with alternating index and value elements."
80 80
81(ert-deftest ruby-heredoc-font-lock () 81(ert-deftest ruby-heredoc-font-lock ()
82 (let ((s "foo <<eos.gsub('^ *', '')")) 82 (let ((s "foo <<eos.gsub('^ *', '')"))
83 (ruby-assert-face s 9 'font-lock-string-face) 83 (ruby-assert-face s 9 font-lock-string-face)
84 (ruby-assert-face s 10 nil))) 84 (ruby-assert-face s 10 nil)))
85 85
86(ert-deftest ruby-singleton-class-no-heredoc-font-lock () 86(ert-deftest ruby-singleton-class-no-heredoc-font-lock ()
@@ -154,7 +154,6 @@ VALUES-PLIST is a list with alternating index and value elements."
154 |")) 154 |"))
155 155
156(ert-deftest ruby-indent-singleton-class () 156(ert-deftest ruby-indent-singleton-class ()
157 :expected-result :failed ; Doesn't work yet, when no space before "<<".
158 (ruby-should-indent-buffer 157 (ruby-should-indent-buffer
159 "class<<bar 158 "class<<bar
160 | foo 159 | foo
@@ -165,6 +164,20 @@ VALUES-PLIST is a list with alternating index and value elements."
165 | end 164 | end
166 |")) 165 |"))
167 166
167(ert-deftest ruby-indent-inside-heredoc-after-operator ()
168 (ruby-should-indent-buffer
169 "b=<<eos
170 | 42"
171 "b=<<eos
172 | 42"))
173
174(ert-deftest ruby-indent-inside-heredoc-after-space ()
175 (ruby-should-indent-buffer
176 "foo <<eos.gsub(' ', '*')
177 | 42"
178 "foo <<eos.gsub(' ', '*')
179 | 42"))
180
168(ert-deftest ruby-indent-array-literal () 181(ert-deftest ruby-indent-array-literal ()
169 (let ((ruby-deep-indent-paren nil)) 182 (let ((ruby-deep-indent-paren nil))
170 (ruby-should-indent-buffer 183 (ruby-should-indent-buffer
@@ -249,19 +262,35 @@ VALUES-PLIST is a list with alternating index and value elements."
249 (should (string= "foo do |b|\n b + 1\nend" (buffer-string))))) 262 (should (string= "foo do |b|\n b + 1\nend" (buffer-string)))))
250 263
251(ert-deftest ruby-recognize-symbols-starting-with-at-character () 264(ert-deftest ruby-recognize-symbols-starting-with-at-character ()
252 (ruby-assert-face ":@abc" 3 'font-lock-constant-face)) 265 (ruby-assert-face ":@abc" 3 font-lock-constant-face))
253 266
254(ert-deftest ruby-hash-character-not-interpolation () 267(ert-deftest ruby-hash-character-not-interpolation ()
255 (ruby-assert-face "\"This is #{interpolation}\"" 15 268 (ruby-assert-face "\"This is #{interpolation}\"" 15
256 'font-lock-variable-name-face) 269 font-lock-variable-name-face)
257 (ruby-assert-face "\"This is \\#{no interpolation} despite the #\"" 270 (ruby-assert-face "\"This is \\#{no interpolation} despite the #\""
258 15 'font-lock-string-face) 271 15 font-lock-string-face)
259 (ruby-assert-face "\n#@comment, not ruby code" 5 'font-lock-comment-face) 272 (ruby-assert-face "\n#@comment, not ruby code" 5 font-lock-comment-face)
260 (ruby-assert-state "\n#@comment, not ruby code" 4 t) 273 (ruby-assert-state "\n#@comment, not ruby code" 4 t)
261 (ruby-assert-face "# A comment cannot have #{an interpolation} in it" 274 (ruby-assert-face "# A comment cannot have #{an interpolation} in it"
262 30 'font-lock-comment-face) 275 30 font-lock-comment-face)
263 (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 276 (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16
264 'font-lock-variable-name-face)) 277 font-lock-variable-name-face))
278
279(ert-deftest ruby-interpolation-suppresses-syntax-inside ()
280 (let ((s "\"<ul><li>#{@files.join(\"</li><li>\")}</li></ul>\""))
281 (ruby-assert-state s 8 nil)
282 (ruby-assert-face s 9 font-lock-string-face)
283 (ruby-assert-face s 10 font-lock-variable-name-face)
284 (ruby-assert-face s 41 font-lock-string-face)))
285
286(ert-deftest ruby-interpolation-inside-percent-literal-with-paren ()
287 :expected-result :failed
288 (let ((s "%(^#{\")\"}^)"))
289 (ruby-assert-face s 3 font-lock-string-face)
290 (ruby-assert-face s 4 font-lock-variable-name-face)
291 (ruby-assert-face s 10 font-lock-string-face)
292 ;; It's confused by the closing paren in the middle.
293 (ruby-assert-state s 8 nil)))
265 294
266(ert-deftest ruby-add-log-current-method-examples () 295(ert-deftest ruby-add-log-current-method-examples ()
267 (let ((pairs '(("foo" . "#foo") 296 (let ((pairs '(("foo" . "#foo")
@@ -283,6 +312,54 @@ VALUES-PLIST is a list with alternating index and value elements."
283 (should (string= (ruby-add-log-current-method) 312 (should (string= (ruby-add-log-current-method)
284 (format "M::C%s" value))))))) 313 (format "M::C%s" value)))))))
285 314
315(defvar ruby-block-test-example
316 (ruby-test-string
317 "class C
318 | def foo
319 | 1
320 | end
321 |
322 | def bar
323 | 2
324 | end
325 |
326 | def baz
327 | some do
328 | end
329 | end
330 |end"))
331
332(defmacro ruby-deftest-move-to-block (name &rest body)
333 `(ert-deftest ,(intern (format "ruby-move-to-block-%s" name)) ()
334 (with-temp-buffer
335 (insert ruby-block-test-example)
336 (ruby-mode)
337 ,@body)))
338
339(put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun)
340
341(ruby-deftest-move-to-block works-on-do
342 (goto-line 11)
343 (ruby-end-of-block)
344 (should (= 12 (line-number-at-pos)))
345 (ruby-beginning-of-block)
346 (should (= 11 (line-number-at-pos))))
347
348(ruby-deftest-move-to-block zero-is-noop
349 (goto-line 5)
350 (ruby-move-to-block 0)
351 (should (= 5 (line-number-at-pos))))
352
353(ruby-deftest-move-to-block ok-with-three
354 (goto-line 2)
355 (ruby-move-to-block 3)
356 (should (= 13 (line-number-at-pos))))
357
358(ruby-deftest-move-to-block ok-with-minus-two
359 (goto-line 10)
360 (ruby-move-to-block -2)
361 (should (= 2 (line-number-at-pos))))
362
286(provide 'ruby-mode-tests) 363(provide 'ruby-mode-tests)
287 364
288;;; ruby-mode-tests.el ends here 365;;; ruby-mode-tests.el ends here