From: Phil Estival <pe@7d.nz>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: To factorize code of test sets (or not)
Date: Wed, 8 Jan 2025 09:45:27 +0100 [thread overview]
Message-ID: <18d80a44-bc2b-472a-bf62-05878b4f8fa4@7d.nz> (raw)
* [2025-01-07 19:38] Ihor Radchenko:> Phil Estival <pe@7d.nz> writes:
>
>> [...]
>> Some macros [for test suite] should probably be moved upward
>> in a file where generic functions which purposes are to help
>> writing the tests of babel source blocks should be declared.
>>
>
> I do not mind.
> But please show which _other_ tests can benefit from the simplification.
This may appear as an unnecessary effort to refactor, or worse,
normalize a code that can benefit from some diversity
yet,
the forms
(should
(equal "<str result>"
(org-test-with-temp-text "<block>"
(org-babel-next-src-block)
(org-trim (org-babel-execute-src-block))))))
or
(org-test-with-temp-text "<block>"
(org-babel-next-src-block)
(should (equal '(<something>) ;; or (should (string= "<str>
(org-babel-execute-src-block))))
;; or org-babel-execute-maybe for ruby and elisp
exist in
test-ob-[maxima,R,sqlite,sed,shell,plantuml,lua,java,julia,lob,octave,perl,python,emacs-lisp].el
Considering it at the repetitive pattern, I think a macro can shorten
those forms to :
(ob-test "<preamble + block>"
:expect "<expected-result>")
and a variant to test or exclude matching regexp
(ob-test "<preamble+block>"
:expect-to-match "<expected regexp to match>")
(ob-test "<preamble+block>"
:expect-to-not-match "<expected-regexp to not match>")
IMHO, they would be easier to read with one additional line feed
(ob-test "
#+begin_src ...
#+end_src"
:expect "<expected-result>")
rather than
(ob-test "#+begin_src ...
#+end_src"
:expect "<expected-result>")
Similar macro/function exists in
ob-emacs-lisp/dynamic-lexical-execute
or ob-sql/command-should-contain.
my 2¢,
Phil
reply other threads:[~2025-01-08 8:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18d80a44-bc2b-472a-bf62-05878b4f8fa4@7d.nz \
--to=pe@7d.nz \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).