Skip to content

Commit

Permalink
Move all the parsing tests into files by language
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 committed Jan 8, 2016
1 parent 2a82b9e commit 8f94974
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 133 deletions.
34 changes: 34 additions & 0 deletions test/smartparens-get-paired-expression-latex-test.el
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)
)
31 changes: 31 additions & 0 deletions test/smartparens-get-paired-expression-ruby-test.el
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)
)
133 changes: 0 additions & 133 deletions test/smartparens-get-paired-expression-test.el

This file was deleted.

0 comments on commit 8f94974

Please sign in to comment.