[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode e97861c 226/468: ert-tests/test-electric-mode.el:
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode e97861c 226/468: ert-tests/test-electric-mode.el: add tests for electric indentation |
Date: |
Thu, 5 Aug 2021 04:58:41 -0400 (EDT) |
branch: elpa/lua-mode
commit e97861cb36509c0a206bcbcc92ebd2d8a8ddb0d0
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
ert-tests/test-electric-mode.el: add tests for electric indentation
---
Cask | 3 ++
Makefile | 1 +
ert-tests/test-electric-mode.el | 65 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/Cask b/Cask
index 9dcc96b..8f1dd5a 100644
--- a/Cask
+++ b/Cask
@@ -2,6 +2,9 @@
(package "lua-mode" "dev" "Major mode for editing Lua")
+(development
+ (depends-on "s"))
+
;; Local Variables:
;; mode: emacs-lisp
;; End:
diff --git a/Makefile b/Makefile
index 1cacc2c..24f6f2a 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@ EMACS_BATCH=cask exec $(EMACS) --batch -Q
TESTS=
TESTS += ert-tests/test-defun-font-lock.el
TESTS += ert-tests/test-builtin-font-lock.el
+TESTS += ert-tests/test-electric-mode.el
default:
@echo version is $(VERSION)
diff --git a/ert-tests/test-electric-mode.el b/ert-tests/test-electric-mode.el
new file mode 100644
index 0000000..f05259f
--- /dev/null
+++ b/ert-tests/test-electric-mode.el
@@ -0,0 +1,65 @@
+(require 'ert)
+(require 's)
+
+(defmacro with-lua-buffer (&rest body)
+ `(with-temp-buffer
+ (switch-to-buffer (current-buffer))
+ (lua-mode)
+ (font-lock-fontify-buffer)
+ ,@body))
+
+
+(ert-deftest test-electric-brace ()
+ (with-lua-buffer
+ (execute-kbd-macro (kbd "return SPC foo SPC { C-j"))
+ (execute-kbd-macro (kbd "'baz' C-j"))
+ (should (eq (current-indentation) lua-indent-level))
+
+ (execute-kbd-macro (kbd "}"))
+ (should (eq (current-indentation) 0))))
+
+
+(ert-deftest test-electric-paren ()
+ (with-lua-buffer
+ (execute-kbd-macro (kbd "return SPC foo SPC ( C-j"))
+ (execute-kbd-macro (kbd "'baz' C-j"))
+ (should (eq (current-indentation) lua-indent-level))
+
+ (execute-kbd-macro (kbd ")"))
+ (should (eq (current-indentation) 0))))
+
+
+(ert-deftest test-electric-end ()
+ (with-lua-buffer
+ (execute-kbd-macro (kbd "if SPC foo SPC then C-j"))
+ (execute-kbd-macro (kbd "'baz' C-j"))
+ (should (eq (current-indentation) lua-indent-level))
+
+ (abbrev-mode 1)
+ (execute-kbd-macro (kbd "end C-j"))
+ (beginning-of-line 0)
+ (should (eq (current-indentation) 0))))
+
+
+(ert-deftest test-electric-else ()
+ (with-lua-buffer
+ (execute-kbd-macro (kbd "if SPC foo SPC then C-j"))
+ (execute-kbd-macro (kbd "'baz' C-j"))
+ (should (eq (current-indentation) lua-indent-level))
+
+ (abbrev-mode 1)
+ (execute-kbd-macro (kbd "else C-j"))
+ (beginning-of-line 0)
+ (should (eq (current-indentation) 0))))
+
+
+(ert-deftest test-electric-elseif ()
+ (with-lua-buffer
+ (execute-kbd-macro (kbd "if SPC foo SPC then C-j"))
+ (execute-kbd-macro (kbd "'baz' C-j"))
+ (should (eq (current-indentation) lua-indent-level))
+
+ (abbrev-mode 1)
+ (execute-kbd-macro (kbd "elseif C-j"))
+ (beginning-of-line 0)
+ (should (eq (current-indentation) 0))))
- [nongnu] elpa/lua-mode 0a986f7 266/468: Add hideshow support for "repeat... until" blocks, (continued)
- [nongnu] elpa/lua-mode 0a986f7 266/468: Add hideshow support for "repeat... until" blocks, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8d27d2c 268/468: fixed up tests && improved lua-kill-process, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 82daeb5 297/468: Merge pull request #88 from tarsius/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7b2c18c 305/468: Merge pull request #99 from tarsius/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6f4035a 315/468: Merge pull request #108 from ptrv/patch-1, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f2915c3 324/468: Add string tab escape test, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 652e299 339/468: gitignore: add cask working dir, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode adb1f3a 334/468: lua_loadstring: fix variables that were made global, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 191eb10 330/468: Makefile: add "nocask" targets, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 25c2535 343/468: test-inferior-process: temporarily disable failing test, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e97861c 226/468: ert-tests/test-electric-mode.el: add tests for electric indentation,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode ec35884 228/468: Suppress fontification messages in emacs23 test output, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c995c7a 103/468: Use beginning-of-defun-function and end-of-defun-function variables, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 91b5974 104/468: minor style fixes, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8be4f4e 108/468: .gitignore: ignore byte-compiled files, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c69e150 112/468: Makefile: add compile target, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 993e042 113/468: Merge branch 'multiline_literals', Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d742cae 116/468: lua-mark-all-multiline-literals: comment out debug message, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5542927 122/468: lua-automark-multiline: add function to enable automatical multiline construct marking when emacs is idle, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6beb586 123/468: Add customizable lua-automark-multiline-interval variable, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode eab8fc0 136/468: Move docstrings to the end of constants., Philip Kaludercic, 2021/08/05