]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/optional-args-backup.ly
input/regression/optional-args-backup.ly: Test backing up of optional argument parts.
[lilypond.git] / input / regression / optional-args-backup.ly
1 \version "2.15.17"
2
3 \header{
4   texidoc= "Test backup of predicate-based optional music function arguments.
5
6 Unit expressions like @code{3\cm} can't be parsed as optional
7 arguments since they would require lookahead after @code{3}.  However,
8 if @code{3} gets rejected as an optional argument based on evaluating
9 its predicate, it should still be able to participate as part of a unit
10 expression in a following mandatory argument."
11 }
12
13 \layout { ragged-right = ##t }
14
15 test=#(define-void-function (parser location expect . rest)
16        (list? (string? "def1") (integer? "def2") (number-pair? "def3") integer?)
17        (if (not (equal? expect rest))
18         (ly:parser-error parser
19          (format #f "Expected ~a, got ~a.\n" expect rest)
20          location)))
21
22 twice=2
23
24 \test #'("a" 3 (3 . 4) 8)        "a" 3 3/4 4\twice
25 \test #'("a" 3 "def3" 8)         "a" 3 4\twice
26 \test #'("a" 4 "def3" 2)         "a" 4\twice
27 \test #'("def1" "def2" "def3" 8) 4\twice