-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all the parsing tests into files by language
- Loading branch information
Showing
3 changed files
with
65 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(defun sp-test--paired-expression-parse-in-latex (initial result &optional back) | ||
(let ((sp-pairs '((t . ((:open "\\{" :close "\\}" :actions (insert wrap autoskip navigate)) | ||
(:open "(" :close ")" :actions (insert wrap autoskip navigate)) | ||
(:open "[" :close "]" :actions (insert wrap autoskip navigate)) | ||
(:open "{" :close "}" :actions (insert wrap autoskip navigate)) | ||
(:open "\"" :close "\"" :actions (insert wrap autoskip navigate)) | ||
(:open "\\\"" :close "\\\"" :actions (insert wrap autoskip navigate)) | ||
(:open "\\langle" :close "\\rangle" :actions (insert wrap autoskip navigate)) | ||
(:open "OPEN" :close "CLOSE" :actions (insert wrap autoskip navigate)) | ||
(:open "\\big(" :close "\\big)" :actions (insert wrap autoskip navigate) :trigger "\\b") | ||
(:open "``" :close "''" :actions (insert wrap autoskip navigate)) | ||
(:open "`" :close "'" :actions (insert wrap autoskip navigate)) | ||
(:open "$" :close "$" :actions (insert wrap autoskip navigate))))))) | ||
(sp-test-with-temp-buffer initial | ||
(latex-mode) | ||
(should (equal (sp-get-paired-expression back) result))))) | ||
|
||
(ert-deftest sp-test-get-paired-expression-latex () | ||
(sp-test--paired-expression-parse-in-latex "|``''" '(:beg 1 :end 5 :op "``" :cl "''" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-latex "``|''" '(:beg 1 :end 5 :op "``" :cl "''" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-latex "|foo ``bar'' baz" '(:beg 5 :end 12 :op "``" :cl "''" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-latex "|`'" '(:beg 1 :end 3 :op "`" :cl "'" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-latex "`|'" '(:beg 1 :end 3 :op "`" :cl "'" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-latex "|foo `bar' baz" '(:beg 5 :end 10 :op "`" :cl "'" :prefix "" :suffix "")) | ||
) | ||
|
||
(ert-deftest sp-test-get-paired-expression-latex-backward () | ||
(sp-test--paired-expression-parse-in-latex "``''|" '(:beg 1 :end 5 :op "``" :cl "''" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-latex "``|''" '(:beg 1 :end 5 :op "``" :cl "''" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-latex "foo ``bar'' b|az" '(:beg 5 :end 12 :op "``" :cl "''" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-latex "`'|" '(:beg 1 :end 3 :op "`" :cl "'" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-latex "`|'" '(:beg 1 :end 3 :op "`" :cl "'" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-latex "foo `bar' baz|" '(:beg 5 :end 10 :op "`" :cl "'" :prefix "" :suffix "") t) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(defun sp-test--paired-expression-parse-in-ruby (initial result &optional back) | ||
(let ((sp-pairs '((t . ((:open "def" :close "end" :actions (insert wrap autoskip navigate)) | ||
(:open "if" :close "end" :actions (insert wrap autoskip navigate)) | ||
(:open "do" :close "end" :actions (insert wrap autoskip navigate)) | ||
(:open "begin" :close "end" :actions (insert wrap autoskip navigate))))))) | ||
(sp-test-with-temp-buffer initial | ||
(ruby-mode) | ||
(should (equal (sp-get-paired-expression back) result))))) | ||
|
||
(ert-deftest sp-test-get-paired-expression-ruby () | ||
(sp-test--paired-expression-parse-in-ruby "|begin end" '(:beg 1 :end 10 :op "begin" :cl "end" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-ruby "begin |end" '(:beg 1 :end 10 :op "begin" :cl "end" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-ruby "|def foo bar if blaz end end" '(:beg 1 :end 28 :op "def" :cl "end" :prefix "" :suffix "")) | ||
(sp-test--paired-expression-parse-in-ruby "|def foo end;" '(:beg 1 :end 12 :op "def" :cl "end" :prefix "" :suffix "")) | ||
) | ||
|
||
(ert-deftest sp-test-get-paired-expression-ruby-backward () | ||
(sp-test--paired-expression-parse-in-ruby "begin end|" '(:beg 1 :end 10 :op "begin" :cl "end" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-ruby "begin| end" '(:beg 1 :end 10 :op "begin" :cl "end" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-ruby "def foo bar if blaz end end|" '(:beg 1 :end 28 :op "def" :cl "end" :prefix "" :suffix "") t) | ||
(sp-test--paired-expression-parse-in-ruby "def foo end;|" '(:beg 1 :end 12 :op "def" :cl "end" :prefix "" :suffix "") t) | ||
) | ||
|
||
(ert-deftest sp-test-get-paired-expression-ruby-fail () | ||
(sp-test--paired-expression-parse-in-ruby "|def en" nil) | ||
(sp-test--paired-expression-parse-in-ruby "|do do end do" nil) | ||
) | ||
|
||
(ert-deftest sp-test-get-paired-expression-ruby-backward-fail () | ||
(sp-test--paired-expression-parse-in-ruby "de end|" nil t) | ||
) |
This file was deleted.
Oops, something went wrong.