From b4ff85a2416e4b80deb9eef8329cd230ee4dc944 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Fri, 23 Sep 2011 19:38:38 +0200 Subject: [PATCH] optional-args.ly: regtest for optional arguments --- input/regression/optional-args.ly | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 input/regression/optional-args.ly diff --git a/input/regression/optional-args.ly b/input/regression/optional-args.ly new file mode 100644 index 0000000000..f4a88604e3 --- /dev/null +++ b/input/regression/optional-args.ly @@ -0,0 +1,33 @@ +\version "2.15.13" + +\header{ + texidoc= "Test optional music function arguments. +The output is nonsensical, but if you wrack your brain, +you'll figure it out. Remember that optional arguments +are matched left to right, and after the first non-match, +the rest is skipped." +} + +\layout { ragged-right = ##t } + +% Get following pitch into Scheme +pitch = #(define-scheme-function (parser location p) (ly:pitch?) p) +% The same with a duration +dur = #(define-scheme-function (parser location p) (ly:duration?) p) + +% Just like \relative, but defaulting to f as reference, making the +% first note of the music the same as if written as absolute pitch +ablative = +#(define-music-function (parser location ref music) + ((ly:pitch? #{ \pitch f #}) ly:music?) + #{ \relative $ref $music #}) + +% Let's take a duration and four pitches, defaulting to 2 c' d' e' +zap = +#(define-music-function (parser location dur a b c d) + ((ly:duration? #{ \dur 2 #}) (ly:pitch? #{ \pitch c' #}) + (ly:pitch? #{ \pitch d' #}) (ly:pitch? #{ \pitch e' #}) + ly:music?) #{ $a $dur $b $c ^\markup{!} $d #}) + +\new Voice { \relative c' e' \relative { e' } \ablative c' e' \ablative { e' } + \zap 8. c'' d'' {e''4..} \zap f''8 g'' \zap 4 a'' b'' c''' d'''2 } -- 2.39.5