%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************

#(ly:set-option 'eps-box-padding 3.000000)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}




% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "/lilypond-2.26.0/input/regression/optional-args-backup.ly"
\sourcefileline 0
\version "2.19.22"

\header{
  texidoc= "Test backup of predicate-based optional music function arguments.

Unit expressions like @code{3\cm} can't be parsed as optional
arguments in one go since they would require lookahead after @code{3}.
The predicate is checked after @code{3}, and if it is suitable,
Lilypond commits to parsing as a unit number, and checks the result
again.  For the predicate @code{integer?} and @code{3\cm}, you would
actually get a syntax error (since the combination is no longer an
integer) rather than Lilypond trying to see @code{3\cm} as two
separate arguments."

}

\layout { ragged-right = ##t }

test=#(define-void-function (expect . rest)
       (list? (string? "def1") (integer? "def2") (fraction? "def3") integer?)
       (if (not (equal? expect rest))
	(ly:parser-error
	 (format #f "Expected ~s, got ~s.\n" expect rest)
	 (*location*))))

twice=2

\test #'("x" 3 (3 . 4) 8)        x 3 3/4 4\twice
\test #'("x" 3 "def3" 8)         x 3 4\twice
\test #'("x" 8 "def3" 10)        x 4\twice 5\twice
\test #'("def1" "def2" "def3" 8) 4\twice



% ****************************************************************
% end ly snippet
% ****************************************************************
