aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-01 13:15:20 -0500
committerSean Allred <code@seanallred.com>2015-01-01 13:15:20 -0500
commit9469287080501f3e3c7ce0002d837664a1b9b91e (patch)
tree5d14819fb7c2adf0b356c8962107f442ec6243f2
parent7217c37a3619c72bce6ac5be97b969a0bb2f03cc (diff)
Use test fixture for sample data
See (info "(ert) Fixtures and Test Suites").
-rw-r--r--test/test-macros.el31
1 files changed, 17 insertions, 14 deletions
diff --git a/test/test-macros.el b/test/test-macros.el
index 6a1910c..8bdd527 100644
--- a/test/test-macros.el
+++ b/test/test-macros.el
@@ -1,18 +1,21 @@
+(defmacro sx-test-with-json-data (cell &rest body)
+ (declare (indent 1))
+ `(let ((,cell '((test . nil) (test-one . 1) (test-two . 2)
+ (link . "http://meta.emacs.stackexchange.com/"))))
+ ,@body))
+
(ert-deftest macro-test--sx-assoc-let ()
"Tests macro expansion for `sx-assoc-let'"
- (let ((prototype '((test . nil) (test-one . 1) (test-two . 2)
- (link . "http://meta.emacs.stackexchange.com/"))))
- (let ((data (copy-tree prototype)))
- (should
- (null (let-alist data .site))))
-
- (let ((data (copy-tree prototype)))
- (should
- (equal (sx-assoc-let data .site)
- "meta.emacs")))
+ (sx-test-with-json-data data
+ (should
+ (null (let-alist data .site))))
- (let ((data (copy-tree prototype)))
- (should
- (equal (sx-assoc-let data (cons .test-one .test-two))
- '(1 . 2))))))
+ (sx-test-with-json-data data
+ (should
+ (equal (sx-assoc-let data .site)
+ "meta.emacs")))
+ (sx-test-with-json-data data
+ (should
+ (equal (sx-assoc-let data (cons .test-one .test-two))
+ '(1 . 2)))))