lilypond-devel
[Top][All Lists]
Advanced

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

Re: Add regtest for issue 5181 (issue 327470043 by address@hidden)


From: dak
Subject: Re: Add regtest for issue 5181 (issue 327470043 by address@hidden)
Date: Mon, 25 Sep 2017 14:53:05 -0700

Reviewers: carl.d.sorensen_gmail.com, thomasmorley651,

Message:
On 2017/09/25 21:28:50, thomasmorley651 wrote:
Very nice, i.e LGTM

Not sure whether this should be reflected by a reg-test, but currently
there is
no case in it triggering the warning like:

warns = {
   \override NoteHead.color = #red
   c'1 d'
   \revert NoteHead.color
}
{ \warns -1 e' }


Touché.  I was not sure about whether or not the behavior and warning
for << {c'} -1 >> should be retained.  But your case looks pretty bad.
I mean, sure, one could skip backwards over unusable music expressions
as long as their length amounted to zero...  But it seems like
inviting trouble.

And there are cases which will probably never work, like:

fails = {
   d'-\tweak color #red
      %% with or without \etc
      \etc
}

{ \fails -1 e' }

Ugh.  That's another of those "what do you even think \etc is" cases.
Basically you need to come up with a reasonable definition of the
expression

{ ... \etc }

first.  I mean, the syntax does not yet seem taken so that does not
seem impossible but it may still end up being tricky.

Not sure if we should mention it in the docs at all, or in "Known
issues and warnings" or elsewhere ...?

So far I think it's more a case of reviewing "Known issues and
warnings" for stuff that is no longer an issue.  I don't think that we
have rigidly defined the limits of where you could place post-events,
but we may have warned people off a few things.


Description:
Add regtest for issue 5181


Also contains:

Define ly:music-error

Please review this at https://codereview.appspot.com/327470043/

Affected files (+67, -0 lines):
  A input/regression/added-post-event-test.ly
  M scm/music-functions.scm


Index: input/regression/added-post-event-test.ly
diff --git a/input/regression/added-post-event-test.ly b/input/regression/added-post-event-test.ly
new file mode 100644
index 0000000000000000000000000000000000000000..8f637438d5a435c1e58eb9fe4c2345cb3e519b32
--- /dev/null
+++ b/input/regression/added-post-event-test.ly
@@ -0,0 +1,63 @@
+\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
+%%%
+
+testIt =
+#(define-void-function (harmless music) ((boolean?) ly:music?)
+   ;; We check whether there is sequential music with a single
+   ;; expression that has the location of its single element basically
+   ;; at the end of the expression:
+   ;;
+   ;; That's when the expression has been combined immediately at
+   ;; parse time and not in a second sweep
+   (define (contained? m p)
+     (let ((m-loc (ly:input-both-locations (ly:music-property m 'origin)))
+           (p-loc (ly:input-both-locations (ly:music-property p 'origin))))
+       (and (string= (first m-loc) (first p-loc))
+            (= (fourth m-loc) (fourth p-loc))
+            (>= (fifth m-loc) (fifth p-loc)))))
+   (let* ((musl (and (music-is-of-type? music 'sequential-music)
+                     (ly:music-property music 'elements)))
+          (muse (and (pair? musl) (not (pair? (cdr musl))) (car musl)))
+          (badpost (and muse
+                        (find (lambda (m) (not (contained? muse m)))
+                              (extract-typed-music muse 'post-event)))))
+     (cond ((not muse)
+ (ly:music-error music (_ "expected single-element sequential expression")))
+           (badpost
+            (if harmless
+                (ly:music-message badpost (_ "late post-event, expected"))
+ (ly:music-warning badpost (_ "late post-event, unexpected"))))
+           (else
+            (if harmless
+ (ly:music-warning muse (_ "no late post-event, unexpected")))))))
+
+pitch = c'
+note = c'4
+chord = <c' g'>
+lyr = \lyricmode { two words }
+
+\testIt ##t { \note -1 }
+\testIt ##t { $note -1 }
+\testIt ##t { \chord -1 }
+\testIt { { \note -1 } }
+\testIt ##t { { \note -1 } -2 }
+\testIt { < \note -1 g' > -2 }
+\testIt { { \chord -1 } }
+\testIt { $pitch -1 }
+\testIt { c-\single \slurUp ( -1 }
+\testIt ##t { c \single \slurUp ( -1 }
+\testIt ##t \lyricmode { \lyr __ }
+\testIt ##t \lyricmode { \lyr -- }
+
+%% end test.
Index: scm/music-functions.scm
diff --git a/scm/music-functions.scm b/scm/music-functions.scm
index 5bbd07ea8fae1ade4bffe1067e9d7faf6b213d69..ff62c17c017d285b377b05d77716879cb61a92f7 100644
--- a/scm/music-functions.scm
+++ b/scm/music-functions.scm
@@ -1087,6 +1087,10 @@ actually fully cloned."
         (apply ly:input-warning ip msg rest)
         (apply ly:warning msg rest))))

+(define-public (ly:music-error music msg . rest)
+  (ly:parser-error (apply format #f msg rest)
+                   (ly:music-property music 'origin)))
+
 (define-public (ly:event-warning event msg . rest)
   (let ((ip (ly:event-property event 'origin)))
     (if (ly:input-location? ip)



reply via email to

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