diff options
| author | Nicolas Petton | 2015-04-25 12:07:12 +0200 |
|---|---|---|
| committer | Nicolas Petton | 2015-04-25 12:07:12 +0200 |
| commit | 62879799ea0272f2ed3067252f20afb910bce352 (patch) | |
| tree | a1807809cd3c548076182440975f4eb97d20df2f /test | |
| parent | eea2e831381a7b33ecfcd1c4dfee725a917befd3 (diff) | |
| download | emacs-62879799ea0272f2ed3067252f20afb910bce352.tar.gz emacs-62879799ea0272f2ed3067252f20afb910bce352.zip | |
Fix a false negative in `map-elt' with alists and values being nil
* lisp/emacs-lisp/map.el (map-elt): If map is an alist and key is
found but its associated value is nil, do not return the default
value.
* test/automated/map-tests.el: Add a regression test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/map-tests.el | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/automated/map-tests.el b/test/automated/map-tests.el index 5201116613e..e65af894275 100644 --- a/test/automated/map-tests.el +++ b/test/automated/map-tests.el | |||
| @@ -66,6 +66,12 @@ Evaluate BODY for each created map. | |||
| 66 | (with-maps-do map | 66 | (with-maps-do map |
| 67 | (assert (= 5 (map-elt map 7 5))))) | 67 | (assert (= 5 (map-elt map 7 5))))) |
| 68 | 68 | ||
| 69 | (ert-deftest test-map-elt-with-nil-value () | ||
| 70 | (assert (null (map-elt '((a . 1) | ||
| 71 | (b)) | ||
| 72 | 'b | ||
| 73 | '2)))) | ||
| 74 | |||
| 69 | (ert-deftest test-map-put () | 75 | (ert-deftest test-map-put () |
| 70 | (with-maps-do map | 76 | (with-maps-do map |
| 71 | (map-put map 2 'hello) | 77 | (map-put map 2 'hello) |