((ruby-smie--opening-pipe-p) "opening-|")
((ruby-smie--closing-pipe-p) "closing-|")
(t tok)))
+ ((string-match "\\`[^|]+|\\'" tok)
+ (forward-char -1)
+ (substring tok 0 -1))
((and (equal tok "") (looking-at "\\\\\n"))
(goto-char (match-end 0)) (ruby-smie--forward-token))
((equal tok "do")
((ruby-smie--opening-pipe-p) "opening-|")
((ruby-smie--closing-pipe-p) "closing-|")
(t tok)))
+ ((string-match-p "\\`[^|]+|\\'" tok) "closing-|")
((string-match-p "\\`|[*&]\\'" tok)
(forward-char 1)
(substring tok 1))
(ruby-backward-sexp)
(should (= 2 (line-number-at-pos)))))
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-no-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do
+ |end")
+ (search-backward "do\n")
+ (ruby-forward-sexp)
+ (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-no-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do
+ |end")
+ (goto-char (point-max))
+ (ruby-backward-sexp)
+ (should (looking-at "do$"))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-empty-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do ||
+ |end")
+ (search-backward "do ")
+ (ruby-forward-sexp)
+ (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-empty-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do ||
+ |end")
+ (goto-char (point-max))
+ (ruby-backward-sexp)
+ (should (looking-at "do "))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do |a,b|
+ |end")
+ (search-backward "do ")
+ (ruby-forward-sexp)
+ (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do |a,b|
+ |end")
+ (goto-char (point-max))
+ (ruby-backward-sexp)
+ (should (looking-at "do "))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-any-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do |*|
+ |end")
+ (search-backward "do ")
+ (ruby-forward-sexp)
+ (should (eobp))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-expanded-one-arg ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do |a,|
+ |end")
+ (search-backward "do ")
+ (ruby-forward-sexp)
+ (should (eobp))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-one-and-any-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do |a,*|
+ |end")
+ (search-backward "do ")
+ (ruby-forward-sexp)
+ (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-one-and-any-args ()
+ (ruby-with-temp-buffer
+ (ruby-test-string
+ "proc do |a,*|
+ |end")
+ (goto-char (point-max))
+ (ruby-backward-sexp)
+ (should (looking-at "do "))))
+
(ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
(let ((pairs
'(("puts '\"foo\"\\''" . "puts \"\\\"foo\\\"'\"")