guile: avoid body duplication

In message, don't re-fill when unneeded. Add tests.

Fixes #2802.
This commit is contained in:
Dirk-Jan C. Binnema
2025-02-05 21:16:15 +02:00
parent d33adc923c
commit c0887603c5
3 changed files with 28 additions and 15 deletions

View File

@ -74,10 +74,13 @@ exec guile -e main -s $0 $@
(str-equal-or-exit (mu:subject msg) "Fwd: rfc822")
(str-equal-or-exit (mu:to msg) "martin")
(str-equal-or-exit (mu:from msg) "foobar <foo@example.com>")
(str-equal-or-exit (mu:body msg) "Hello world, forwarding some RFC822 message\n")
(str-equal-or-exit (mu:header msg "X-Mailer") "Ximian Evolution 1.4.5")
;; issue #2802
(str-equal-or-exit (mu:body msg) "Hello world, forwarding some RFC822 message\n")
(if (not (equal? (mu:priority msg) mu:prio:normal))
(error-exit "Expected ~A, got ~A" (mu:priority msg) mu:prio:normal)))
(error-exit "Expected ~A, got ~A" (mu:priority msg) mu:prio:normal)))
(let ((msg (car (mu:message-list "atoms"))))
(str-equal-or-exit (mu:subject msg) "atoms")
@ -85,21 +88,21 @@ exec guile -e main -s $0 $@
(str-equal-or-exit (mu:from msg) "Richard P. Feynman <rpf@example.com>")
;;(str-equal-or-exit (mu:header msg "Content-Transfer-Encoding") "8bit")
(str-equal-or-exit (mu:body msg)
(string-join
'("If, in some cataclysm, all scientific knowledge were to be destroyed,"
"and only one sentence passed on to the next generation of creatures,"
"what statement would contain the most information in the fewest words?"
"I believe it is the atomic hypothesis (or atomic fact, or whatever you"
"wish to call it) that all things are made of atoms — little particles"
"that move around in perpetual motion, attracting each other when they"
"are a little distance apart, but repelling upon being squeezed into"
"one another. In that one sentence you will see an enormous amount of"
"information about the world, if just a little imagination and thinking"
"are applied.\n") "\n"))
(string-join
'("If, in some cataclysm, all scientific knowledge were to be destroyed,"
"and only one sentence passed on to the next generation of creatures,"
"what statement would contain the most information in the fewest words?"
"I believe it is the atomic hypothesis (or atomic fact, or whatever you"
"wish to call it) that all things are made of atoms — little particles"
"that move around in perpetual motion, attracting each other when they"
"are a little distance apart, but repelling upon being squeezed into"
"one another. In that one sentence you will see an enormous amount of"
"information about the world, if just a little imagination and thinking"
"are applied.\n") "\n"))
(str-equal-or-exit (mu:body-txt msg) (mu:body msg))
(let ((got (mu:body-html msg)))
(if got
(error-exit "Expected #f, got ~a" got)))
(error-exit "Expected #f, got ~a" got)))
(if (not (equal? (mu:priority msg) mu:prio:high))
(error-exit "Expected ~a, got ~a" (mu:priority msg) mu:prio:high))))