]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/optional-args-backup.ly
Imported Upstream version 2.19.45
[lilypond.git] / input / regression / optional-args-backup.ly
1 \version "2.19.22"
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 in one go since they would require lookahead after @code{3}.
8 The predicate is checked after @code{3}, and if it is suitable,
9 Lilypond commits to parsing as a unit number, and checks the result
10 again.  For the predicate @code{integer?} and @code{3\cm}, you would
11 actually get a syntax error (since the combination is no longer an
12 integer) rather than Lilypond trying to see @code{3\cm} as two
13 separate arguments."
14
15 }
16
17 \layout { ragged-right = ##t }
18
19 test=#(define-void-function (expect . rest)
20        (list? (string? "def1") (integer? "def2") (fraction? "def3") integer?)
21        (if (not (equal? expect rest))
22         (ly:parser-error
23          (format #f "Expected ~s, got ~s.\n" expect rest)
24          (*location*))))
25
26 twice=2
27
28 \test #'("x" 3 (3 . 4) 8)        x 3 3/4 4\twice
29 \test #'("x" 3 "def3" 8)         x 3 4\twice
30 \test #'("x" 8 "def3" 10)        x 4\twice 5\twice
31 \test #'("def1" "def2" "def3" 8) 4\twice