[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 70bbe82 204/352: Adding unit tests for indentat
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 70bbe82 204/352: Adding unit tests for indentation. |
Date: |
Sun, 29 Aug 2021 11:22:45 -0400 (EDT) |
branch: elpa/julia-mode
commit 70bbe82260e1baacb3d657306a7d24c159955fb7
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>
Adding unit tests for indentation.
---
julia-mode.el | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
diff --git a/julia-mode.el b/julia-mode.el
index 788a116..b99cab1 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -410,6 +410,136 @@ before point. Returns nil if we're not within nested
parens."
(when (>= point-offset 0)
(move-to-column (+ (current-indentation) point-offset)))))
+;; Emacs 23.X doesn't include ert, so we ignore any errors that occur
+;; when we define tests.
+(ignore-errors
+ (require 'ert)
+
+ (defmacro julia--should-indent (from to)
+ "Assert that we indent text FROM producing text TO in `julia-mode'."
+ `(with-temp-buffer
+ (julia-mode)
+ (insert ,from)
+ (indent-region (point-min) (point-max))
+ (should (equal (buffer-substring-no-properties (point-min) (point-max))
+ ,to))))
+
+ (ert-deftest julia--test-indent-if ()
+ "We should indent inside if bodies."
+ (julia--should-indent
+ "
+if foo
+bar
+end"
+ "
+if foo
+ bar
+end"))
+
+ (ert-deftest julia--test-indent-else ()
+ "We should indent inside else bodies."
+ (julia--should-indent
+ "
+if foo
+ bar
+else
+baz
+end"
+ "
+if foo
+ bar
+else
+ baz
+end"))
+
+ (ert-deftest julia--test-indent-toplevel ()
+ "We should not indent toplevel expressions. "
+ (julia--should-indent
+ "
+foo()
+bar()"
+ "
+foo()
+bar()"))
+
+ (ert-deftest julia--test-indent-nested-if ()
+ "We should indent for each level of indentation."
+ (julia--should-indent
+ "
+if foo
+ if bar
+bar
+ end
+end"
+ "
+if foo
+ if bar
+ bar
+ end
+end"))
+
+ (ert-deftest julia--test-indent-function ()
+ "We should indent function bodies."
+ (julia--should-indent
+ "
+function foo()
+bar
+end"
+ "
+function foo()
+ bar
+end"))
+
+ (ert-deftest julia--test-indent-begin ()
+ "We should indent after a begin keyword."
+ (julia--should-indent
+ "
+@async begin
+bar
+end"
+ "
+@async begin
+ bar
+end"))
+
+ (ert-deftest julia--test-indent-paren ()
+ "We should indent to line up with open parens."
+ (julia--should-indent
+ "
+foobar(bar,
+baz)"
+ "
+foobar(bar,
+ baz)"))
+
+ (ert-deftest julia--test-indent-equals ()
+ "We should increase indent on a trailing =."
+ (julia--should-indent
+ "
+foo() =
+bar"
+ "
+foo() =
+ bar"))
+
+ (ert-deftest julia--test-indent-ignores-blank-lines ()
+ "Blank lines should not affect indentation of non-blank lines."
+ (julia--should-indent
+ "
+if foo
+
+bar
+end"
+ "
+if foo
+
+ bar
+end"))
+
+ (defun julia--run-tests ()
+ (interactive)
+ (ert-run-tests-interactively "julia--test")))
+
(defalias 'julia-mode-prog-mode
(if (fboundp 'prog-mode)
'prog-mode
- [nongnu] elpa/julia-mode c45c786 335/352: Add more tests, (continued)
- [nongnu] elpa/julia-mode c45c786 335/352: Add more tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 549a7b4 341/352: Remove C_NULL from constants and add Cvoid, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 13a3c53 344/352: Merge branch 'master' into triple-quote-cmd, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ac7431c 174/352: Mark @ and ! as a symbol constituents, as suggested by @Clemens-H., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ac55340 175/352: Factoring out a types regex., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d96a08c 180/352: Refactoring julia-char-regex as an rx form., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 76d5d75 183/352: Optimising julia-at-keyword., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 9cdad57 187/352: Make julia-char-regex stricter., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ff5fc36 202/352: julia-mode.el: allow space or no space after :: and <:, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 05f002c 203/352: When indenting code, limit how far back we search., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 70bbe82 204/352: Adding unit tests for indentation.,
ELPA Syncer <=
- [nongnu] elpa/julia-mode ff8adf5 221/352: Add tests for #11684. [ci skip], ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8ab2a60 222/352: julia-paren-indent skips blanks after paren, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c8dfbe2 227/352: Declare indentation as customizable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 011435c 237/352: julia-mode: Fix indent for hanging ops and module, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c2f0ed8 235/352: julia-mode: Fix prompt regexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode a95b06b 252/352: Merge pull request #20 from tpapp/indent-export, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 847908e 249/352: Add indent for import and export., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7b1d3fb 253/352: Merge pull request #21 from kshramt/python-paren-indent, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f591c6d 275/352: Merge pull request #41 from rfourquet/rf/where-return, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8449c95 295/352: Merge pull request #69 from emmt/master, ELPA Syncer, 2021/08/29