diff --git a/README.md b/README.md index fc19a5b..f268123 100644 --- a/README.md +++ b/README.md @@ -1088,7 +1088,7 @@ Return a list with running sums of items in `list`. ```el (-running-sum '(1 2 3 4)) ;; => (1 3 6 10) (-running-sum '(1)) ;; => (1) -(-running-sum ()) ;; Error +(-running-sum ()) ;; Wrong type argument: consp, nil ``` #### -product `(list)` @@ -1109,7 +1109,7 @@ Return a list with running products of items in `list`. ```el (-running-product '(1 2 3 4)) ;; => (1 2 6 24) (-running-product '(1)) ;; => (1) -(-running-product ()) ;; Error +(-running-product ()) ;; Wrong type argument: consp, nil ``` #### -inits `(list)` @@ -1807,7 +1807,7 @@ the `apl` language. ```el (-iota 6) ;; => (0 1 2 3 4 5) (-iota 4 2.5 -2) ;; => (2.5 0.5 -1.5 -3.5) -(-iota -1) ;; Error +(-iota -1) ;; Wrong type argument: natnump, -1 ``` #### -zip-with `(fn list1 list2)` diff --git a/dev/examples-to-docs.el b/dev/examples-to-docs.el index 8fc4567..983f8fb 100644 --- a/dev/examples-to-docs.el +++ b/dev/examples-to-docs.el @@ -44,9 +44,13 @@ (defun example-to-string (example) (pcase-let ((`(,actual ,sym ,expected) example) (print-quoted t)) - (and (eq (car-safe expected) 'quote) - (not (equal expected ''())) - (setq expected (cadr expected))) + (cond ((eq sym '!!>) + ;; Print actual error message. + (setq expected (error-message-string (-list expected)))) + ((and (eq (car-safe expected) 'quote) + (not (equal expected ''()))) + ;; Unquote expected result. + (setq expected (cadr expected)))) (with-output-to-string (with-current-buffer standard-output (dash--print-lisp-as-md actual) @@ -55,7 +59,7 @@ (princ sym) (insert ?\s) (dash--print-lisp-as-md expected)) - ((eq sym '!!>) (insert "Error")) + ((eq sym '!!>) (princ expected)) ((error "Invalid test case: %S" example))))))) (defun dash--describe (fn)