]> git.donarmstrong.com Git - lilypond.git/blobdiff - input/regression/automatic-polyphony-context-id.ly
resolve merge
[lilypond.git] / input / regression / automatic-polyphony-context-id.ly
diff --git a/input/regression/automatic-polyphony-context-id.ly b/input/regression/automatic-polyphony-context-id.ly
new file mode 100644 (file)
index 0000000..a825222
--- /dev/null
@@ -0,0 +1,36 @@
+\version "2.14.0"
+
+\header {
+  texidoc = "The bottom-level contexts in polyphony shorthand are
+allocated a context id in order of creation, starting with
+@code{\"1\"}.
+This snippet will fail to compile if either voice has an invalid
+@code{context-id} string.
+"
+}
+
+assertContextId =
+#(define-music-function (parser location id) (string?)
+   (let ((music (make-music 'ApplyContext
+                            'procedure
+                            (lambda (ctx)
+                              (and
+                               (not (string=? (ly:context-id ctx) id))
+                               (ly:error "context-id mismatch found: expecting ~s, got ~s"
+                                         id
+                                         (ly:context-id ctx)))))))
+     music))
+
+\relative c'' {
+  <<
+    {
+      \assertContextId "1"
+      c4 d e2
+    }
+    \\
+    {
+      \assertContextId "2"
+      a,4 b c2
+    }
+  >>
+}