diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-02-23 05:15:17 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-02-23 05:15:17 -0500 |
| commit | 22c8cfaccf6012dd6e753a10cc5fe5c8867f5c7d (patch) | |
| tree | 59831030dcd1a5d02d50b517c29c5fc14221ceab /rust-mode-tests.el | |
| parent | 249e3cef5d3dacfec1c1947637d009dafa0fad8d (diff) | |
| parent | 52febe93a0b15740a3891855701555af404953ba (diff) | |
| download | rust-mode-22c8cfaccf6012dd6e753a10cc5fe5c8867f5c7d.tar.gz | |
Merge pull request #43 from MicahChalmer/indent-backslash-strings
Indent inside strings after line-ending backslash
Diffstat (limited to 'rust-mode-tests.el')
| -rw-r--r-- | rust-mode-tests.el | 123 |
1 files changed, 121 insertions, 2 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 4b32e94..007d116 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -284,8 +284,8 @@ very very very long string */" )) -(defun test-indent (indented) - (let ((deindented (replace-regexp-in-string "^[[:blank:]]*" " " indented))) +(defun test-indent (indented &optional deindented) + (let ((deindented (or deindented (replace-regexp-in-string "^[[:blank:]]*" " " indented)))) (rust-test-manip-code deindented 1 @@ -1207,3 +1207,122 @@ impl Foo for Bar { } " )) + +(ert-deftest test-indent-string-with-eol-backslash () + (test-indent + " +pub fn foo() { + format!(\"abc \\ + def\") +} +" + )) + +(ert-deftest test-indent-string-with-eol-backslash-at-start () + (test-indent + " +pub fn foo() { + format!(\"\\ + abc \\ + def\") +} +" + )) + +(ert-deftest test-indent-string-without-eol-backslash-indent-is-not-touched () + (test-indent + " +pub fn foo() { + format!(\" +abc +def\"); +} + +pub fn foo() { + format!(\"la la la +la +la la\"); +} +" + ;; Should still indent the code parts but leave the string internals alone: + " + pub fn foo() { + format!(\" +abc +def\"); +} + +pub fn foo() { + format!(\"la la la +la +la la\"); + } +" + )) + +(ert-deftest test-indent-string-eol-backslash-mixed-with-literal-eol () + (test-indent + " +fn foo() { + println!(\" +Here is the beginning of the string + and here is a line that is arbitrarily indented \\ + and a continuation of that indented line + and another arbitrary indentation + still another + yet another \\ + with a line continuing it +And another line not indented +\") +} +" + " +fn foo() { + println!(\" +Here is the beginning of the string + and here is a line that is arbitrarily indented \\ + and a continuation of that indented line + and another arbitrary indentation + still another + yet another \\ +with a line continuing it +And another line not indented +\") +} +")) + +(ert-deftest test-indent-string-eol-backslash-dont-touch-raw-strings () + (test-indent + " +pub fn foo() { + format!(r\"\ +abc\ + def\"); +} + +pub fn foo() { + format!(r\"la la la + la\ +la la\"); +} +" + ;; Should still indent the code parts but leave the string internals alone: + " + pub fn foo() { + format!(r\"\ +abc\ + def\"); +} + +pub fn foo() { + format!(r\"la la la + la\ +la la\"); +} +" + )) + +(ert-deftest indent-inside-string-first-line () + (test-indent + ;; Needs to leave 1 space before "world" + "\"hello \\\n world\"")) |
