* To factorize code of test sets (or not)
@ 2025-01-08 8:45 Phil Estival
0 siblings, 0 replies; only message in thread
From: Phil Estival @ 2025-01-08 8:45 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Org Mode List
* [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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-08 8:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 8:45 To factorize code of test sets (or not) Phil Estival
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).