[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/macrostep fbd61eb 030/110: Tests for macrolet/cl-macrolet
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/macrostep fbd61eb 030/110: Tests for macrolet/cl-macrolet support |
Date: |
Sat, 7 Aug 2021 09:17:56 -0400 (EDT) |
branch: elpa/macrostep
commit fbd61eb5bf3f9b3dc336fd9bf920371746a4e4ac
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Tests for macrolet/cl-macrolet support
---
Makefile | 4 ++
macrostep-test.el | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 137 insertions(+)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0540b44
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+test:
+ emacs --batch --load macrostep-test.el
+
+.PHONY: test
diff --git a/macrostep-test.el b/macrostep-test.el
new file mode 100644
index 0000000..03cd923
--- /dev/null
+++ b/macrostep-test.el
@@ -0,0 +1,133 @@
+;;; macrostep-test.el --- tests for macrostep.el
+
+;; Copyright (C) 2014 Jon Oddie <j.j.oddie@gmail.com>
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see `http://www.gnu.org/licenses/'.
+
+
+(defmacro macrostep-with-text (object &rest forms)
+ (declare (indent 1))
+ `(with-temp-buffer
+ (emacs-lisp-mode)
+ (let ((print-level nil)
+ (print-length nil)
+ (standard-output (current-buffer)))
+ (save-excursion
+ (print ,object))
+ ,@forms)))
+
+(defmacro macrostep-should-expand (form expansion)
+ `(save-excursion
+ (goto-char (point-min))
+ (let ((print-level nil)
+ (print-length nil))
+ (search-forward (prin1-to-string ,form))
+ (goto-char (match-beginning 0))
+ (unwind-protect
+ (progn
+ (macrostep-expand)
+ (should
+ (equal (read (current-buffer))
+ ,expansion)))
+ (macrostep-collapse-all)))))
+
+(ert-deftest macrostep-expand-macrolet ()
+ (macrostep-with-text
+ '(macrolet
+ ((test (&rest args) `(expansion of ,@args)))
+ (first body form)
+ (second body form)
+ (test (strawberry pie) and (apple pie))
+ (final body form))
+ (macrostep-should-expand
+ '(test (strawberry pie) and (apple pie))
+ '(expansion of (strawberry pie) and (apple pie)))))
+
+(ert-deftest macrostep-expand-macrolet-2 ()
+ (macrostep-with-text
+ ;; Taken from org-notify.el.
+ '(macrolet ((get (k) `(plist-get list ,k))
+ (pr (k v) `(setq result (plist-put result ,k ,v))))
+ (let* ((list (nth 1 heading)) (notify (or (get :notify)
"default"))
+ (deadline (org-notify-convert-deadline (get :deadline)))
+ (heading (get :raw-value))
+ result)
+ (when (and (eq (get :todo-type) 'todo) heading deadline)
+ (pr :heading heading) (pr :notify (intern notify))
+ (pr :begin (get :begin))
+ (pr :file (nth org-notify-parse-file (org-agenda-files
'unrestricted)))
+ (pr :timestamp deadline) (pr :uid (md5 (concat heading deadline)))
+ (pr :deadline (- (org-time-string-to-seconds deadline)
+ (org-float-time))))
+ result))
+ (macrostep-should-expand
+ '(pr :heading heading)
+ '(setq result (plist-put result :heading heading)))
+ (macrostep-should-expand
+ '(pr :notify (intern notify))
+ '(setq result (plist-put result :notify (intern notify))))
+ (macrostep-should-expand
+ '(pr :begin (get :begin))
+ '(setq result (plist-put result :begin (get :begin))))
+ (macrostep-should-expand
+ '(get :begin)
+ '(plist-get list :begin))))
+
+(ert-deftest macrostep-expand-cl-macrolet ()
+ (macrostep-with-text
+ ;; Taken from slime.el.
+ '(cl-macrolet ((fontify (face string)
+ `(slime-inspector-fontify ,face ,string)))
+ (slime-propertize-region
+ (list 'slime-part-number id
+ 'mouse-face 'highlight
+ 'face 'slime-inspector-value-face)
+ (insert title))
+ (while (eq (char-before) ?\n)
+ (backward-delete-char 1))
+ (insert "\n" (fontify label "--------------------") "\n")
+ (save-excursion
+ (slime-inspector-insert-content content))
+ (when point
+ (cl-check-type point cons)
+ (ignore-errors
+ (goto-char (point-min))
+ (forward-line (1- (car point)))
+ (move-to-column (cdr point)))))
+ (macrostep-should-expand
+ '(fontify label "--------------------")
+ '(slime-inspector-fontify label "--------------------"))))
+
+(ert-deftest macrostep-expand-shadowed-macrolet ()
+ (macrostep-with-text
+ '(macrolet
+ ((test-macro (&rest forms) (cons 'shadowed forms))
+ (test-macro (&rest forms) (cons 'outer-definition forms)))
+ (test-macro first (call))
+ (cl-macrolet
+ ((test-macro (&rest forms) (cons 'inner-definition forms)))
+ (test-macro (second (call)))))
+ (macrostep-should-expand
+ '(test-macro first (call))
+ '(outer-definition first (call)))
+ (macrostep-should-expand
+ '(test-macro (second (call)))
+ '(inner-definition (second (call))))))
+
+(when noninteractive
+ (load-file (expand-file-name "macrostep.el"
+ (file-name-directory load-file-name)))
+ (ert-run-tests-batch "^macrostep"))
- [nongnu] elpa/macrostep 352b6d2 042/110: Minor improvements to SLIME prototype, (continued)
- [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, 2021/08/07
- [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 <=
- [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
- [nongnu] elpa/macrostep d459ded 024/110: bump version number, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 96e0c02 041/110: WIP: Add generic interface for other languages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e9a95f4 049/110: Fix `macrostep--macro-form-info`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e35b61d 047/110: Add compiler-macro support for SLIME, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 3766ffb 043/110: Hack to propertize macros in SLIME expansions, ELPA Syncer, 2021/08/07