about summary refs log tree commit diff
path: root/users/wpcarro/emacs/pkgs/maybe/tests.el
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-07-29T18·15-0700
committerclbot <clbot@tvl.fyi>2022-07-30T00·35+0000
commit230c4bbb3e9f44875d6593a7c6cb0ca33bb63805 (patch)
tree55207bf03a894ffdd2b5687216081ee81e3fb195 /users/wpcarro/emacs/pkgs/maybe/tests.el
parent4a4f8f93583df81344dd1c91f033d8644028dc85 (diff)
feat(wpcarro/emacs): Package maybe.el r/4344
(Temporarily) remove dependency on list.el in favor of dash, which I'm not
thrilled about.

Change-Id: Ic4348ee72582dee63ba07a183f3bda65baa7e2d6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5999
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/wpcarro/emacs/pkgs/maybe/tests.el')
-rw-r--r--users/wpcarro/emacs/pkgs/maybe/tests.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/users/wpcarro/emacs/pkgs/maybe/tests.el b/users/wpcarro/emacs/pkgs/maybe/tests.el
new file mode 100644
index 000000000000..775bb6b7ac80
--- /dev/null
+++ b/users/wpcarro/emacs/pkgs/maybe/tests.el
@@ -0,0 +1,28 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Dependencies
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'maybe)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Tests
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(ert-deftest maybe-nil? ()
+  (and
+   (maybe-nil? nil)
+   (not (maybe-nil? t))))
+
+(ert-deftest maybe-some? ()
+  (and
+   (maybe-some? '(1 2 3))
+   (not (maybe-some? nil))))
+
+(ert-deftest maybe-default ()
+  (and
+   (string= "some" (maybe-default "some" nil))
+   (= 10 (maybe-default 1 10))))
+
+(ert-deftest maybe-map ()
+  (eq nil (maybe-map (lambda (x) (* x 2)) nil))
+  (= 4 (maybe-map (lambda (x) (* x 2)) 2)))