[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DRAFT PATCH v5] Decouple LANG= and testing (was: Test failure due t
From: |
Ihor Radchenko |
Subject: |
Re: [DRAFT PATCH v5] Decouple LANG= and testing (was: Test failure due to LANG) |
Date: |
Wed, 26 Apr 2023 08:44:07 +0000 |
Ruijie Yu <ruijie@netyu.xyz> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> (let ((org-time-stamp-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M")))
>> (org-element-timestamp-interpreter timestamp nil))
>
> Thanks for the pointer. I have made this into a macro and redid my
> changes accordingly. Please also let me know if more work should be
> dedicated to avoid code duplication in tests (I see a lot of duplication
> in the portions I touched in testing/lisp/test-org.el).
Thanks!
Some comments below.
> +(defmacro org-test-with-result (result &rest body)
...
> + (_ result))))
> +
> +(defmacro org-test-without-dow (result &rest body)
> + "Eval BODY skipping day-of-week in timestamps.
> +See `org-test-with-result' for RESULT and the return value."
> + (declare (indent 1))
> + `(let ((org-time-stamp-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M")))
> + ;; ,(macroexpand-1 `(org-test-with-result ,result ,@body))
> + (org-test-with-result ,result ,@body)))
When reading the test code, this `org-test-without-dow' is quite
confusing - the name suggests "day of week"-related, but RESULTS='buffer
argument is doing something completely different.
IMHO, it would be cleaner to:
1. (let ((org-time-stamp-formats ...)) ...) around the whole test.
2. Use `org-test-with-result' explicitly inside individual test clauses.
> +(defconst org-test-day-of-weeks-abbrev
> + (apply #'vector
> + (seq-map (apply-partially #'format-time-string "%a")
> + org-test-day-of-weeks-seconds))
> + "Vector of abbreviated names of days of week.
> +See `org-test-day-of-weeks-seconds'.")
> +
> +(defconst org-test-day-of-weeks-full
> + (apply #'vector
> + (seq-map (apply-partially #'format-time-string "%A")
> + org-test-day-of-weeks-seconds))
> + "Vector of full names for days of week.
> +See `org-test-day-of-weeks-seconds'.")
These constants make it necessary to write incantations like
(sun (aref org-test-day-of-weeks-abbrev 0))
Why not creating a function like (org-test-translate-dow "Mon")
or (org-test-translate-dow "Monday") that will do the same?
It will be a lot more readable as well. You can then use an alist
instead of vectors.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
- Re: [DRAFT PATCH v2] Decouple LANG= and testing (was: Test failure due to LANG), (continued)
- Re: [DRAFT PATCH v2] Decouple LANG= and testing (was: Test failure due to LANG), Ruijie Yu, 2023/04/22
- Re: [DRAFT PATCH v3] Decouple LANG= and testing (was: Test failure due to LANG), Ruijie Yu, 2023/04/22
- Re: [DRAFT PATCH v3] Decouple LANG= and testing (was: Test failure due to LANG), Axel Kielhorn, 2023/04/23
- Re: [DRAFT PATCH v4] Decouple LANG= and testing (was: Test failure due to LANG), Ruijie Yu, 2023/04/23
- Re: [DRAFT PATCH v4] Decouple LANG= and testing (was: Test failure due to LANG), Ihor Radchenko, 2023/04/23
- Re: [DRAFT PATCH v4] Decouple LANG= and testing (was: Test failure due to LANG), Ruijie Yu, 2023/04/23
- Re: [DRAFT PATCH v4] Decouple LANG= and testing (was: Test failure due to LANG), Ihor Radchenko, 2023/04/23
- Re: [DRAFT PATCH v5] Decouple LANG= and testing (was: Test failure due to LANG), Ruijie Yu, 2023/04/25
- Re: [DRAFT PATCH v6] Decouple LANG= and testing (was: Test failure due to LANG), Ruijie Yu, 2023/04/25
- Re: [DRAFT PATCH v6] Decouple LANG= and testing (was: Test failure due to LANG), Ihor Radchenko, 2023/04/26
- Re: [DRAFT PATCH v5] Decouple LANG= and testing (was: Test failure due to LANG),
Ihor Radchenko <=
- Re: Test failure due to LANG, Axel Kielhorn, 2023/04/22
Re: Test failure due to LANG, Ihor Radchenko, 2023/04/22
Re: Test failure due to LANG, Axel Kielhorn, 2023/04/22