]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/automatic-polyphony-context-id.ly
a825222600af6f05eff90558de556b2e73de96a8
[lilypond.git] / input / regression / automatic-polyphony-context-id.ly
1 \version "2.14.0"
2
3 \header {
4   texidoc = "The bottom-level contexts in polyphony shorthand are
5 allocated a context id in order of creation, starting with
6 @code{\"1\"}.
7 This snippet will fail to compile if either voice has an invalid
8 @code{context-id} string.
9 "
10 }
11
12 assertContextId =
13 #(define-music-function (parser location id) (string?)
14    (let ((music (make-music 'ApplyContext
15                             'procedure
16                             (lambda (ctx)
17                               (and
18                                (not (string=? (ly:context-id ctx) id))
19                                (ly:error "context-id mismatch found: expecting ~s, got ~s"
20                                          id
21                                          (ly:context-id ctx)))))))
22      music))
23
24 \relative c'' {
25   <<
26     {
27       \assertContextId "1"
28       c4 d e2
29     }
30     \\
31     {
32       \assertContextId "2"
33       a,4 b c2
34     }
35   >>
36 }