emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/toc-org b4dbeb936c 024/128: simply require ert


From: ELPA Syncer
Subject: [nongnu] elpa/toc-org b4dbeb936c 024/128: simply require ert
Date: Sun, 2 Jan 2022 09:59:07 -0500 (EST)

branch: elpa/toc-org
commit b4dbeb936c0c1503095492fb62ea9f4fcf1030c1
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: Sergei Nosov <sergei.nosov@gmail.com>

    simply require ert
---
 org-toc.el | 120 +++++++++++++++++++++++++++++--------------------------------
 1 file changed, 57 insertions(+), 63 deletions(-)

diff --git a/org-toc.el b/org-toc.el
index 101112a122..5ad797a057 100644
--- a/org-toc.el
+++ b/org-toc.el
@@ -42,6 +42,8 @@
 
 ;;; Code:
 
+(require 'ert)
+
 (defgroup org-toc nil
   "org-toc is a utility to have an up-to-date table of contents
 in the org files without exporting (useful primarily for readme
@@ -95,37 +97,35 @@ tags."
       (buffer-substring-no-properties
        (point-min) (point-max)))))
 
-(eval-after-load "ert-autoloads"
-  (when (require 'ert nil t)
-    (ert-deftest org-toc-test-raw-toc ()
-      "Test the `org-toc-raw-toc' function"
-
-      (defun org-toc-test-raw-toc-gold-test (content gold)
-        (should (equal
-                 (with-temp-buffer
-                   (insert content)
-                   (org-toc-raw-toc))
-                 gold)))
-
-      (let ((beg "* About\n:TOC:\n drawer\n:END:\n\norg-toc is a utility to 
have an up-to-date table of contents in the\norg files without exporting 
(useful primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n\n* Table of Contents                   
                                  ")
-            (gold "* About\n"))
-
-        ;; different TOC styles
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC:"         ) gold)
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC_1:"       ) gold)
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC_1_qqq:"   ) gold)
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1:"       ) gold)
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1@cxv:"   ) gold)
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" ) gold)
-
-        ;; trailing symbols
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\n") 
gold)
-        (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" 
"\n\n\nsdfd") gold))
-
-      ;; more complex case
-      (org-toc-test-raw-toc-gold-test
-       "* About\n:TOC:\n drawer\n:END:\n\norg-toc is a utility to have an 
up-to-date table of contents in the\norg files without exporting (useful 
primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n\n* Table of Contents                   
                                  :TOC:\n - [[#about][About]]\n - 
[[#use][Use]]\n - [[#different-href-styles][Different hre [...]
-       "* About\n* Installation\n** via package.el\n** Manual\n* Use\n* 
Different href styles\n* Example\n"))))
+(ert-deftest org-toc-test-raw-toc ()
+  "Test the `org-toc-raw-toc' function"
+
+  (defun org-toc-test-raw-toc-gold-test (content gold)
+    (should (equal
+             (with-temp-buffer
+               (insert content)
+               (org-toc-raw-toc))
+             gold)))
+
+  (let ((beg "* About\n:TOC:\n drawer\n:END:\n\norg-toc is a utility to have 
an up-to-date table of contents in the\norg files without exporting (useful 
primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n\n* Table of Contents                   
                                  ")
+        (gold "* About\n"))
+
+    ;; different TOC styles
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC:"         ) gold)
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC_1:"       ) gold)
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC_1_qqq:"   ) gold)
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1:"       ) gold)
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1@cxv:"   ) gold)
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" ) gold)
+
+    ;; trailing symbols
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\n") gold)
+    (org-toc-test-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\nsdfd") 
gold))
+
+  ;; more complex case
+  (org-toc-test-raw-toc-gold-test
+   "* About\n:TOC:\n drawer\n:END:\n\norg-toc is a utility to have an 
up-to-date table of contents in the\norg files without exporting (useful 
primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n\n* Table of Contents                   
                                  :TOC:\n - [[#about][About]]\n - 
[[#use][Use]]\n - [[#different-href-styles][Different href st [...]
+   "* About\n* Installation\n** via package.el\n** Manual\n* Use\n* Different 
href styles\n* Example\n"))
 
 (defun org-toc-hrefify-gh (str)
   "Given a heading, transform it into a href using the GitHub
@@ -135,13 +135,11 @@ rules."
          (special-chars-fix (replace-regexp-in-string 
org-toc-special-chars-regexp "" upcase-fix t)))
     (concat "#" special-chars-fix)))
 
-(eval-after-load "ert-autoloads"
-  (when (require 'ert nil t)
-    (ert-deftest org-toc-test-hrefify-gh ()
-      "Test the `org-toc-hrefify-gh' function"
-      (should (equal (org-toc-hrefify-gh "About") "#about"))
-      (should (equal (org-toc-hrefify-gh "!h@#$%^&*(){}|][:;\"'/?.>,<`~") 
"#h"))
-      (should (equal (org-toc-hrefify-gh "!h@#$% ^&*(S){}|][:;\"'/?.>,<`~") 
"#h-s")))))
+(ert-deftest org-toc-test-hrefify-gh ()
+  "Test the `org-toc-hrefify-gh' function"
+  (should (equal (org-toc-hrefify-gh "About") "#about"))
+  (should (equal (org-toc-hrefify-gh "!h@#$%^&*(){}|][:;\"'/?.>,<`~") "#h"))
+  (should (equal (org-toc-hrefify-gh "!h@#$% ^&*(S){}|][:;\"'/?.>,<`~") 
"#h-s")))
 
 (defun org-toc-hrefify-org (str)
   "Given a heading, transform it into a href using the org-mode
@@ -181,13 +179,11 @@ each heading into a link."
     (buffer-substring-no-properties
      (point-min) (point-max))))
 
-(eval-after-load "ert-autoloads"
-  (when (require 'ert nil t)
-    (ert-deftest org-toc-test-hrefify-toc ()
-      (should (equal (org-toc-hrefify-toc "* About\n" 'upcase)
-                     " - [[ABOUT][About]]\n"))
-      (should (equal (org-toc-hrefify-toc "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 'upcase)
-                     " - [[ABOUT][About]]\n - [[INSTALLATION][Installation]]\n 
    - [[VIA PACKAGE.EL][via package.el]]\n     - [[MANUAL][Manual]]\n - 
[[USE][Use]]\n - [[DIFFERENT HREF STYLES][Different href styles]]\n - 
[[EXAMPLE][Example]]\n")))))
+(ert-deftest org-toc-test-hrefify-toc ()
+  (should (equal (org-toc-hrefify-toc "* About\n" 'upcase)
+                 " - [[ABOUT][About]]\n"))
+  (should (equal (org-toc-hrefify-toc "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 'upcase)
+                 " - [[ABOUT][About]]\n - [[INSTALLATION][Installation]]\n     
- [[VIA PACKAGE.EL][via package.el]]\n     - [[MANUAL][Manual]]\n - 
[[USE][Use]]\n - [[DIFFERENT HREF STYLES][Different href styles]]\n - 
[[EXAMPLE][Example]]\n")))
 
 (defun org-toc-flush-subheadings (toc max-depth)
   "Flush subheadings of the raw `toc' deeper than `max-depth'."
@@ -203,24 +199,22 @@ each heading into a link."
     (buffer-substring-no-properties
      (point-min) (point-max))))
 
-(eval-after-load "ert-autoloads"
-  (when (require 'ert nil t)
-    (ert-deftest org-toc-test-flush-subheadings ()
-      (should (equal (org-toc-flush-subheadings "* About\n" 0)
-                     ""))
-      (should (equal (org-toc-flush-subheadings "* About\n" 1)
-                     "* About\n"))
-      (should (equal (org-toc-flush-subheadings "* About\n" 2)
-                     "* About\n"))
-
-      (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** 
via package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 0)
-                     ""))
-      (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** 
via package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 1)
-                     "* About\n* Installation\n* Use\n* Different href 
styles\n* Example\n"))
-      (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** 
via package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 2)
-                     "* About\n* Installation\n** via package.el\n** Manual\n* 
Use\n* Different href styles\n* Example\n"))
-      (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** 
via package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 3)
-                     "* About\n* Installation\n** via package.el\n** Manual\n* 
Use\n* Different href styles\n* Example\n")))))
+(ert-deftest org-toc-test-flush-subheadings ()
+  (should (equal (org-toc-flush-subheadings "* About\n" 0)
+                 ""))
+  (should (equal (org-toc-flush-subheadings "* About\n" 1)
+                 "* About\n"))
+  (should (equal (org-toc-flush-subheadings "* About\n" 2)
+                 "* About\n"))
+
+  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 0)
+                 ""))
+  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 1)
+                 "* About\n* Installation\n* Use\n* Different href styles\n* 
Example\n"))
+  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 2)
+                 "* About\n* Installation\n** via package.el\n** Manual\n* 
Use\n* Different href styles\n* Example\n"))
+  (should (equal (org-toc-flush-subheadings "* About\n* Installation\n** via 
package.el\n** Manual\n* Use\n* Different href styles\n* Example\n" 3)
+                 "* About\n* Installation\n** via package.el\n** Manual\n* 
Use\n* Different href styles\n* Example\n")))
 
 (defun org-toc-insert-toc ()
   "Looks for a headline with the TOC tag and updates it with the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]