[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/forth-mode 66f7a2dc97 060/153: Add tests for various Forth
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/forth-mode 66f7a2dc97 060/153: Add tests for various Forth block and non-block files. |
Date: |
Sat, 29 Jan 2022 08:02:16 -0500 (EST) |
branch: elpa/forth-mode
commit 66f7a2dc9736ec28745a963c64a5aa54550bc89c
Author: Lars Brinkhoff <lars.brinkhoff@delphi.com>
Commit: Lars Brinkhoff <lars.brinkhoff@delphi.com>
Add tests for various Forth block and non-block files.
---
build.el | 14 ++++----------
forth-block-mode.el | 4 ++++
forth-mode.el | 20 +++++++++++++++++---
test/block1.fth | 1 +
test/block2.fth | 32 ++++++++++++++++++++++++++++++++
test/noblock.fth | 1 +
test/tests.el | 23 +++++++++++++++++++++++
7 files changed, 82 insertions(+), 13 deletions(-)
diff --git a/build.el b/build.el
index f0c599d040..6172088e19 100644
--- a/build.el
+++ b/build.el
@@ -3,7 +3,7 @@
(let ((generated-autoload-file (concat default-directory "autoloads.el")))
(update-directory-autoloads "."))
(load-file "autoloads.el")
-(add-to-list 'load-path ".")
+(add-to-list 'load-path default-directory)
(if (locate-library "ert")
(require 'ert)
@@ -18,13 +18,7 @@
"Compile package."
(should-not (string-match "failed" (byte-recompile-directory "." 0))))
-(ert-deftest load-forth-mode ()
- "Load forth-mode."
- (should (require 'forth-mode))
- (should (featurep 'forth-mode))
- (with-temp-buffer
- (forth-mode)
- (should (eq major-mode 'forth-mode))
- (kill-buffer)))
+(load-file "test/tests.el")
-(ert-run-tests-batch-and-exit)
+;;; Ensure compile-package is run first.
+(ert-run-tests-batch-and-exit '(or compile-package t))
diff --git a/forth-block-mode.el b/forth-block-mode.el
index 84be683e35..5d577fdcfb 100644
--- a/forth-block-mode.el
+++ b/forth-block-mode.el
@@ -1,6 +1,8 @@
(require 'cl)
(require 'forth-mode)
+(defvar forth-block-with-newlines)
+
(defun forth-line (n)
(goto-char (point-min))
(forward-line (1- n)))
@@ -80,6 +82,8 @@
(define-minor-mode forth-block-mode
"Minor mode for Forth code in blocks."
:lighter " block"
+ (make-local-variable 'forth-block-with-newlines)
+ (setq forth-block-with-newlines (forth-block-with-newlines-p))
(setq require-final-newline nil)
(forth-unblockify)
(add-hook 'before-save-hook 'forth-blockify nil t)
diff --git a/forth-mode.el b/forth-mode.el
index f298a84269..cd706954ac 100644
--- a/forth-mode.el
+++ b/forth-mode.el
@@ -79,13 +79,27 @@
(push (car def) list)))))
(list (forth-symbol-start) (forth-symbol-end) list)))
+(defun forth-block-with-newlines-p ()
+ (save-excursion
+ (forth-beginning)
+ (let ((result t))
+ (dotimes (i 16)
+ (goto-char (* 64 (1+ i)))
+ (unless (looking-at "\n")
+ (setq result nil)))
+ result)))
+
+(defun forth-block-without-newlines-p ()
+ (save-excursion
+ (forth-beginning)
+ (not (search-forward "\n" 1024 t))))
+
(defun forth-block-p ()
"Guess whether the current buffer is a Forth block file."
(and (> (point-max) 1)
(eq (logand (point-max) 1023) 1)
- (save-excursion
- (forth-beginning)
- (not (search-forward "\n" 1024 t)))))
+ (or (forth-block-with-newlines-p)
+ (forth-block-without-newlines-p))))
(unless (fboundp 'prog-mode)
(defalias 'prog-mode 'fundamental-mode))
diff --git a/test/block1.fth b/test/block1.fth
new file mode 100644
index 0000000000..2a09adf2fe
--- /dev/null
+++ b/test/block1.fth
@@ -0,0 +1 @@
+
[...]
\ No newline at end of file
diff --git a/test/block2.fth b/test/block2.fth
new file mode 100644
index 0000000000..e9fae59544
--- /dev/null
+++ b/test/block2.fth
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/noblock.fth b/test/noblock.fth
new file mode 100644
index 0000000000..f08b6c74c3
--- /dev/null
+++ b/test/noblock.fth
@@ -0,0 +1 @@
+: foo ;
diff --git a/test/tests.el b/test/tests.el
new file mode 100644
index 0000000000..840230d608
--- /dev/null
+++ b/test/tests.el
@@ -0,0 +1,23 @@
+(ert-deftest load-forth-mode ()
+ "Load forth-mode."
+ (should (require 'forth-mode))
+ (should (featurep 'forth-mode))
+ (with-temp-buffer
+ (forth-mode)
+ (should (eq major-mode 'forth-mode))
+ (kill-buffer)))
+
+(ert-deftest load-not-block ()
+ (find-file "test/noblock.fth")
+ (should (eq major-mode 'forth-mode))
+ (should-not (and (boundp 'forth-block-mode) forth-block-mode)))
+
+(ert-deftest load-block-with-newlines ()
+ (find-file "test/block2.fth")
+ (should (eq major-mode 'forth-mode))
+ (should (and (boundp 'forth-block-mode) forth-block-mode)))
+
+(ert-deftest load-block-without-newlines ()
+ (find-file "test/block1.fth")
+ (should (eq major-mode 'forth-mode))
+ (should (and (boundp 'forth-block-mode) forth-block-mode)))
- [nongnu] elpa/forth-mode 38f0ccbfc8 027/153: Rename to run-forth, forth-ensure, and forth-parse.el., (continued)
- [nongnu] elpa/forth-mode 38f0ccbfc8 027/153: Rename to run-forth, forth-ensure, and forth-parse.el., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode ccb14b4a47 136/153: Indentation rule for :noname, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode d711fd5200 130/153: Remove tabs in wercker.yml, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode dd450e6a01 120/153: Remove debugging code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode b3c1e62e5a 151/153: The Emacs 25 package can't coexist with Emacs-snapshot., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 157c14b18e 092/153: Include tab (\t) as whitespace delimiter for comments., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 93c90ebf97 129/153: Install gforth in wercker, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode eaeac02b6d 082/153: Disable warning about cl., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 3ef42c825a 101/153: Emacs 23: indenting doesn't work well., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 9440f2a5af 121/153: Add test for comment-dwim, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 66f7a2dc97 060/153: Add tests for various Forth block and non-block files.,
ELPA Syncer <=
- [nongnu] elpa/forth-mode 3fa933d556 123/153: Test comment-region, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 17e58ab993 102/153: Test with Emacs snapshot., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 885407ebc5 047/153: Automated build., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 9f9b5cdf86 089/153: Don't send output as input, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 2e65a80a3b 110/153: Fontify buffer before testing word movement commands., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode f44fa6481f 152/153: Forth 200x core.html is no longer there., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5502816e37 134/153: Make it easier to emulate Open Firmware indentation style, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5076a08abc 057/153: Make C-c C-k work in all Forth modes., ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 7cbb60f1d7 143/153: Highlight +field and friends, ELPA Syncer, 2022/01/29
- [nongnu] elpa/forth-mode 5c1c928490 132/153: Make completion case insensitive, ELPA Syncer, 2022/01/29