[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode a927264 092/346: Allow tests to specify lisp code a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode a927264 092/346: Allow tests to specify lisp code and expected output. |
Date: |
Sun, 29 Aug 2021 11:00:09 -0400 (EDT) |
branch: elpa/d-mode
commit a9272644644ec339acd8b8c4e32b6ab4e10b85e2
Author: Dmitri Makarov <dmakarov@alumni.stanford.edu>
Commit: Dmitri Makarov <dmakarov@alumni.stanford.edu>
Allow tests to specify lisp code and expected output.
---
d-mode-test.el | 55 +++++++++++++++++++++++++------------------------------
tests/I0021.d | 7 ++++---
2 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/d-mode-test.el b/d-mode-test.el
index 65d8d05..14a41db 100644
--- a/d-mode-test.el
+++ b/d-mode-test.el
@@ -107,7 +107,7 @@
(c-add-style "teststyle" d-test-teststyle)
-(defun make-test-buffers (filename)
+(defun make-test-buffer (filename)
(let ((testbuf (get-buffer-create "*d-mode-test*"))
(enable-local-eval t))
;; setup the test file buffer.
@@ -121,12 +121,13 @@
(setq buffer-read-only t)
(goto-char (point-min))
(let ((c-default-style "TESTSTYLE")
- d-mode-hook c-mode-common-hook)
+ d-mode-hook
+ c-mode-common-hook)
(d-mode))
(hack-local-variables)
- (list testbuf)))
+ testbuf))
-(defun kill-test-buffers ()
+(defun kill-test-buffer ()
(let (buf)
(if (setq buf (get-buffer "*d-mode-test*"))
(kill-buffer buf))))
@@ -144,8 +145,7 @@
(font-lock-maximum-decoration t)
(font-lock-global-modes nil)
(enable-local-variables ':all)
- (buflist (make-test-buffers filename))
- (testbuf (car buflist))
+ (testbuf (make-test-buffer filename))
(pop-up-windows t)
(linenum 1)
error-found-p
@@ -153,28 +153,21 @@
c-echo-syntactic-information-p)
(switch-to-buffer testbuf)
- ;; Record the expected indentation and reindent. This is done
- ;; in backward direction to avoid cascading errors.
- (while (= (forward-line -1) 0)
- (back-to-indentation)
- (setq expectedindent (cons (current-column) expectedindent))
- (unless (eolp)
- ;; Do not reindent empty lines; the test cases might have
- ;; whitespace at eol trimmed away, so that could produce
- ;; false alarms.
- (let ((buffer-read-only nil))
- (if no-error
- (condition-case err (c-indent-line)
- (error
- (unless error-found-p
- (setq error-found-p t)
- (d-test-message
- "%s:%d: c-indent-line error: %s" filename
- (1+ (count-lines (point-min) (c-point 'bol)))
- (error-message-string err)))))
- (c-indent-line)))))
-
- (when (and error-found-p (not no-error))
+ (syntax-ppss (point-max))
+ ;; extract the run command and expected output if any.
+ (let* ((contents (buffer-substring-no-properties 1 (point-max)))
+ (run-str (if (string-match "^// #run: \\(.+\\)$" contents)
+ (match-string 1 contents)))
+ (out-str (if (string-match "^// #out: \\(.+\\)$" contents)
+ (match-string 1 contents))))
+ (if run-str
+ (let ((result (eval (car (read-from-string run-str)))))
+ (when out-str
+ (let ((expect (car (read-from-string out-str))))
+ (if (not (equal result expect))
+ (setq error-found-p t)))))))
+
+ (when error-found-p
(set-buffer testbuf)
(buffer-enable-undo testbuf)
(set-buffer-modified-p nil)
@@ -184,11 +177,13 @@
(set-buffer save-buf)
(goto-char save-point)
(when (and (not error-found-p) (interactive-p))
- (kill-test-buffers))
+ (kill-test-buffer))
(not error-found-p)))
;; Run the tests
(ert-deftest d-mode-basic ()
- (should (equal (do-one-test "tests/I0039.d") t)))
+ (should (equal (do-one-test "tests/I0021.d") t))
+ (should (equal (do-one-test "tests/I0039.d") t))
+ )
(provide 'd-mode-test)
diff --git a/tests/I0021.d b/tests/I0021.d
index 090bae6..7d4d92a 100644
--- a/tests/I0021.d
+++ b/tests/I0021.d
@@ -1,3 +1,4 @@
-// #run: (goto-char 74) (c-literal-limits)
-// #out: (72 . 77)
-auto x = `ab\`; // something else
+// #run: (let ((a (progn (goto-char 170) (c-literal-limits))) (b (progn
(goto-char 230) (c-literal-limits)))) (list a b))
+// #out: ((167 . 172) (227 . 232))
+auto x = `ab\`; // back-quoted string ends with a backslash
+auto y = "c\""; // double-quoted string ends with an escaped "
- [nongnu] elpa/d-mode 2cb1fe0 030/346: don't highlight []* in type face, (continued)
- [nongnu] elpa/d-mode 2cb1fe0 030/346: don't highlight []* in type face, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2f684db 037/346: Fix deadlock in imenu generator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 701c6be 044/346: use `cc-imenu-init' rather than `setq', ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode bac805f 050/346: Fix backslashes in backquotes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 86930c3 059/346: Rework a sentence of the README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 5691b70 069/346: Merge pull request #36 from dmakarov/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8a14ce4 080/346: Fix some compiler warnings., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 79940f2 085/346: Cleanup and fix test error reporting., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode fbd1f8b 089/346: Merge pull request #44 from snosov1/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e19d704 090/346: Closes #21., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a927264 092/346: Allow tests to specify lisp code and expected output.,
ELPA Syncer <=
- [nongnu] elpa/d-mode b4cbdfc 094/346: Workaround issue #50., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3e80976 097/346: recognize deprecation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 6323cd4 098/346: Recognize postfix @-keywords in function declarations for imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 600c70b 108/346: Merge pull request #65 from CyberShadow/pull-20160329-054927, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3e73378 112/346: Update the badges/shields in the README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a99d127 054/346: Fix keywords list construction to include doc-comment keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f487a71 058/346: Add the function to support alignment of multi-line fluent API using expressions., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 05cd7b9 038/346: Fix classes with inherit lists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 27e7c62 041/346: Merge pull request #14 from finalpatch/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 011d0cf 043/346: Merge pull request #17 from nordlow/master, ELPA Syncer, 2021/08/29