From 45fbcfe37da8e0caa941311626db77e94889fddb Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 5 Jun 2015 16:29:41 -0400 Subject: [PATCH] * test/automated/map-tests.el: Replace "assert" with "should". --- test/automated/map-tests.el | 186 ++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/test/automated/map-tests.el b/test/automated/map-tests.el index 2f7d4eb0572..96fc9b15a25 100644 --- a/test/automated/map-tests.el +++ b/test/automated/map-tests.el @@ -56,18 +56,18 @@ Evaluate BODY for each created map. (ert-deftest test-map-elt () (with-maps-do map - (assert (= 3 (map-elt map 0))) - (assert (= 4 (map-elt map 1))) - (assert (= 5 (map-elt map 2))) - (assert (null (map-elt map -1))) - (assert (null (map-elt map 4))))) + (should (= 3 (map-elt map 0))) + (should (= 4 (map-elt map 1))) + (should (= 5 (map-elt map 2))) + (should (null (map-elt map -1))) + (should (null (map-elt map 4))))) (ert-deftest test-map-elt-default () (with-maps-do map - (assert (= 5 (map-elt map 7 5))))) + (should (= 5 (map-elt map 7 5))))) (ert-deftest test-map-elt-with-nil-value () - (assert (null (map-elt '((a . 1) + (should (null (map-elt '((a . 1) (b)) 'b '2)))) @@ -75,89 +75,89 @@ Evaluate BODY for each created map. (ert-deftest test-map-put () (with-maps-do map (map-put map 2 'hello) - (assert (eq (map-elt map 2) 'hello))) + (should (eq (map-elt map 2) 'hello))) (let ((ht (make-hash-table))) (map-put ht 2 'a) - (assert (eq (map-elt ht 2) + (should (eq (map-elt ht 2) 'a))) (let ((alist '((0 . a) (1 . b) (2 . c)))) (map-put alist 2 'a) - (assert (eq (map-elt alist 2) + (should (eq (map-elt alist 2) 'a))) (let ((vec [3 4 5])) (should-error (map-put vec 3 6)))) (ert-deftest test-map-put-literal () - (assert (= (map-elt (map-put [1 2 3] 1 4) 1) + (should (= (map-elt (map-put [1 2 3] 1 4) 1) 4)) - (assert (= (map-elt (map-put (make-hash-table) 'a 2) 'a) + (should (= (map-elt (map-put (make-hash-table) 'a 2) 'a) 2)) (should-error (map-put '((a . 1)) 'b 2)) (should-error (map-put '() 'a 1))) (ert-deftest test-map-put-return-value () (let ((ht (make-hash-table))) - (assert (eq (map-put ht 'a 'hello) ht)))) + (should (eq (map-put ht 'a 'hello) ht)))) (ert-deftest test-map-delete () (with-maps-do map (map-delete map 1) - (assert (null (map-elt map 1)))) + (should (null (map-elt map 1)))) (with-maps-do map (map-delete map -2) - (assert (null (map-elt map -2))))) + (should (null (map-elt map -2))))) (ert-deftest test-map-delete-return-value () (let ((ht (make-hash-table))) - (assert (eq (map-delete ht 'a) ht)))) + (should (eq (map-delete ht 'a) ht)))) (ert-deftest test-map-nested-elt () (let ((vec [a b [c d [e f]]])) - (assert (eq (map-nested-elt vec '(2 2 0)) 'e))) + (should (eq (map-nested-elt vec '(2 2 0)) 'e))) (let ((alist '((a . 1) (b . ((c . 2) (d . 3) (e . ((f . 4) (g . 5)))))))) - (assert (eq (map-nested-elt alist '(b e f)) + (should (eq (map-nested-elt alist '(b e f)) 4))) (let ((ht (make-hash-table))) (map-put ht 'a 1) (map-put ht 'b (make-hash-table)) (map-put (map-elt ht 'b) 'c 2) - (assert (eq (map-nested-elt ht '(b c)) + (should (eq (map-nested-elt ht '(b c)) 2)))) (ert-deftest test-map-nested-elt-default () (let ((vec [a b [c d]])) - (assert (null (map-nested-elt vec '(2 3)))) - (assert (null (map-nested-elt vec '(2 1 1)))) - (assert (= 4 (map-nested-elt vec '(2 1 1) 4))))) + (should (null (map-nested-elt vec '(2 3)))) + (should (null (map-nested-elt vec '(2 1 1)))) + (should (= 4 (map-nested-elt vec '(2 1 1) 4))))) (ert-deftest test-map-p () - (assert (map-p nil)) - (assert (map-p '((a . b) (c . d)))) - (assert (map-p '(a b c d))) - (assert (map-p [])) - (assert (map-p [1 2 3])) - (assert (map-p (make-hash-table))) - (assert (map-p "hello")) - (assert (not (map-p 1))) - (assert (not (map-p 'hello)))) + (should (map-p nil)) + (should (map-p '((a . b) (c . d)))) + (should (map-p '(a b c d))) + (should (map-p [])) + (should (map-p [1 2 3])) + (should (map-p (make-hash-table))) + (should (map-p "hello")) + (should (not (map-p 1))) + (should (not (map-p 'hello)))) (ert-deftest test-map-keys () (with-maps-do map - (assert (equal (map-keys map) '(0 1 2)))) - (assert (null (map-keys nil))) - (assert (null (map-keys [])))) + (should (equal (map-keys map) '(0 1 2)))) + (should (null (map-keys nil))) + (should (null (map-keys [])))) (ert-deftest test-map-values () (with-maps-do map - (assert (equal (map-values map) '(3 4 5))))) + (should (equal (map-values map) '(3 4 5))))) (ert-deftest test-map-pairs () (with-maps-do map - (assert (equal (map-pairs map) '((0 . 3) + (should (equal (map-pairs map) '((0 . 3) (1 . 4) (2 . 5)))))) @@ -167,27 +167,27 @@ Evaluate BODY for each created map. (puthash 'b 2 ht) (puthash 'c 3 ht) (puthash 'd 4 ht) - (assert (= 0 (map-length nil))) - (assert (= 0 (map-length []))) - (assert (= 0 (map-length (make-hash-table)))) - (assert (= 5 (map-length [0 1 2 3 4]))) - (assert (= 2 (map-length '((a . 1) (b . 2))))) - (assert (= 4 (map-length ht))))) + (should (= 0 (map-length nil))) + (should (= 0 (map-length []))) + (should (= 0 (map-length (make-hash-table)))) + (should (= 5 (map-length [0 1 2 3 4]))) + (should (= 2 (map-length '((a . 1) (b . 2))))) + (should (= 4 (map-length ht))))) (ert-deftest test-map-copy () (with-maps-do map (let ((copy (map-copy map))) - (assert (equal (map-keys map) (map-keys copy))) - (assert (equal (map-values map) (map-values copy))) - (assert (not (eq map copy)))))) + (should (equal (map-keys map) (map-keys copy))) + (should (equal (map-values map) (map-values copy))) + (should (not (eq map copy)))))) (ert-deftest test-map-apply () (with-maps-do map - (assert (equal (map-apply (lambda (k v) (cons (int-to-string k) v)) + (should (equal (map-apply (lambda (k v) (cons (int-to-string k) v)) map) '(("0" . 3) ("1" . 4) ("2" . 5))))) (let ((vec [a b c])) - (assert (equal (map-apply (lambda (k v) (cons (1+ k) v)) + (should (equal (map-apply (lambda (k v) (cons (1+ k) v)) vec) '((1 . a) (2 . b) @@ -195,139 +195,139 @@ Evaluate BODY for each created map. (ert-deftest test-map-keys-apply () (with-maps-do map - (assert (equal (map-keys-apply (lambda (k) (int-to-string k)) + (should (equal (map-keys-apply (lambda (k) (int-to-string k)) map) '("0" "1" "2")))) (let ((vec [a b c])) - (assert (equal (map-keys-apply (lambda (k) (1+ k)) + (should (equal (map-keys-apply (lambda (k) (1+ k)) vec) '(1 2 3))))) (ert-deftest test-map-values-apply () (with-maps-do map - (assert (equal (map-values-apply (lambda (v) (1+ v)) + (should (equal (map-values-apply (lambda (v) (1+ v)) map) '(4 5 6)))) (let ((vec [a b c])) - (assert (equal (map-values-apply (lambda (v) (symbol-name v)) + (should (equal (map-values-apply (lambda (v) (symbol-name v)) vec) '("a" "b" "c"))))) (ert-deftest test-map-filter () (with-maps-do map - (assert (equal (map-keys (map-filter (lambda (k v) + (should (equal (map-keys (map-filter (lambda (k v) (<= 4 v)) map)) '(1 2))) - (assert (null (map-filter (lambda (k v) + (should (null (map-filter (lambda (k v) (eq 'd k)) map)))) - (assert (null (map-filter (lambda (k v) + (should (null (map-filter (lambda (k v) (eq 3 v)) [1 2 4 5]))) - (assert (equal (map-filter (lambda (k v) + (should (equal (map-filter (lambda (k v) (eq 3 k)) [1 2 4 5]) '((3 . 5))))) (ert-deftest test-map-remove () (with-maps-do map - (assert (equal (map-keys (map-remove (lambda (k v) + (should (equal (map-keys (map-remove (lambda (k v) (>= v 4)) map)) '(0))) - (assert (equal (map-keys (map-remove (lambda (k v) + (should (equal (map-keys (map-remove (lambda (k v) (eq 'd k)) map)) (map-keys map)))) - (assert (equal (map-remove (lambda (k v) + (should (equal (map-remove (lambda (k v) (eq 3 v)) [1 2 4 5]) '((0 . 1) (1 . 2) (2 . 4) (3 . 5)))) - (assert (null (map-remove (lambda (k v) + (should (null (map-remove (lambda (k v) (>= k 0)) [1 2 4 5])))) (ert-deftest test-map-empty-p () - (assert (map-empty-p nil)) - (assert (not (map-empty-p '((a . b) (c . d))))) - (assert (map-empty-p [])) - (assert (not (map-empty-p [1 2 3]))) - (assert (map-empty-p (make-hash-table))) - (assert (not (map-empty-p "hello"))) - (assert (map-empty-p ""))) + (should (map-empty-p nil)) + (should (not (map-empty-p '((a . b) (c . d))))) + (should (map-empty-p [])) + (should (not (map-empty-p [1 2 3]))) + (should (map-empty-p (make-hash-table))) + (should (not (map-empty-p "hello"))) + (should (map-empty-p ""))) (ert-deftest test-map-contains-key-p () - (assert (map-contains-key-p '((a . 1) (b . 2)) 'a)) - (assert (not (map-contains-key-p '((a . 1) (b . 2)) 'c))) - (assert (map-contains-key-p '(("a" . 1)) "a")) - (assert (not (map-contains-key-p '(("a" . 1)) "a" #'eq))) - (assert (map-contains-key-p [a b c] 2)) - (assert (not (map-contains-key-p [a b c] 3)))) + (should (map-contains-key-p '((a . 1) (b . 2)) 'a)) + (should (not (map-contains-key-p '((a . 1) (b . 2)) 'c))) + (should (map-contains-key-p '(("a" . 1)) "a")) + (should (not (map-contains-key-p '(("a" . 1)) "a" #'eq))) + (should (map-contains-key-p [a b c] 2)) + (should (not (map-contains-key-p [a b c] 3)))) (ert-deftest test-map-some-p () (with-maps-do map - (assert (equal (map-some-p (lambda (k v) + (should (equal (map-some-p (lambda (k v) (eq 1 k)) map) (cons 1 4))) - (assert (not (map-some-p (lambda (k v) + (should (not (map-some-p (lambda (k v) (eq 'd k)) map)))) (let ((vec [a b c])) - (assert (equal (map-some-p (lambda (k v) + (should (equal (map-some-p (lambda (k v) (> k 1)) vec) (cons 2 'c))) - (assert (not (map-some-p (lambda (k v) + (should (not (map-some-p (lambda (k v) (> k 3)) vec))))) (ert-deftest test-map-every-p () (with-maps-do map - (assert (map-every-p (lambda (k v) + (should (map-every-p (lambda (k v) k) map)) - (assert (not (map-every-p (lambda (k v) + (should (not (map-every-p (lambda (k v) nil) map)))) (let ((vec [a b c])) - (assert (map-every-p (lambda (k v) + (should (map-every-p (lambda (k v) (>= k 0)) vec)) - (assert (not (map-every-p (lambda (k v) + (should (not (map-every-p (lambda (k v) (> k 3)) vec))))) (ert-deftest test-map-into () (let* ((alist '((a . 1) (b . 2))) (ht (map-into alist 'hash-table))) - (assert (hash-table-p ht)) - (assert (equal (map-into (map-into alist 'hash-table) 'list) + (should (hash-table-p ht)) + (should (equal (map-into (map-into alist 'hash-table) 'list) alist)) - (assert (listp (map-into ht 'list))) - (assert (equal (map-keys (map-into (map-into ht 'list) 'hash-table)) + (should (listp (map-into ht 'list))) + (should (equal (map-keys (map-into (map-into ht 'list) 'hash-table)) (map-keys ht))) - (assert (equal (map-values (map-into (map-into ht 'list) 'hash-table)) + (should (equal (map-values (map-into (map-into ht 'list) 'hash-table)) (map-values ht))) - (assert (null (map-into nil 'list))) - (assert (map-empty-p (map-into nil 'hash-table))) + (should (null (map-into nil 'list))) + (should (map-empty-p (map-into nil 'hash-table))) (should-error (map-into [1 2 3] 'string)))) (ert-deftest test-map-let () (map-let (foo bar baz) '((foo . 1) (bar . 2)) - (assert (= foo 1)) - (assert (= bar 2)) - (assert (null baz))) + (should (= foo 1)) + (should (= bar 2)) + (should (null baz))) (map-let ((foo . a) (bar . b) (baz . c)) '((foo . 1) (bar . 2)) - (assert (= a 1)) - (assert (= b 2)) - (assert (null c)))) + (should (= a 1)) + (should (= b 2)) + (should (null c)))) (provide 'map-tests) ;;; map-tests.el ends here -- 2.39.2