-
-
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.
[Fix #661] Fix parsing of strings nested in string fences
- Loading branch information
Showing
3 changed files
with
64 additions
and
3 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
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
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,36 @@ | ||
(require 'smartparens-python) | ||
|
||
(defmacro sp-test-with-temp-python-buffer (initial &rest forms) | ||
(declare (indent 1) | ||
(debug (form body))) | ||
`(sp-test-with-temp-buffer ,initial | ||
(shut-up (python-mode)) | ||
,@forms)) | ||
|
||
(ert-deftest sp-test--python-get-thing-which-is-string-inside-string () | ||
(sp-test-with-temp-python-buffer "\"foo bar | 'baz qux' fux\"" | ||
(should (equal (sp-get-thing) '(:beg 11 :end 20 :op "'" :cl "'" :prefix "" :suffix "")))) | ||
|
||
(sp-test-with-temp-python-buffer "\"foo bar 'baz qux' | fux\"" | ||
(should (equal (sp-get-thing t) '(:beg 10 :end 19 :op "'" :cl "'" :prefix "" :suffix ""))))) | ||
|
||
(ert-deftest sp-test--python-get-expression-which-is-string-inside-string () | ||
(sp-test-with-temp-python-buffer "\"foo bar | 'baz qux' fux\"" | ||
(should (equal (sp-get-expression) '(:beg 11 :end 20 :op "'" :cl "'" :prefix "" :suffix "")))) | ||
|
||
(sp-test-with-temp-python-buffer "\"foo bar 'baz qux' | fux\"" | ||
(should (equal (sp-get-expression t) '(:beg 10 :end 19 :op "'" :cl "'" :prefix "" :suffix ""))))) | ||
|
||
(ert-deftest sp-test--python-get-stringlike-expression-inside-string () | ||
(sp-test-with-temp-python-buffer "\"foo bar | 'baz qux' fux\"" | ||
(should (equal (sp-get-stringlike-expression) '(:beg 11 :end 20 :op "'" :cl "'" :prefix "" :suffix "")))) | ||
|
||
(sp-test-with-temp-python-buffer "\"foo bar 'baz qux' | fux\"" | ||
(should (equal (sp-get-stringlike-expression t) '(:beg 10 :end 19 :op "'" :cl "'" :prefix "" :suffix ""))))) | ||
|
||
(ert-deftest sp-test--python-get-stringlike-or-textmode-expression-inside-string () | ||
(sp-test-with-temp-python-buffer "\"foo bar | 'baz qux' fux\"" | ||
(should (equal (sp-get-stringlike-or-textmode-expression) '(:beg 11 :end 20 :op "'" :cl "'" :prefix "" :suffix "")))) | ||
|
||
(sp-test-with-temp-python-buffer "\"foo bar 'baz qux' | fux\"" | ||
(should (equal (sp-get-stringlike-or-textmode-expression t) '(:beg 10 :end 19 :op "'" :cl "'" :prefix "" :suffix ""))))) |