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

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

[elpa] externals/assess 196470b1e1 08/95: New function buffer-string=


From: ELPA Syncer
Subject: [elpa] externals/assess 196470b1e1 08/95: New function buffer-string=
Date: Tue, 19 Jul 2022 15:57:28 -0400 (EDT)

branch: externals/assess
commit 196470b1e1c28968ce02bc777c13a53c03b1b07b
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>

    New function buffer-string=
    
    Compares the contents of a buffer with a string.
---
 Cask                  |  2 +-
 sisyphus.el           | 16 ++++++++++++++--
 test/sisyphus-test.el | 50 ++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/Cask b/Cask
index 7430091a46..4c185b2828 100644
--- a/Cask
+++ b/Cask
@@ -1,5 +1,5 @@
 (source gnu)
-(source melpa-stable)
+(source melpa)
 
 (package-file "sisyphus.el")
 
diff --git a/sisyphus.el b/sisyphus.el
index 5daf94f548..c4582e5826 100644
--- a/sisyphus.el
+++ b/sisyphus.el
@@ -47,6 +47,7 @@
 ;; #+begin_src emacs-lisp
 (require 'pp)
 (require 'ert)
+(require 'm-buffer-at)
 ;; #+end_src
 
 ;; ** Advice
@@ -156,14 +157,25 @@ print any messages!."
 ;; #+begin_src emacs-lisp
 (defun sisyphus-buffer-string= (buffer string)
   (string=
-   (m-buffer-at-substring buffer)
+   (m-buffer-at-string buffer)
    string))
 
+(defun sisyphus-explain-buffer-string= (buffer string)
+  (sisyphus-explain-string=
+   (m-buffer-at-string buffer)
+   string))
+
+(put 'sisyphus-buffer-string=
+     'ert-explainer
+     'sisyphus-explain-buffer-string=)
+
 ;; #+end_src
 
-;; Compare string to buffer
 
 ;; Compare buffer to buffer
+;; #+begin_src emacs-lisp
+
+;; #+end_src
 
 ;; Compare string to file
 
diff --git a/test/sisyphus-test.el b/test/sisyphus-test.el
index d7967b78f5..c4555fb359 100644
--- a/test/sisyphus-test.el
+++ b/test/sisyphus-test.el
@@ -18,14 +18,14 @@
 (require 'sisyphus)
 (require 'cl-lib)
 
-(defun sisyphus-test--plist-from-test (result)
+(defun sisyphus-test--plist-from-result (result)
   (cl-cdadr
    (ert-test-result-with-condition-condition result)))
 
 (ert-deftest plist-extraction ()
   (should
    (equal
-    (sisyphus-test--plist-from-test
+    (sisyphus-test--plist-from-result
      (ert-run-test
       (make-ert-test
        :body
@@ -34,16 +34,16 @@
           (eq 1 2))))))
     '(:form (eq 1 2) :value nil))))
 
-(defun sisyphus-test--explanation-from-test (result)
+(defun sisyphus-test--explanation-from-result (result)
   (plist-get
-   (sisyphus-test--plist-from-test result)
+   (sisyphus-test--plist-from-result result)
    :explanation))
 
-(ert-deftest explanation-extraction ()
+(ert-deftest explanation-extraction-from-result ()
   "Test that explanation is extractable from failing test.
 This also tests the advice on string=."
   (should
-   (sisyphus-test--explanation-from-test
+   (sisyphus-test--explanation-from-result
     (ert-run-test
      (make-ert-test
       :body
@@ -57,3 +57,41 @@ This also tests the advice on string=."
    (string= "1" "1"))
   (should-not
    (string= "1" "2")))
+
+(defun sisyphus-test--explanation (f)
+  (sisyphus-test--explanation-from-result
+   (ert-run-test
+    (make-ert-test
+     :body f))))
+
+(ert-deftest explanation-extraction ()
+  "Test that explanation is extractable from failing test.
+This also tests the advice on string=."
+  (should
+   (sisyphus-test--explanation
+    (lambda ()
+      (should
+       (string= "1" "2"))))))
+
+(ert-deftest buffer-string= ()
+  (with-temp-buffer
+    (insert "hello")
+    (should
+     (sisyphus-buffer-string=
+      (current-buffer)
+      "hello")))
+  (with-temp-buffer
+    (insert "goodbye")
+    (should-not
+     (sisyphus-buffer-string=
+      (current-buffer)
+      "hello")))
+  (should
+   (sisyphus-test--explanation
+    (lambda ()
+      (with-temp-buffer
+        (insert "goodbye")
+        (should
+         (sisyphus-buffer-string=
+          (current-buffer)
+          "hello")))))))



reply via email to

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