about summary refs log tree commit diff
path: root/configs/shared/.emacs.d/wpc/do.el
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2019-10-09T11·13+0100
committerWilliam Carroll <wpcarro@gmail.com>2019-12-24T15·21+0000
commit6b456c1b7a4f6899f063a6e65355af51901d9c7a (patch)
treecfc70d74818ae9fabdbbfb0cf16cce092e4c1a09 /configs/shared/.emacs.d/wpc/do.el
parenta7c72adb2ebec1e497fc040eaf3551d564d61a5b (diff)
Massive configuration overhaul
Currently paying the price of months of non-diligent git usage.

Here's what has changed.

- Theming support in Gvcci and wpgtk
- Dropping support for i3
- Supporting EXWM
- Many Elisp modules
- Collapsed redundant directories in ./configs
Diffstat (limited to 'configs/shared/.emacs.d/wpc/do.el')
-rw-r--r--configs/shared/.emacs.d/wpc/do.el54
1 files changed, 54 insertions, 0 deletions
diff --git a/configs/shared/.emacs.d/wpc/do.el b/configs/shared/.emacs.d/wpc/do.el
new file mode 100644
index 000000000000..7dc2b260fdcd
--- /dev/null
+++ b/configs/shared/.emacs.d/wpc/do.el
@@ -0,0 +1,54 @@
+;;; do.el --- Small assertion library for Elisp -*- lexical-binding: t -*-
+;; Author: William Carroll <wpcarro@gmail.com>
+
+;;; Commentary:
+;; Assertion library inspired by Elixir's core testing library.
+;;
+;; The goal here is to create this module without relying on other non-core
+;; Elisp libraries.  I will attempt to do this as long as I'm not sacrificing
+;; the readability of this code nor the ease at which it can be written.
+;;
+;; A note on testing:
+;; Another goal with this library is to blur the line between testing code and
+;; runtime code.  Developers should ideally be using `do/assert' and `do/refute'
+;; in their library code.  Because of this, I'm avoiding referring
+;; to the notion of testing in the names of these functions.
+;;
+;; Hypothesis:
+;; The lower the friction is for writing tests, the more likely people will
+;; write tests.
+
+;; TODO: Support better error messages, which might include information about
+;; line numbers in source code where the assertion failed.
+
+;; TODO: Consider offering the ability to have some of these functions compile
+;; to nothing at runtime if developers want to use them while developing without
+;; incurring the costs at runtime.
+
+;; TODO: Consider using this module instead of prelude.el.  Right now, I'm
+;; having troubling preferring one to the other.  The benefit of this module is
+;; that it's independent of prelude, but that might also be a downside, since
+;; the messaging that asserting should be a critical part of any core library
+;; like prelude.
+
+;;; Code:
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Library
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defmacro do/assert (x)
+  "Errors unless X is t.
+These are strict assertions and purposely do not rely on truthiness."
+  (let ((as-string (format "%s" x)))
+    `(unless (equal t ,x)
+       (error (concat "Assertion failed: " ,as-string)))))
+
+(defmacro do/refute (x)
+  "Errors unless X is nil."
+  (let ((as-string (format "%s" x)))
+    `(unless (eq nil ,x)
+       (error (concat "Refutation failed: " ,as-string)))))
+
+(provide 'do)
+;;; do.el ends here