diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-02-05 20:56:46 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-02-05 20:56:53 -0500 |
| commit | f0d4c25b9f13702d6c4b6ca7fe7fca9df4e7f4e3 (patch) | |
| tree | ebab481fe46789687cece6ac360a08a8ac257b26 /rust-mode-tests.el | |
| parent | 66438d4e7c25587bf396fb0ee7063a1869ad04a3 (diff) | |
| download | rust-mode-f0d4c25b9f13702d6c4b6ca7fe7fca9df4e7f4e3.tar.gz | |
Fix aligning of method chains (more-or-less) and add various unit tests.
The regular expressions are probably kind of wrong for things like
self.foo.something::<X>()
.more();
Diffstat (limited to 'rust-mode-tests.el')
| -rw-r--r-- | rust-mode-tests.el | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 2b18728..2e6f77f 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -919,3 +919,89 @@ list of substrings of `STR' each followed by its face." "main" font-lock-function-name-face "let" font-lock-keyword-face "'\\''" font-lock-string-face))) + +(ert-deftest indent-method-chains-no-align () + (let ((rust-indent-method-chain nil)) (test-indent + " +fn main() { + let x = thing.do_it() + .aligned() + .more_alignment(); +} +" + ))) + +(ert-deftest indent-method-chains-with-align () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + let x = thing.do_it() + .aligned() + .more_alignment(); +} +" + ))) + +(ert-deftest indent-method-chains-with-align-and-second-stmt () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + let x = thing.do_it() + .aligned() + .more_alignment(); + foo.bar(); +} +" + ))) + +(ert-deftest indent-method-chains-field () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + let x = thing.do_it + .aligned + .more_alignment(); +} +" + ))) + +(ert-deftest indent-method-chains-double-field-on-first-line () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + let x = thing.a.do_it + .aligned + .more_alignment(); +} +" + ))) + +(ert-deftest indent-method-chains-no-let () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + thing.a.do_it + .aligned + .more_alignment(); +} +" + ))) + +(ert-deftest indent-method-chains-comment () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + // thing.do_it() + // .aligned() +} +" + ))) + +(ert-deftest indent-method-chains-close-block () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + foo.bar() +} +" + ))) |
