]> git.donarmstrong.com Git - lilypond.git/commitdiff
input/regression/optional-args-backup.ly: Test backing up of optional argument parts.
authorDavid Kastrup <dak@gnu.org>
Tue, 1 Nov 2011 10:57:41 +0000 (11:57 +0100)
committerDavid Kastrup <dak@gnu.org>
Tue, 8 Nov 2011 21:56:53 +0000 (22:56 +0100)
input/regression/optional-args-backup.ly [new file with mode: 0644]

diff --git a/input/regression/optional-args-backup.ly b/input/regression/optional-args-backup.ly
new file mode 100644 (file)
index 0000000..35dadf9
--- /dev/null
@@ -0,0 +1,27 @@
+\version "2.15.17"
+
+\header{
+  texidoc= "Test backup of predicate-based optional music function arguments.
+
+Unit expressions like @code{3\cm} can't be parsed as optional
+arguments since they would require lookahead after @code{3}.  However,
+if @code{3} gets rejected as an optional argument based on evaluating
+its predicate, it should still be able to participate as part of a unit
+expression in a following mandatory argument."
+}
+
+\layout { ragged-right = ##t }
+
+test=#(define-void-function (parser location expect . rest)
+       (list? (string? "def1") (integer? "def2") (number-pair? "def3") integer?)
+       (if (not (equal? expect rest))
+       (ly:parser-error parser
+        (format #f "Expected ~a, got ~a.\n" expect rest)
+        location)))
+
+twice=2
+
+\test #'("a" 3 (3 . 4) 8)        "a" 3 3/4 4\twice
+\test #'("a" 3 "def3" 8)         "a" 3 4\twice
+\test #'("a" 4 "def3" 2)         "a" 4\twice
+\test #'("def1" "def2" "def3" 8) 4\twice