This commit is contained in:
parent
0870cb1fa5
commit
e4339cb64a
2 changed files with 14 additions and 6 deletions
14
i-ching.el
14
i-ching.el
|
@ -865,17 +865,21 @@ Provided by Randomness and Integrity Services Ltd. via https://www.random.org/"
|
||||||
The hexagram can be entered as a string, or by number."
|
The hexagram can be entered as a string, or by number."
|
||||||
(interactive "sHexagram number? " hexagram)
|
(interactive "sHexagram number? " hexagram)
|
||||||
(let ((hexagram-number
|
(let ((hexagram-number
|
||||||
(pcase hexagram
|
(cond
|
||||||
((pred numberp) hexagram)
|
((i-ching-hexagram-p hexagram)
|
||||||
((pred i-ching-hexagram-p)
|
(i-ching-hexagram-to-number hexagram))
|
||||||
(i-ching-hexagram-to-number hexagram))
|
((numberp hexagram) hexagram)
|
||||||
(_ (error "Not a hexagram symbol or number")))))
|
((stringp hexagram)
|
||||||
|
(if (numberp (string-to-number hexagram))
|
||||||
|
(string-to-number hexagram)))
|
||||||
|
(t (error "Not a hexagram symbol or number")))))
|
||||||
(format "%s\n\n%s\n\nJudgment: %s\n\nImage: %s\n\n"
|
(format "%s\n\n%s\n\nJudgment: %s\n\nImage: %s\n\n"
|
||||||
(i-ching-number-to-hexagram hexagram-number)
|
(i-ching-number-to-hexagram hexagram-number)
|
||||||
(i-ching-number-to-description hexagram-number)
|
(i-ching-number-to-description hexagram-number)
|
||||||
(i-ching-number-to-judgment hexagram-number)
|
(i-ching-number-to-judgment hexagram-number)
|
||||||
(i-ching-number-to-image hexagram-number))))
|
(i-ching-number-to-image hexagram-number))))
|
||||||
|
|
||||||
|
|
||||||
;; querying the I Ching
|
;; querying the I Ching
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
6
tests.el
6
tests.el
|
@ -76,7 +76,11 @@
|
||||||
|
|
||||||
(ert-deftest i-ching-interprets ()
|
(ert-deftest i-ching-interprets ()
|
||||||
(should (stringp (i-ching-interpretation 49)))
|
(should (stringp (i-ching-interpretation 49)))
|
||||||
(should-not (seq-empty-p (i-ching-interpretation 49))))
|
(should (stringp (i-ching-interpretation "23")))
|
||||||
|
(should (stringp (i-ching-interpretation "䷖")))
|
||||||
|
(should-not (seq-empty-p (i-ching-interpretation 49)))
|
||||||
|
(should-not (seq-empty-p (i-ching-interpretation "23")))
|
||||||
|
(should-not (seq-empty-p (i-ching-interpretation "䷖"))))
|
||||||
|
|
||||||
(ert-deftest i-ching-queries ()
|
(ert-deftest i-ching-queries ()
|
||||||
(should (stringp (i-ching-query-string)))
|
(should (stringp (i-ching-query-string)))
|
||||||
|
|
Loading…
Reference in a new issue