[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 9cbde7b 236/352: julia-mode: Move tests to new
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 9cbde7b 236/352: julia-mode: Move tests to new file and improve |
Date: |
Sun, 29 Aug 2021 11:22:52 -0400 (EDT) |
branch: elpa/julia-mode
commit 9cbde7bbe1c115543a821cae8f422db23f76e98e
Author: justbur <justin@burkett.cc>
Commit: Yichao Yu <yyc1992@gmail.com>
julia-mode: Move tests to new file and improve
Create file julia-mode-tests.el to hold all ert tests, so that tests are
not loaded with julia-mode.el
Instead of ignoring-warnings for everyone to get around some users not
having ert, use require with the NOERROR flag.
Have julia--run-tests print a helpful message for thsoe who do not have
ert installed.
Fixes #13237
---
julia-mode-tests.el | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++
julia-mode.el | 172 ----------------------------------------
2 files changed, 222 insertions(+), 172 deletions(-)
diff --git a/julia-mode-tests.el b/julia-mode-tests.el
new file mode 100644
index 0000000..1ad866f
--- /dev/null
+++ b/julia-mode-tests.el
@@ -0,0 +1,222 @@
+;;; julia-mode-tests.el --- Tests for julia-mode.el
+
+;; Copyright (C) 2009-2014 Julia contributors
+;; URL: https://github.com/JuliaLang/julia
+;; Version: 0.3
+;; Keywords: languages
+
+;;; Usage:
+
+;; From command line:
+;;
+;; emacs -batch -L . -l ert -l julia-mode-tests.el -f
ert-run-tests-batch-and-exit
+
+;;; Commentary:
+;; Contains ert tests for julia-mode.el
+
+;;; License:
+;; Permission is hereby granted, free of charge, to any person obtaining
+;; a copy of this software and associated documentation files (the
+;; "Software"), to deal in the Software without restriction, including
+;; without limitation the rights to use, copy, modify, merge, publish,
+;; distribute, sublicense, and/or sell copies of the Software, and to
+;; permit persons to whom the Software is furnished to do so, subject to
+;; the following conditions:
+;;
+;; The above copyright notice and this permission notice shall be
+;; included in all copies or substantial portions of the Software.
+;;
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+;;; Code:
+
+;; We can't use cl-lib whilst supporting Emacs 23 users who don't use
+;; ELPA.
+(with-no-warnings
+ (require 'cl)) ;; incf, decf, plusp
+
+(require 'julia-mode)
+(require 'ert)
+
+(defmacro julia--should-indent (from to)
+ "Assert that we indent text FROM producing text TO in `julia-mode'."
+ `(with-temp-buffer
+ (let ((julia-indent-offset 4))
+ (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 the text after an open paren."
+ (julia--should-indent
+ "
+foobar(bar,
+baz)"
+ "
+foobar(bar,
+ baz)"))
+
+(ert-deftest julia--test-indent-paren-space ()
+ "We should indent to line up with the text after an open
+paren, even if there are additional spaces."
+ (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"))
+
+(ert-deftest julia--test-indent-comment-equal ()
+ "`=` at the end of comment should not increase indent level."
+ (julia--should-indent
+ "
+# a =
+# b =
+c"
+ "
+# a =
+# b =
+c"))
+
+(ert-deftest julia--test-indent-leading-paren ()
+ "`(` at the beginning of a line should not affect indentation."
+ (julia--should-indent
+ "
+\(1)"
+ "
+\(1)"))
+
+(ert-deftest julia--test-top-level-following-paren-indent ()
+ "`At the top level, a previous line indented due to parens should not affect
indentation."
+ (julia--should-indent
+ "y1 = f(x,
+ z)
+y2 = g(x)"
+ "y1 = f(x,
+ z)
+y2 = g(x)"))
+
+(defun julia--run-tests ()
+ (interactive)
+ (if (featurep 'ert)
+ (ert-run-tests-interactively "julia--test")
+ (message "Can't run julia-mode-tests because ert is not available.")))
+
+(provide 'julia-mode-tests)
+;; Local Variables:
+;; coding: utf-8
+;; byte-compile-warnings: (not obsolete)
+;; End:
+;;; julia-mode-tests.el ends here
diff --git a/julia-mode.el b/julia-mode.el
index 0907483..58aafa3 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -461,178 +461,6 @@ with it. Returns nil if we're not within nested parens."
(when (>= point-offset 0)
(move-to-column (+ (current-indentation) point-offset)))))
-(defmacro julia--should-indent (from to)
- "Assert that we indent text FROM producing text TO in `julia-mode'."
- `(with-temp-buffer
- (let ((julia-indent-offset 4))
- (julia-mode)
- (insert ,from)
- (indent-region (point-min) (point-max))
- (should (equal (buffer-substring-no-properties (point-min) (point-max))
- ,to)))))
-
-;; Emacs 23.X doesn't include ert, so we ignore any errors that occur
-;; when we define tests.
-(ignore-errors
- (require 'ert)
-
- (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 the text after an open paren."
- (julia--should-indent
- "
-foobar(bar,
-baz)"
- "
-foobar(bar,
- baz)"))
-
- (ert-deftest julia--test-indent-paren-space ()
- "We should indent to line up with the text after an open
-paren, even if there are additional spaces."
- (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"))
-
- (ert-deftest julia--test-indent-comment-equal ()
- "`=` at the end of comment should not increase indent level."
- (julia--should-indent
- "
-# a =
-# b =
-c"
- "
-# a =
-# b =
-c"))
-
- (ert-deftest julia--test-indent-leading-paren ()
- "`(` at the beginning of a line should not affect indentation."
- (julia--should-indent
- "
-(1)"
- "
-(1)"))
-
- (ert-deftest julia--test-top-level-following-paren-indent ()
- "`At the top level, a previous line indented due to parens should not
affect indentation."
- (julia--should-indent
- "y1 = f(x,
- z)
-y2 = g(x)"
- "y1 = f(x,
- z)
-y2 = g(x)"))
-
- (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 ca2fe4b 195/352: Removing julia-in-char., (continued)
- [nongnu] elpa/julia-mode ca2fe4b 195/352: Removing julia-in-char., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ea54e19 196/352: Fontify strings and chars as strings, not keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 80c6754 197/352: Silencing byte-compiler warning., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e4d0e09 199/352: Highlight quoted symbols, e.g. :foo., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4b22a79 205/352: julia-mode.el: remove types that are removed or deprecated, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f84a425 219/352: Clean up stagedfunction, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f378cbc 208/352: Mailmap update., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f3b490b 210/352: Added inferior-julia comint mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8dd023d 223/352: julia-paren-indent: docstring, test, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8d6ea60 233/352: Fix #11549 (top level after paren-indented line), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 9cbde7b 236/352: julia-mode: Move tests to new file and improve,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 1f06e85 234/352: Alias `run-julia` to `inferior-julia` in julia-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode a82e629 239/352: julia-mode: Indent manually inside strings with \n, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 1746c4b 238/352: julia-mode: Improve paren indent perf, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 44c9959 241/352: julia-mode: Fix #15461, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4f56ded 258/352: make lookback distance customizable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 362be60 255/352: Merge pull request #26 from JeffBezanson/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 6add61b 254/352: fix indenting after commented `end`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8818ede 245/352: fix ignoring of keywords inside comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 9067194 268/352: Merge pull request #38 from Wilfred/patch-1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode edaaff2 276/352: Bin op chars (#44), ELPA Syncer, 2021/08/29