[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/macrostep b1c1230 079/110: More tests
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/macrostep b1c1230 079/110: More tests |
Date: |
Sat, 7 Aug 2021 09:18:06 -0400 (EDT) |
branch: elpa/macrostep
commit b1c1230b7fd64602064f6aeeb42bcc13785793cf
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
More tests
---
macrostep-test.el | 118 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 88 insertions(+), 30 deletions(-)
diff --git a/macrostep-test.el b/macrostep-test.el
index 5eaaa45..1ae9692 100644
--- a/macrostep-test.el
+++ b/macrostep-test.el
@@ -17,6 +17,8 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see `http://www.gnu.org/licenses/'.
+
+;;;; Conveniences for defining tests
(defmacro macrostep-with-text (object &rest forms)
(declare (indent 1)
@@ -30,6 +32,12 @@
(print ,object))
,@forms)))
+(defun macrostep-goto (text &optional from-point-min)
+ (when from-point-min (goto-char (point-min)))
+ (let ((search-whitespace-regexp "[[:space:]\n]+"))
+ (search-forward-lax-whitespace text)
+ (goto-char (match-beginning 0))))
+
(defmacro macrostep-should-expand (form expansion)
`(save-excursion
(goto-char (point-min))
@@ -45,6 +53,8 @@
,expansion)))
(macrostep-collapse-all)))))
+
+;;;; Tests
(ert-deftest macrostep-expand-defmacro ()
(defmacro macrostep-dummy-macro (&rest args)
`(expansion of ,@args))
@@ -58,6 +68,34 @@
'(macrostep-dummy-macro (first (argument)) second (third argument))
'(expansion of (first (argument)) second (third argument)))))
+(ert-deftest macrostep-expand-and-collapse ()
+ (dolist (expander
+ (list
+ #'identity
+ (lambda (sexp) `(progn ,sexp ,sexp))
+ (lambda (sexp) `(long
+ (complicated
+ (expansion of ,sexp () ())
+ (with trailing forms))))))
+ (let ((macrostep-expand-1-function expander)
+ (macrostep-macro-form-p-function
+ (lambda (&rest _) t)))
+ (macrostep-with-text
+ '(progn
+ (first form)
+ (second form)
+ (third (nested form)))
+ (macrostep-goto "(first ")
+ (let ((original-text (buffer-string)))
+ (dotimes (i 10)
+ (dotimes (j i)
+ (macrostep-expand))
+ (dotimes (j i)
+ (macrostep-collapse))
+ (should (null macrostep-overlays))
+ (should (string= (buffer-string)
+ original-text))))))))
+
(ert-deftest macrostep-expand-macrolet ()
(macrostep-with-text
'(macrolet
@@ -162,6 +200,30 @@
(apply (cdr (assq 'get env)) '(:begin))
'(plist-get list :begin))))))
+(ert-deftest macrostep-environment-at-point-2 ()
+ (defmacro macrostep-with-dummy (&rest body)
+ `(cl-macrolet ((dummy (&rest forms) `(expansion of ,@forms)))
+ ,@body))
+ (macrostep-with-text
+ '(macrostep-with-dummy
+ (body)
+ (forms)
+ (cl-loop for i from 6 to 10
+ do (something)))
+ (macrostep-goto "(macrostep-with-dummy" t)
+ (should (null (macrostep-environment-at-point)))
+
+ (dolist (place (list "(body)" "dy)" "(forms)" "rms)"
+ "(something)"))
+ (macrostep-goto place)
+ (let* ((env (macrostep-environment-at-point))
+ (dummy-defn (cdr (assq 'dummy env))))
+ (should dummy-defn)
+ (should (functionp dummy-defn))
+ (should (equal
+ (funcall dummy-defn 'lorem 'ipsum)
+ `(expansion of lorem ipsum)))))))
+
(ert-deftest macrostep-print-sexp ()
(cl-macrolet ((should-print (form string)
`(should (equal
@@ -187,36 +249,32 @@
(ert-deftest macrostep-pp-macrolet-environment ()
(with-temp-buffer
(emacs-lisp-mode)
- (save-excursion
- (macrostep-pp
- '(macrolet ((some-macro (&rest forms) (cons 'progn forms)))
- (some-macro with (arguments))
- (intervening body forms)
- (some-macro with (more) (arguments))))
- (cl-flet ((search (text)
- (goto-char (point-min))
- (let ((search-whitespace-regexp "[[:space:]\n]+"))
- (search-forward-lax-whitespace text))
- (goto-char (match-beginning 0))
- ;; Leave point on the head of the form
- (forward-char)))
- ;; The occurrence of "(some-macro" in the binding list should
- ;; not be fontified as a macro form
- (search "(some-macro (&rest")
- (should-not
- (eq (get-char-property (point) 'font-lock-face)
- 'macrostep-macro-face))
+ (macrostep-pp
+ '(macrolet ((some-macro (&rest forms) (cons 'progn forms)))
+ (some-macro with (arguments))
+ (intervening body forms)
+ (some-macro with (more) (arguments))))
+ (cl-flet ((search (text)
+ (macrostep-goto text t)
+ ;; Leave point on the head of the form
+ (forward-char)))
+ ;; The occurrence of "(some-macro" in the binding list should
+ ;; not be fontified as a macro form
+ (search "(some-macro (&rest")
+ (should-not
+ (eq (get-char-property (point) 'font-lock-face)
+ 'macrostep-macro-face))
- ;; However, the two occurrences in the body of the macrolet should be.
- (search "(some-macro with (arguments)")
- (should
- (eq (get-char-property (point) 'font-lock-face)
- 'macrostep-macro-face))
+ ;; However, the two occurrences in the body of the macrolet should be.
+ (search "(some-macro with (arguments)")
+ (should
+ (eq (get-char-property (point) 'font-lock-face)
+ 'macrostep-macro-face))
- (search "(some-macro with (more)")
- (should
- (eq (get-char-property (point) 'font-lock-face)
- 'macrostep-macro-face))))))
+ (search "(some-macro with (more)")
+ (should
+ (eq (get-char-property (point) 'font-lock-face)
+ 'macrostep-macro-face)))))
(ert-deftest macrostep-expand-macro-defined-macros ()
(defmacro with-local-dummy-macro (&rest body)
@@ -261,8 +319,8 @@
`(expansion of ,@args)))
(dummy-macro-1 (some (arguments))))
(let ((original-buffer (current-buffer)))
- (search-forward "(dummy-macro-1 (some")
- (goto-char (match-beginning 0))
+ (macrostep-goto "(dummy-macro-1 (some")
+
(macrostep-expand)
(should (not (equal (current-buffer) original-buffer)))
(should macrostep-expansion-buffer)
- [nongnu] elpa/macrostep 0067091 018/110: fix youtube link in docs, (continued)
- [nongnu] elpa/macrostep 0067091 018/110: fix youtube link in docs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep ee46132 008/110: Print dotted lists in expansions correctly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 99d2cc7 020/110: Don't fontify a quoted macro since this won't get expanded normally, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep f8f0424 027/110: Fix header dates, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 9a534df 052/110: Make macrostep-slime-insert more robust, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 352b6d2 042/110: Minor improvements to SLIME prototype, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 3062d4c 046/110: Add support for compiler macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 874c790 058/110: WIP: smarter SLIME macroexpansion, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep d7991b4 070/110: Track forms using the printer rather than the reader, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep dd14d5c 077/110: Remove unused function `bindings-to-environment`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep b1c1230 079/110: More tests,
ELPA Syncer <=
- [nongnu] elpa/macrostep 4b382cd 088/110: Identify Elisp compiler-macros more selectively, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep a3338d3 104/110: Make test script exit non-zero on failure, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e537612 106/110: compmiler-macro changed to compiler-macro, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep a5b980e 035/110: Update readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep fbd61eb 030/110: Tests for macrolet/cl-macrolet support, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep afed3cf 072/110: MARKER-CHAR-POSITION => MARKER-CHAR-ID, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 2390cec 075/110: slime-sexp-at-point may return nil, deal with it, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 2c5bda2 090/110: Update README, bump version number, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 6c8ae5b 098/110: Remove call to `define-error` for Emacs <24.4, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 29fd924 107/110: Move overlay face to a different overlay, ELPA Syncer, 2021/08/07