lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regtest for issue 5181 (was: \mark and slur)


From: David Kastrup
Subject: Regtest for issue 5181 (was: \mark and slur)
Date: Fri, 22 Sep 2017 12:22:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> 2017-09-16 22:21 GMT+02:00 David Kastrup <address@hidden>:
>> Thomas Morley <address@hidden> writes:
>>
>>> 2017-09-16 21:49 GMT+02:00 David Kastrup <address@hidden>:
>>>
>>>> And, uh, it is lacking regtests and documentation.  Because someone for
>>>> some reason finds it less challenging to implement functionality than
>>>> inventing examples using it...
>>>
>>> Absolutely no idea which person you may have in mind ...
>>>
>>>> If you are testing things out anyway, at least regtests should not be
>>>> too far away...
>>>
>>> Will do, at least for regtests and as soon as I find some time.
>>
>> Thanks.  Sorry for my mental laziness.
>
> You? Lazy? Rubbish!
>
> Here my suggestion for a regtest. Not sure if we discuss/demonstrate
> problems in regtests, though.
> Ofcourse the title would be removed (only done for demonstration here)
> and surpressing the warning probably needs to be adjusted, depending
> how 5194 will be done finally.

Now things become _really_ embarrassing.  Trying to come up with
improvements on your regtest convinced me that this kind of syntactical
feature is not served well by a graphical test featuring the typeset
results.

So I stole a bunch of code from the display-lily-tests.ly regtest.

I am not convinced this is good either: only outputting stuff that is
less than perfect, and only to the terminal (namely without any typeset
output) is not nice for the printed variant of the regtests either.  But
if there is a better choice, it would probably also warrant implementing
in display-lily-tests.ly .

Not putting up an issue just yet.  Need to hear that you're ok with what
amounts to scrapping your work after it helped me figure out why I
wasn't even able to start writing something that I felt good about.

\version "2.21.0"

\header {

  texidoc = "This is a test of combining post-events with various
constructs.  Problems are reported on the stderr of this run; there
are no images produced."

}

%%%
%%% Testing utilities
%%%
#(use-modules (scm display-lily))

#(define (parse-lily-and-compute-lily-string chr port)
  (let ((lily-string (call-with-output-string
                      (lambda (out)
                        (do ((c (read-char port) (read-char port)))
                            ((and (char=? c #\#)
                                  (char=? (peek-char port) #\]))
                             (read-char port))
                          (display c out))))))
    `(let* ((parser-clone (ly:parser-clone))
            (input-str (string-append "\\displayLilyMusic "
                                      (string-trim-both ,lily-string)))
            (music #f)
            (seen
             (string-trim-both
              (with-output-to-string
               (lambda ()
                (set! music
                 (ly:parse-string-expression parser-clone input-str))))))
            (result-str (string-trim-both (music->lily-string music))))
      (cons* input-str result-str seen))))

#(read-hash-extend #\[ parse-lily-and-compute-lily-string) %{ ] %}

#(define (lily-string->markup str)
   (make-column-markup (string-split str #\NewLine)))

test =
#(define-void-function (harmless strings)
  ((string?) pair?)
  (let ((input (car strings))
        (output (cadr strings))
        (seen (cddr strings))
        (result-info (or harmless "BUG")))
   (if harmless
    (if (not (equal? output seen))
     (ly:progress "Test unequal: ~a.\ninput  = ~a\nvalue  = ~a\noutput = ~a\n"
      harmless input output seen)
     (ly:input-warning (*location*) "Test equal: unexpected.\ninput  = 
~a\nvalue  = ~a\noutput = ~a"
      input output seen))
    (if (not (equal? output seen))
     (ly:input-warning (*location*) "Test unequal: BUG.\ninput  = ~a\nvalue  = 
~a\noutput = ~a"
      input output seen)))))

pitch = c'
note = c'4
chord = <c' g'>

\test "limitation" ##[ \note -1 #]
\test "limitation" ##[ $note -1 #]
\test "limitation" ##[ \chord -1 #]
\test ##[ { \note -1 } #]
\test "limitation" ##[ { \note -1 } -2 #]
\test ##[ < \note -1 g' > -2 #]
\test ##[ { \chord -1 } #]
\test ##[ $pitch -1 #]
\test "limitation" ##[ #pitch -1 #]
\test ##[ c-\single \slurUp ( -1 #]
\test "limitation" ##[ c \single \slurUp ( -1 #]

%% end test.

#(read-hash-extend #\[ #f) %{ ] %}
-- 
David Kastrup

reply via email to

[Prev in Thread] Current Thread [Next in Thread]