aboutsummaryrefslogtreecommitdiff
path: root/test/test-macros.el
blob: 21690888d6b59f81cac9f43ec997ef971bd2c080 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(defmacro sx-test-with-json-data (cell &rest body)
  "Run BODY with sample data let-bound to CELL"
  (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 ()
  "Test `sx-assoc-let'"
  (sx-test-with-json-data data
    (should
     (null (let-alist data .site))))

  (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)))))