[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode d43fd73 141/385: more efficient indentati
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode d43fd73 141/385: more efficient indentation 'insert test |
Date: |
Tue, 5 Oct 2021 23:59:18 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit d43fd739d259882a174903754178efa3d7021ce5
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
more efficient indentation 'insert test
---
test/haskell-tng-indent-test.el | 51 +++++++++++++++++------------------
test/haskell-tng-testutils.el | 5 ++++
test/src/indentation.hs.append.indent | 2 ++
3 files changed, 31 insertions(+), 27 deletions(-)
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index 213de04..a926155 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -26,13 +26,15 @@
;; Test 1 involves a lot of buffer refreshing and will be very slow.
(ert-deftest haskell-tng-append-indent-file-tests ()
- ;; this is a very slow test
-
;; (require 'profiler)
;; (profiler-start 'cpu)
(should (have-expected-append-indent (testdata "src/indentation.hs")))
+ ;;(should (have-expected-append-indent (testdata "src/layout.hs")))
+ ;; this test is slow
+ ;;(should (have-expected-append-indent (testdata "src/medley.hs")))
+
;; (profiler-report)
;; (profiler-report-write-profile "indentation.profile")
;; (profiler-stop)
@@ -56,27 +58,22 @@
;; (should (have-expected-reindent (testdata "src/medley.hs")))
)
-(defun current-line-string ()
- (buffer-substring-no-properties
- (line-beginning-position)
- (- (line-beginning-position 2) 1)))
(defun haskell-tng-indent-test:work (mode)
- "MODE can be 'insert, 'reindent, or 'append.
-
-'append is VERY slow."
- ;; each line could be done in parallel, if emacs allowed such a thing...
- (let (indents kill)
- (while (not (eobp))
+ "MODE can be 'insert, 'reindent, or 'append."
+ (let (indents lines)
+ (pcase mode
+ ('append
+ (setq lines (split-string (buffer-string) (rx ?\n)))
+ (delete-region (point-min) (point-max))))
+ (while (pcase mode
+ ('append lines)
+ (_ (not (eobp))))
;; the command loop is necessary for this/last-command
+ (when lines
+ (insert (pop lines)))
(cl-flet ((RET ()
(end-of-line)
- (pcase mode
- ('append
- (setq kill ;; kill-region/yank is noisy
- (buffer-substring-no-properties
- (point) (point-max)))
- (delete-region (point) (point-max))))
(ert-simulate-command '(newline-and-indent))
(current-column))
(TAB ()
@@ -84,7 +81,7 @@
(current-column)))
(let ((orig (current-indentation))
- (line (current-line-string))
+ (line (haskell-tng-testutils:current-line-string))
(prime (pcase mode
((or 'insert 'append) (RET))
('reindent (TAB))))
@@ -99,16 +96,16 @@
;; unfortunately killing resets this-command so we can't test double
;; newline insertions, which could accidentally trigger alts only.
(pcase mode
- ('insert (kill-whole-line))
+ ('insert
+ (beginning-of-line)
+ (when (not (eobp))
+ (kill-whole-line)))
+ ('append
+ (beginning-of-line)
+ (when (not (eobp))
+ (delete-region (point) (point-max))))
('reindent
(indent-line-to orig)
- (ert-simulate-command '(forward-line)))
- ('append
- (forward-line -1)
- (end-of-line)
- (save-excursion
- (insert kill)
- (delete-region (point) (point-max)))
(ert-simulate-command '(forward-line)))))))
(reverse indents)))
diff --git a/test/haskell-tng-testutils.el b/test/haskell-tng-testutils.el
index 078f642..330e61e 100644
--- a/test/haskell-tng-testutils.el
+++ b/test/haskell-tng-testutils.el
@@ -44,6 +44,11 @@ Alternatively, if MODE is a buffer object, run TO-STRING
there instead."
(write-region got nil golden)
nil))))
+(defun haskell-tng-testutils:current-line-string ()
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))
+
(defun testdata (file)
(expand-file-name
file
diff --git a/test/src/indentation.hs.append.indent
b/test/src/indentation.hs.append.indent
index b630885..690d20d 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -99,4 +99,6 @@ v 1 2
v 1 2
-- TODO long type signatures vs definitions
+v 1 2
+
v 1 2
\ No newline at end of file
- [nongnu] elpa/haskell-tng-mode 387aa18 203/385: more efficient layout algorithm, (continued)
- [nongnu] elpa/haskell-tng-mode 387aa18 203/385: more efficient layout algorithm, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bfc3841 193/385: remove bind-key dependency, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6acba95 206/385: better insertion indentation on toplevels, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9bfc6bf 215/385: really basic imenu, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f648cf9 212/385: fallback to current directory (e.g. for cabal scripts), ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5bdf688 211/385: better in-line indentation of parens, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1cdf901 120/385: better escape syntax detection, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c40c6e6 125/385: fix explicit export fontification bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 82312a2 126/385: working compilation matchers, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 794c80b 131/385: better indentation alts, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d43fd73 141/385: more efficient indentation 'insert test,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode a830fcb 135/385: reindention test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode aa2a0ad 146/385: prefer --enable-tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a754020 144/385: indent alts will suggest based on previous <- lines, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9023dc6 164/385: don't rely on line-based indentation rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fdaaf38 148/385: indent after "in", ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e2c60a9 161/385: prep for records, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8e4f438 184/385: don't continue indenting one liner types, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5251477 186/385: thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 41f1ad5 191/385: document fast-tags, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4ec6259 185/385: prefer the lexer, ELPA Syncer, 2021/10/06