unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23139: [PATCH] test/automated/abbrev-tests.el
@ 2016-03-29  4:04 Lee B
  2016-04-24 15:01 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Lee B @ 2016-03-29  4:04 UTC (permalink / raw)
  To: 23139

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

Hello,

Attached is a patch for the emacs-25 branch
test/automated/abbrev-tests.el. It comprises a couple of tests copied
from the master branch, minor modifications and a bunch of new tests.

In the abbrev-table-p-test, I've commented out a check that works in
master but not in emacs-25 (and vice-versa) - pointers on how to fix
this would be greatly appreciated. Any other hints and advice also
welcome :-)

Thanks,

Lee.

[-- Attachment #2: abbrev-tests.el patch --]
[-- Type: text/plain, Size: 10131 bytes --]

From 1cab871c6bcc77906d76f93bd361a0f4fefa849e Mon Sep 17 00:00:00 2001
From: Lee Bochicchio <lboc.home@gmail.com>
Date: Sat, 26 Mar 2016 05:28:18 +0900
Subject: [PATCH] abbrev-tests copy tests from master, modify test, add tests

* test/automated/abbrev-tests.el (abbrev-table-p-test)
(abbrev-make-abbrev-table-test, abbrev-table-get-put-test)
(abbrev-table-empty-p-test): Copy from master.
(clear-abbrev-table-test): Use 'abbrev-expansion'.
(list-abbrevs-test, prepare-abbrev-list-buffer-test, insert-abbrevs-test)
(edit-abbrevs-test, define-abbrevs-test, read-write-abbrev-file-test)
(abbrev-edit-save-to-file-test): New tests.
---
 test/automated/abbrev-tests.el | 184 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 172 insertions(+), 12 deletions(-)

diff --git a/test/automated/abbrev-tests.el b/test/automated/abbrev-tests.el
index 66413c5..dbd1804 100644
--- a/test/automated/abbrev-tests.el
+++ b/test/automated/abbrev-tests.el
@@ -1,6 +1,6 @@
-;;; abbrev-tests.el --- Test suite for abbrevs.
+;;; abbrev-tests.el --- Test suite for abbrevs  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2016 Free Software Foundation, Inc.
+;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii <eliz@gnu.org>
 ;; Keywords: abbrevs
@@ -29,6 +29,7 @@
 
 (require 'ert)
 (require 'abbrev)
+(require 'obarray)
 (require 'seq)
 
 ;; set up test abbrev table and abbrev entry
@@ -38,6 +39,38 @@ setup-test-abbrev-table
   (abbrev-table-put ert-test-abbrevs :ert-test "ert-test-value")
   ert-test-abbrevs)
 
+(ert-deftest abbrev-table-p-test ()
+  (should-not (abbrev-table-p 42))
+  (should-not (abbrev-table-p "aoeu"))
+  (should-not (abbrev-table-p '()))
+  ;; master
+  ;;(should-not (abbrev-table-p []))
+  (should-error (abbrev-table-p []))
+  ;; Missing :abbrev-table-modiff counter:
+  (should-not (abbrev-table-p (obarray-make)))
+  (let* ((table (obarray-make)))
+    (abbrev-table-put table :abbrev-table-modiff 42)
+    (should (abbrev-table-p table))))
+
+(ert-deftest abbrev-make-abbrev-table-test ()
+  ;; Table without properties:
+  (let ((table (make-abbrev-table)))
+    (should (abbrev-table-p table))
+    (should (= (length table) obarray-default-size)))
+  ;; Table with one property 'foo with value 'bar:
+  (let ((table (make-abbrev-table '(foo bar))))
+    (should (abbrev-table-p table))
+    (should (= (length table) obarray-default-size))
+    (should (eq (abbrev-table-get table 'foo) 'bar))))
+
+(ert-deftest abbrev-table-get-put-test ()
+  (let ((table (make-abbrev-table)))
+    (should-not (abbrev-table-get table 'foo))
+    (should (= (abbrev-table-put table 'foo 42) 42))
+    (should (= (abbrev-table-get table 'foo) 42))
+    (should (eq (abbrev-table-put table 'foo 'bar) 'bar))
+    (should (eq (abbrev-table-get table 'foo) 'bar))))
+
 (ert-deftest copy-abbrev-table-test ()
   (defvar foo-abbrev-table nil)         ; Avoid compiler warning
   (define-abbrev-table 'foo-abbrev-table
@@ -51,6 +84,17 @@ setup-test-abbrev-table
     (should (abbrev-table-p new-foo-abbrev-table)))
   (should-not (string-equal (buffer-name) "*Backtrace*")))
 
+(ert-deftest abbrev-table-empty-p-test ()
+  (should-error (abbrev-table-empty-p 42))
+  (should-error (abbrev-table-empty-p "aoeu"))
+  (should-error (abbrev-table-empty-p '()))
+  (should-error (abbrev-table-empty-p []))
+  ;; Missing :abbrev-table-modiff counter:
+  (should-error (abbrev-table-empty-p (obarray-make)))
+  (let* ((table (obarray-make)))
+    (abbrev-table-put table :abbrev-table-modiff 42)
+    (should (abbrev-table-empty-p table))))
+
 (ert-deftest kill-all-abbrevs-test ()
   "Test undefining all defined abbrevs"
   (unless noninteractive
@@ -80,19 +124,135 @@ setup-test-abbrev-table
 (ert-deftest clear-abbrev-table-test ()
   "Test clearing single abbrev table"
   (let ((ert-test-abbrevs (setup-test-abbrev-table)))
-    (should (equal "a-e-t" (symbol-name
-                            (abbrev-symbol "a-e-t" ert-test-abbrevs))))
-    (should (equal "abbrev-ert-test" (symbol-value
-                                      (abbrev-symbol "a-e-t" ert-test-abbrevs))))
+    (should (equal "abbrev-ert-test" (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+    (clear-abbrev-table ert-test-abbrevs)
+    (should (equal nil (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+    (should (equal t (abbrev-table-empty-p ert-test-abbrevs)))))
+
+(ert-deftest list-abbrevs-test ()
+  "Test generation of abbrev list buffer"
+  ;; Somewhat redundant as prepare-abbrev-list-buffer is also tested.
+  ;; all abbrevs
+  (let ((abbrev-buffer (prepare-abbrev-list-buffer)))
+    (should (equal "*Abbrevs*" (buffer-name abbrev-buffer)))
+    (kill-buffer abbrev-buffer))
+  ;; mode-specific abbrevs
+  (let ((abbrev-buffer (prepare-abbrev-list-buffer t)))
+    (should (equal "*Abbrevs*" (buffer-name abbrev-buffer)))
+    (kill-buffer abbrev-buffer)))
+
+(ert-deftest prepare-abbrev-list-buffer-test ()
+  "Test generation of abbrev list buffer"
+  ;; all abbrevs
+  (let ((ert-test-abbrevs (setup-test-abbrev-table)))
+    (with-current-buffer (prepare-abbrev-list-buffer)
+      ;; Check for a couple of abbrev-table names in buffer.
+      (should (and (progn
+                     (goto-char (point-min))
+                     (search-forward (symbol-name (abbrev-table-name ert-test-abbrevs))))
+                   (progn
+                     (goto-char (point-min))
+                     (search-forward "global-abbrev-table"))))
+      (should (equal 'edit-abbrevs-mode major-mode))
+      (kill-buffer "*Abbrevs*")))
+
+  ;; mode-specific abbrevs (temp buffer uses fundamental-mode)
+  (with-temp-buffer
+    (prepare-abbrev-list-buffer t)
+    (with-current-buffer "*Abbrevs*"
+      (should (progn
+                (goto-char (point-min))
+                (search-forward "fundamental-mode-abbrev-table")))
+      (should-error (progn
+                      (goto-char (point-min))
+                      (search-forward "global-abbrev-table")))
+      (should-not (equal 'edit-abbrevs-mode major-mode))
+      (kill-buffer "*Abbrevs*"))))
+
+(ert-deftest insert-abbrevs-test ()
+  "Test inserting abbrev definitions into buffer"
+  (with-temp-buffer
+    (insert-abbrevs)
+      (should (progn
+                (goto-char (point-min))
+                (search-forward "global-abbrev-table")))))
+
+(ert-deftest edit-abbrevs-test ()
+  "Test editing abbrevs from buffer"
+  (defvar ert-edit-abbrevs-test-table nil)
+  (let ((ert-test-abbrevs (setup-test-abbrev-table)))
+    (with-temp-buffer
+      ;; insert test table and new abbrev, redefine, check definition
+      (goto-char (point-min))
+      (insert "(ert-edit-abbrevs-test-table)\n")
+      (insert "\n" "\"e-a-t\"\t" "0\t" "\"edit-abbrevs-test\"\n")
+      ;; check test table before redefine
+      (should (equal "abbrev-ert-test"
+                     (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+      (edit-abbrevs-redefine)
+      (should-not (abbrev-expansion "a-e-t" ert-test-abbrevs))
+      (should (equal "edit-abbrevs-test"
+                     (abbrev-expansion "e-a-t" ert-edit-abbrevs-test-table))))))
+
+(ert-deftest define-abbrevs-test ()
+  "Test defining abbrevs from buffer"
+  (defvar ert-bad-abbrev-table nil)
+  (defvar ert-good-abbrev-table nil)
+  (defvar ert-redefine-abbrev-table nil)
+  (with-temp-buffer
+    ;; insert bad abbrev data and attempt define
+    (goto-char (point-min))
+    (insert "ert-bad-abbrev-table\n")
+    (insert "\n" "\"b-a-t\"\t" "0\t" "\n")
+    (should-not (define-abbrevs))
+    (should (equal nil (abbrev-expansion "b-a-t" ert-bad-abbrev-table)))
+    (delete-region (point-min) (point-max))
+    ;; try with valid abbrev data
+    (goto-char (point-min))
+    (insert "(ert-good-abbrev-table)\n")
+    (insert "\n" "\"g-a-t\"\t" "0\t" "\"good-abbrev-table\"\n")
+    (define-abbrevs)
+    (should (equal "good-abbrev-table"
+                   (abbrev-expansion "g-a-t" ert-good-abbrev-table)))
+    ;; redefine from buffer
+    (delete-region (point-min) (point-max))
+    (insert "(ert-redefine-abbrev-table)\n")
+    (insert "\n" "\"r-a-t\"\t" "0\t" "\"redefine-abbrev-table\"\n")
+    ;; arg = kill-all-abbrevs
+    (define-abbrevs t)
+    (should (equal "redefine-abbrev-table"
+                   (abbrev-expansion "r-a-t" ert-redefine-abbrev-table)))
+    (should (equal nil (abbrev-expansion "g-a-t" ert-good-abbrev-table)))))
 
+(ert-deftest read-write-abbrev-file-test ()
+  "Test reading and writing abbrevs from file"
+  (let ((temp-test-file (make-temp-file "ert-abbrev-test"))
+        (ert-test-abbrevs (setup-test-abbrev-table)))
+    (write-abbrev-file temp-test-file)
     (clear-abbrev-table ert-test-abbrevs)
+    (should (abbrev-table-empty-p ert-test-abbrevs))
+    (read-abbrev-file temp-test-file)
+    (should (equal "abbrev-ert-test" (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+    (delete-file temp-test-file)))
 
-    (should (equal "nil" (symbol-name
-                          (abbrev-symbol "a-e-t" ert-test-abbrevs))))
-    (should (equal nil (symbol-value
-                        (abbrev-symbol "a-e-t" ert-test-abbrevs))))
-    (should (equal t (abbrev-table-empty-p ert-test-abbrevs)))))
+(ert-deftest abbrev-edit-save-to-file-test ()
+  "Test saving abbrev definitions in buffer to file"
+  (defvar ert-save-test-table nil)
+  (let ((temp-test-file (make-temp-file "ert-abbrev-test"))
+        (ert-test-abbrevs (setup-test-abbrev-table)))
+    (with-temp-buffer
+      (goto-char (point-min))
+      (insert "(ert-save-test-table)\n")
+      (insert "\n" "\"s-a-t\"\t" "0\t" "\"save-abbrevs-test\"\n")
+      (should (equal "abbrev-ert-test"
+                     (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+      ;; clears abbrev tables
+      (abbrev-edit-save-to-file temp-test-file)
+      (should-not (abbrev-expansion "a-e-t" ert-test-abbrevs))
+      (read-abbrev-file temp-test-file)
+      (should (equal "save-abbrevs-test"
+                     (abbrev-expansion "s-a-t" ert-save-test-table)))
+      (delete-file temp-test-file))))
 
 (provide 'abbrev-tests)
-
 ;;; abbrev-tests.el ends here
-- 
2.7.2.333.g70bd996


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#23139: [PATCH] test/automated/abbrev-tests.el
  2016-03-29  4:04 bug#23139: [PATCH] test/automated/abbrev-tests.el Lee B
@ 2016-04-24 15:01 ` Lars Magne Ingebrigtsen
  2016-04-25  0:50   ` Lee B
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2016-04-24 15:01 UTC (permalink / raw)
  To: Lee B; +Cc: 23139

Lee B <lboc.home@gmail.com> writes:

> Attached is a patch for the emacs-25 branch
> test/automated/abbrev-tests.el. It comprises a couple of tests copied
> from the master branch, minor modifications and a bunch of new tests.

Wouldn't it make more sense to just add these new tests to the master
branch?  Adding new tests to the emacs-25 branch at this point
(especially when they are incompatible with master) doesn't seem all
that vital...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23139: [PATCH] test/automated/abbrev-tests.el
  2016-04-24 15:01 ` Lars Magne Ingebrigtsen
@ 2016-04-25  0:50   ` Lee B
  2016-04-25 23:09     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Lee B @ 2016-04-25  0:50 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 23139


On Sun, Apr 24 2016, Lars Magne Ingebrigtsen wrote:

> Lee B <lboc.home@gmail.com> writes:
>
>> Attached is a patch for the emacs-25 branch
>> test/automated/abbrev-tests.el. It comprises a couple of tests copied
>> from the master branch, minor modifications and a bunch of new tests.
>
> Wouldn't it make more sense to just add these new tests to the master
> branch?  Adding new tests to the emacs-25 branch at this point
> (especially when they are incompatible with master) doesn't seem all
> that vital...

Sure, if you think that's the better way. I only patched against
emacs-25 as that's where I'd had some previous patches to this file
applied.

Shall I generate a patch against master and update this bug?

Lee.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23139: [PATCH] test/automated/abbrev-tests.el
  2016-04-25  0:50   ` Lee B
@ 2016-04-25 23:09     ` Lars Magne Ingebrigtsen
  2016-04-26  5:51       ` Lee B
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2016-04-25 23:09 UTC (permalink / raw)
  To: Lee B; +Cc: 23139

Lee B <lboc.home@gmail.com> writes:

> Sure, if you think that's the better way. I only patched against
> emacs-25 as that's where I'd had some previous patches to this file
> applied.
>
> Shall I generate a patch against master and update this bug?

Yes, please do.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#23139: [PATCH] test/automated/abbrev-tests.el
  2016-04-25 23:09     ` Lars Magne Ingebrigtsen
@ 2016-04-26  5:51       ` Lee B
  2016-05-02 22:13         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Lee B @ 2016-04-26  5:51 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 23139

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]


On 月,  4 25 2016, Lars Magne Ingebrigtsen wrote:

> Lee B <lboc.home@gmail.com> writes:
>
>> Sure, if you think that's the better way. I only patched against
>> emacs-25 as that's where I'd had some previous patches to this file
>> applied.
>>
>> Shall I generate a patch against master and update this bug?
>
> Yes, please do.

OK, patch against master attached. Contrary to the bug title, the file
is now test/lisp/abbrev-tests.el of course.

Lee.


[-- Attachment #2: abbrev-tests patch for master --]
[-- Type: text/plain, Size: 7945 bytes --]

From 60f8b69fe83f9b80d6d4d236e4a3f8b3ccada176 Mon Sep 17 00:00:00 2001
From: Lee Bochicchio <lboc.home@gmail.com>
Date: Tue, 26 Apr 2016 14:31:14 +0900
Subject: [PATCH] Modify/add abbrev tests

* test/lisp/abbrev-tests.el
(clear-abbrev-table-test): use `abbrev-expansion'
(abbrev-table-empty-p-test, list-abbrevs-test)
(prepare-abbrev-list-buffer-test, insert-abbrevs-test)
(edit-abbrevs-test, define-abbrevs-test)
(read-write-abbrev-file-test)
(abbrev-edit-save-to-file-test): new tests
---
 test/lisp/abbrev-tests.el | 147 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 138 insertions(+), 9 deletions(-)

diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el
index 0d93e26..3c34521 100644
--- a/test/lisp/abbrev-tests.el
+++ b/test/lisp/abbrev-tests.el
@@ -81,6 +81,17 @@ setup-test-abbrev-table
     (should (abbrev-table-p new-foo-abbrev-table)))
   (should-not (string-equal (buffer-name) "*Backtrace*")))
 
+(ert-deftest abbrev-table-empty-p-test ()
+  (should-error (abbrev-table-empty-p 42))
+  (should-error (abbrev-table-empty-p "aoeu"))
+  (should-error (abbrev-table-empty-p '()))
+  (should-error (abbrev-table-empty-p []))
+  ;; Missing :abbrev-table-modiff counter:
+  (should-error (abbrev-table-empty-p (obarray-make)))
+  (let* ((table (obarray-make)))
+    (abbrev-table-put table :abbrev-table-modiff 42)
+    (should (abbrev-table-empty-p table))))
+
 (ert-deftest kill-all-abbrevs-test ()
   "Test undefining all defined abbrevs"
   (unless noninteractive
@@ -110,18 +121,136 @@ setup-test-abbrev-table
 (ert-deftest clear-abbrev-table-test ()
   "Test clearing single abbrev table"
   (let ((ert-test-abbrevs (setup-test-abbrev-table)))
-    (should (equal "a-e-t" (symbol-name
-                            (abbrev-symbol "a-e-t" ert-test-abbrevs))))
-    (should (equal "abbrev-ert-test" (symbol-value
-                                      (abbrev-symbol "a-e-t" ert-test-abbrevs))))
+    (should (equal "abbrev-ert-test" (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+    (clear-abbrev-table ert-test-abbrevs)
+    (should (equal nil (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+    (should (equal t (abbrev-table-empty-p ert-test-abbrevs)))))
+
+(ert-deftest list-abbrevs-test ()
+  "Test generation of abbrev list buffer"
+  ;; Somewhat redundant as prepare-abbrev-list-buffer is also tested.
+  ;; all abbrevs
+  (let ((abbrev-buffer (prepare-abbrev-list-buffer)))
+    (should (equal "*Abbrevs*" (buffer-name abbrev-buffer)))
+    (kill-buffer abbrev-buffer))
+  ;; mode-specific abbrevs
+  (let ((abbrev-buffer (prepare-abbrev-list-buffer t)))
+    (should (equal "*Abbrevs*" (buffer-name abbrev-buffer)))
+    (kill-buffer abbrev-buffer)))
+
+(ert-deftest prepare-abbrev-list-buffer-test ()
+  "Test generation of abbrev list buffer"
+  ;; all abbrevs
+  (let ((ert-test-abbrevs (setup-test-abbrev-table)))
+    (with-current-buffer (prepare-abbrev-list-buffer)
+      ;; Check for a couple of abbrev-table names in buffer.
+      (should (and (progn
+                     (goto-char (point-min))
+                     (search-forward (symbol-name (abbrev-table-name ert-test-abbrevs))))
+                   (progn
+                     (goto-char (point-min))
+                     (search-forward "global-abbrev-table"))))
+      (should (equal 'edit-abbrevs-mode major-mode))
+      (kill-buffer "*Abbrevs*")))
+
+  ;; mode-specific abbrevs (temp buffer uses fundamental-mode)
+  (with-temp-buffer
+    (prepare-abbrev-list-buffer t)
+    (with-current-buffer "*Abbrevs*"
+      (should (progn
+                (goto-char (point-min))
+                (search-forward "fundamental-mode-abbrev-table")))
+      (should-error (progn
+                      (goto-char (point-min))
+                      (search-forward "global-abbrev-table")))
+      (should-not (equal 'edit-abbrevs-mode major-mode))
+      (kill-buffer "*Abbrevs*"))))
+
+(ert-deftest insert-abbrevs-test ()
+  "Test inserting abbrev definitions into buffer"
+  (with-temp-buffer
+    (insert-abbrevs)
+      (should (progn
+                (goto-char (point-min))
+                (search-forward "global-abbrev-table")))))
+
+(ert-deftest edit-abbrevs-test ()
+  "Test editing abbrevs from buffer"
+  (defvar ert-edit-abbrevs-test-table nil)
+  (let ((ert-test-abbrevs (setup-test-abbrev-table)))
+    (with-temp-buffer
+      ;; insert test table and new abbrev, redefine, check definition
+      (goto-char (point-min))
+      (insert "(ert-edit-abbrevs-test-table)\n")
+      (insert "\n" "\"e-a-t\"\t" "0\t" "\"edit-abbrevs-test\"\n")
+      ;; check test table before redefine
+      (should (equal "abbrev-ert-test"
+                     (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+      (edit-abbrevs-redefine)
+      (should-not (abbrev-expansion "a-e-t" ert-test-abbrevs))
+      (should (equal "edit-abbrevs-test"
+                     (abbrev-expansion "e-a-t" ert-edit-abbrevs-test-table))))))
+
+(ert-deftest define-abbrevs-test ()
+  "Test defining abbrevs from buffer"
+  (defvar ert-bad-abbrev-table nil)
+  (defvar ert-good-abbrev-table nil)
+  (defvar ert-redefine-abbrev-table nil)
+  (with-temp-buffer
+    ;; insert bad abbrev data and attempt define
+    (goto-char (point-min))
+    (insert "ert-bad-abbrev-table\n")
+    (insert "\n" "\"b-a-t\"\t" "0\t" "\n")
+    (should-not (define-abbrevs))
+    (should (equal nil (abbrev-expansion "b-a-t" ert-bad-abbrev-table)))
+    (delete-region (point-min) (point-max))
+    ;; try with valid abbrev data
+    (goto-char (point-min))
+    (insert "(ert-good-abbrev-table)\n")
+    (insert "\n" "\"g-a-t\"\t" "0\t" "\"good-abbrev-table\"\n")
+    (define-abbrevs)
+    (should (equal "good-abbrev-table"
+                   (abbrev-expansion "g-a-t" ert-good-abbrev-table)))
+    ;; redefine from buffer
+    (delete-region (point-min) (point-max))
+    (insert "(ert-redefine-abbrev-table)\n")
+    (insert "\n" "\"r-a-t\"\t" "0\t" "\"redefine-abbrev-table\"\n")
+    ;; arg = kill-all-abbrevs
+    (define-abbrevs t)
+    (should (equal "redefine-abbrev-table"
+                   (abbrev-expansion "r-a-t" ert-redefine-abbrev-table)))
+    (should (equal nil (abbrev-expansion "g-a-t" ert-good-abbrev-table)))))
 
+(ert-deftest read-write-abbrev-file-test ()
+  "Test reading and writing abbrevs from file"
+  (let ((temp-test-file (make-temp-file "ert-abbrev-test"))
+        (ert-test-abbrevs (setup-test-abbrev-table)))
+    (write-abbrev-file temp-test-file)
     (clear-abbrev-table ert-test-abbrevs)
+    (should (abbrev-table-empty-p ert-test-abbrevs))
+    (read-abbrev-file temp-test-file)
+    (should (equal "abbrev-ert-test" (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+    (delete-file temp-test-file)))
 
-    (should (equal "nil" (symbol-name
-                          (abbrev-symbol "a-e-t" ert-test-abbrevs))))
-    (should (equal nil (symbol-value
-                        (abbrev-symbol "a-e-t" ert-test-abbrevs))))
-    (should (equal t (abbrev-table-empty-p ert-test-abbrevs)))))
+(ert-deftest abbrev-edit-save-to-file-test ()
+  "Test saving abbrev definitions in buffer to file"
+  (defvar ert-save-test-table nil)
+  (let ((temp-test-file (make-temp-file "ert-abbrev-test"))
+        (ert-test-abbrevs (setup-test-abbrev-table)))
+    (with-temp-buffer
+      (goto-char (point-min))
+      (insert "(ert-save-test-table)\n")
+      (insert "\n" "\"s-a-t\"\t" "0\t" "\"save-abbrevs-test\"\n")
+      (should (equal "abbrev-ert-test"
+                     (abbrev-expansion "a-e-t" ert-test-abbrevs)))
+      ;; clears abbrev tables
+      (abbrev-edit-save-to-file temp-test-file)
+      (should-not (abbrev-expansion "a-e-t" ert-test-abbrevs))
+      (read-abbrev-file temp-test-file)
+      (should (equal "save-abbrevs-test"
+                     (abbrev-expansion "s-a-t" ert-save-test-table)))
+      (delete-file temp-test-file))))
 
 (provide 'abbrev-tests)
+
 ;;; abbrev-tests.el ends here
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#23139: [PATCH] test/automated/abbrev-tests.el
  2016-04-26  5:51       ` Lee B
@ 2016-05-02 22:13         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2016-05-02 22:13 UTC (permalink / raw)
  To: Lee B; +Cc: 23139

Lee B <lboc.home@gmail.com> writes:

> OK, patch against master attached. Contrary to the bug title, the file
> is now test/lisp/abbrev-tests.el of course.

Thanks; applied to the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-02 22:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-29  4:04 bug#23139: [PATCH] test/automated/abbrev-tests.el Lee B
2016-04-24 15:01 ` Lars Magne Ingebrigtsen
2016-04-25  0:50   ` Lee B
2016-04-25 23:09     ` Lars Magne Ingebrigtsen
2016-04-26  5:51       ` Lee B
2016-05-02 22:13         ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).