[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 553ff83 103/340: Add :to-have-same-items-as to c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 553ff83 103/340: Add :to-have-same-items-as to compare lists as sets. |
Date: |
Thu, 16 Dec 2021 14:59:12 -0500 (EST) |
branch: elpa/buttercup
commit 553ff83264fd16c9233a8493a323e152bd22f456
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
Add :to-have-same-items-as to compare lists as sets.
---
buttercup-compat.el | 3 +++
buttercup.el | 5 +++++
docs/writing-tests.md | 9 +++++++++
3 files changed, 17 insertions(+)
diff --git a/buttercup-compat.el b/buttercup-compat.el
index c509c68..be33d88 100644
--- a/buttercup-compat.el
+++ b/buttercup-compat.el
@@ -35,6 +35,9 @@
(when (not (fboundp 'cl-defstruct))
(defalias 'cl-defstruct 'defstruct))
+(when (not (fboundp 'cl-every))
+ (defalias 'cl-every 'every))
+
;;;;;;;;;;;;;;;;;;;;;
;; Introduced in 24.4
diff --git a/buttercup.el b/buttercup.el
index cffc182..6d5a130 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -161,6 +161,11 @@ MATCHER is either a matcher defined with
(cons t (format "Expected %S not to `equal' %S" a b))
(cons nil (format "Expected %S to `equal' %S" a b))))
+(buttercup-define-matcher :to-have-same-items-as (a b)
+ (if (cl-every (lambda (x) (member x b)) a)
+ (cons t (format "Expected %S not to have same items as %S" a b))
+ (cons nil (format "Expected %S to have same items as %S" a b))))
+
(buttercup-define-matcher :to-match (text regexp)
(if (string-match regexp text)
(cons t (format "Expected %S not to match the regexp %S"
diff --git a/docs/writing-tests.md b/docs/writing-tests.md
index 07b0dc4..b2caafb 100644
--- a/docs/writing-tests.md
+++ b/docs/writing-tests.md
@@ -103,6 +103,15 @@ that are not included below.
(bar '((a . 12) (b . 34))))
(expect foo :to-equal bar))))
+ (it "The :to-have-same-items-as matcher compares two lists as sets"
+ (let ((first (list "a" "b" "c"))
+ (second (list "c" "a" "b"))
+ (third (list "a" "c" "d")))
+ (expect first :to-have-same-items-as second)
+ (expect second :to-have-same-items-as first)
+ (expect first :not :to-have-same-items-as third)
+ (expect third :not :to-have-same-items-as second)))
+
(it "The :to-match matcher is for regular expressions"
(let ((message "foo bar baz"))
(expect message :to-match "bar")
- [nongnu] elpa/buttercup 62a34c7 322/340: Remove elc files in tests on make clean, (continued)
- [nongnu] elpa/buttercup 62a34c7 322/340: Remove elc files in tests on make clean, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0e5eae0 321/340: Merge pull request #192 from snogge/re-patterns, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup e0b5d9f 324/340: Correct error message in buttercup--format-stack-frame, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 843fa6f 327/340: Keep the actual variable definition with the reporter, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 315a891 326/340: Fix stack frame collection in buttercup--backtrace, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup cccdedf 334/340: Merge pull request #197 from snogge/omit-traceback, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup bef49f5 323/340: Remove extra newline in error backtrace, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6ef715f 328/340: Use buttercup--mark-stackframe to mark the start of test code, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 2f24a44 338/340: Make formatting of backtrace frames closer to that standard for Emacs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f6f9335 337/340: test: Add tests for buttercup-run-discovery, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 553ff83 103/340: Add :to-have-same-items-as to compare lists as sets.,
ELPA Syncer <=
- [nongnu] elpa/buttercup 657acef 102/340: Bump version: 1.4 → 1.5, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7e8898b 127/340: Implement :to-have-been-called-times matcher (close #90), ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ca09040 130/340: Improve the Makefile, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a535e51 134/340: Fix a logic error in spy tests, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6ad9565 135/340: Fix several edge cases in "spy-on", ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 389dc43 139/340: Fix a problem with reporter tests suppressing failure messages, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 929a904 143/340: Implement closure-based expect macro, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 11d7fdc 148/340: Add "--help" option to buttercup command-line script, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4106adc 170/340: Add release script, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9b6cc79 177/340: travis: Test on 26.1, ELPA Syncer, 2021/12/16