summaryrefslogtreecommitdiff
path: root/test/lisp/cus-edit-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/cus-edit-tests.el')
-rw-r--r--test/lisp/cus-edit-tests.el42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/lisp/cus-edit-tests.el b/test/lisp/cus-edit-tests.el
index fee695a90b3..535711e02cf 100644
--- a/test/lisp/cus-edit-tests.el
+++ b/test/lisp/cus-edit-tests.el
@@ -92,5 +92,47 @@
(buffer-substring-no-properties (point-min) (point-max)))))
(should (string-search "Value `:foo' does not match type number"
warn-txt))))
+
+(defcustom cus-edit-test-bug63290-option nil
+ "Choice option for testing Bug#63290."
+ :type '(choice (alist
+ :key-type (string :tag "key")
+ :value-type (string :tag "value"))
+ (const :tag "auto" auto)))
+
+(defcustom cus-edit-test-bug63290-option2 'some
+ "Choice option for testing Bug#63290."
+ :type '(choice
+ (const :tag "some" some)
+ (alist
+ :key-type (string :tag "key")
+ :value-type (string :tag "value"))))
+
+(ert-deftest cus-edit-test-bug63290 ()
+ "Test that changing a choice value back to an alist respects its nil value."
+ (customize-variable 'cus-edit-test-bug63290-option)
+ (search-forward "Value")
+ ;; Simulate changing the value.
+ (let* ((choice (widget-at))
+ (args (widget-get choice :args))
+ (list-opt (car (widget-get choice :children)))
+ (const-opt (nth 1 args)))
+ (widget-put choice :explicit-choice const-opt)
+ (widget-value-set choice (widget-default-get const-opt))
+ (widget-put choice :explicit-choice list-opt)
+ (widget-value-set choice (widget-default-get list-opt)))
+ ;; No empty key/value pairs should show up.
+ (should-not (search-forward "key" nil t))
+ (customize-variable 'cus-edit-test-bug63290-option2)
+ (search-forward "Value")
+ ;; Simulate changing the value.
+ (let* ((choice (widget-at))
+ (args (widget-get choice :args))
+ (list-opt (nth 1 args)))
+ (widget-put choice :explicit-choice list-opt)
+ (widget-value-set choice (widget-default-get list-opt)))
+ ;; No empty key/value pairs should show up.
+ (should-not (search-forward "key" nil t)))
+
(provide 'cus-edit-tests)
;;; cus-edit-tests.el ends here