2 #(use-modules (srfi srfi-13)
8 #(use-modules (scm display-lily))
9 #(memoize-clef-names supported-clefs)
10 #(define (parse-lily-and-compute-lily-string chr port)
11 (let ((lily-string (call-with-output-string
13 (do ((c (read-char port) (read-char port)))
15 (char=? (peek-char port) #\]))
18 `(let* ((parser-clone (ly:parser-clone parser))
19 (input-str (string-trim-both ,lily-string))
20 (music (ly:parse-string-expression parser-clone input-str))
21 (result-str (string-trim-both (music->lily-string music parser-clone))))
22 (cons input-str result-str))))
24 #(read-hash-extend #\[ parse-lily-and-compute-lily-string) %{ ] %}
26 #(define (lily-string->markup str)
27 (make-column-markup (string-split str #\NewLine)))
29 #(define test-function
30 (let ((test-number 0))
31 (lambda (parser location result-info strings)
32 (let ((input (car strings))
33 (output (cdr strings)))
34 (set! test-number (1+ test-number))
35 (if (not (equal? input output))
36 (ly:progress "Test ~a unequal: ~a. \nin = ~a\nout = ~a\n"
41 (make-music 'SequentialMusic 'void #t)))))
44 #(define-music-function (parser location result-info strings) (string? pair?)
45 (test-function parser location result-info strings))
51 texidoc = "This is a test of the display-lily-music unit. Problems are reported on the
56 \test "" ##[ { { a b } { c d } } #] % SequentialMusic
57 \test "" ##[ << { a b } { c d } >> #] % SimultaneousMusic
58 \test "" ##[ << { a b } \\ { c d } >> #] % VoiceSeparator
61 \test "" ##[ { ceses ces c cis cisis } #] % NoteEvent
62 \test "" ##[ { deses des d dis disis } #]
63 \test "" ##[ { eeses ees e eis eisis } #]
64 \test "" ##[ { feses fes f fis fisis } #]
65 \test "" ##[ { geses ges g gis gisis } #]
66 \test "" ##[ { aeses aes a ais aisis } #]
67 \test "" ##[ { beses bes b bis bisis } #]
68 \test "" ##[ { c,, d' } #]
69 \test "" ##[ { c' d'=' } #]
70 \test "" ##[ { c! c? } #]
71 \test "" ##[ r1.*4/3 #] % RestEvent
72 \test "" ##[ c1\rest #] % RestEvent
73 \test "" ##[ s2..*3/4 #] % SkipEvent
74 \test "" ##[ R1.*2/3 #] % MultiMeasureRestMusicGroup, MultiMeasureRestEvent
75 \test "" ##[ \skip 2.*3/4 #] % SkipMusic
76 \test "" ##[ < c\1 e\3 >4.*3/4-. #] % EventChord, NoteEvent, StringNumberEvent, ArticulationEvent
77 \test "" ##[ < c-1\4 >8 #]
78 \test "NOT A BUG" ##[ { < c e g c' > q8-. } #] % RepeatedChord
81 \test "" ##[ { \tag #'foo { c4 d } } #]
82 \test "" ##[ c-\tag #'foo -\tag #'baz -^ -. #]
85 \test "" ##[ { \grace c8 d2 } #] % GraceMusic
86 \test "" ##[ { \appoggiatura c8 d2 } #]
87 \test "" ##[ { \acciaccatura c8 d2 } #]
88 \test "" ##[ { c1 \afterGrace { b,16 c } d2 } #]
91 \test "" ##[ { \makeClusters { c4 g } } #] % ClusterNoteEvent
94 \test "" ##[ \figures { < 6 > } #] % BassFigureEvent
95 \test "" ##[ \figuremode { < 1-- 3- > < 2+ 4++ > < _! 7! > } #]
96 \test "" ##[ \figuremode { < [6 > < 5] > } #]
99 \test "" ##[ \lyrics { a b } #]
100 \test "" ##[ \lyricmode { a -- b } #] % HyphenEvent
101 \test "" ##[ \lyricmode { a __ b } #] % ExtenderEvent
102 \test "" ##[ \lyricmode { "a " } #] % LyricEvent
103 \test "" ##[ \lyricsto "foo" { bla bla } #] % LyricCombineMusic
104 \test "" ##[ { { c d }
105 \addlyrics { bla bla } } #]
108 \test "" ##[ \drums { hihat } #]
109 \test "" ##[ \drummode { hihat4.*3/4 } #]
112 \test "" ##[ c4 ~ #] % TieEvent
113 \test "" ##[ c\noBeam #] % BeamForbidEvent
114 \test "" ##[ c\1 #] % StringNumberEvent
115 \test "" ##[ { c: c:1 } #] % TremoloEvent
116 \test "" ##[ { c-^ c^^ c_^ } #] % ArticulationEvent
117 \test "" ##[ { c-+ c^+ c_+ } #]
118 \test "" ##[ { c-- c^- c_- } #]
119 \test "" ##[ { c-| c^| c_| } #]
120 \test "" ##[ { c-> c^> c_> } #]
121 \test "" ##[ { c-. c^. c_. } #]
122 \test "" ##[ { c-_ c^_ c__ } #]
123 \test "" ##[ { c-\trill c^\trill c_\trill } #]
124 \test "" ##[ { c-1 c^2 c_3 } #] % FingerEvent
125 \test "" ##[ { c-"foo" c^"foo" c_"foo" } #] % TextScriptEvent
126 \test "" ##[ { R1*4-"foo" R^"foo" R_"foo" } #] % MultiMeasureTextEvent
127 \test "" ##[ { < c\harmonic >4 < c e\harmonic > } #] % HarmonicEvent
128 \test "" ##[ { c-\glissando c^\glissando c_\glissando } #] % GlissandoEvent
129 \test "" ##[ { c-\arpeggio c^\arpeggio c_\arpeggio } #] % ArpeggioEvent
130 \test "" ##[ { c\p c^\ff c_\sfz } #] % AbsoluteDynamicEvent
131 \test "" ##[ { c[ c] c^[ c^] c_[ c_] } #] % BeamEvent
132 \test "" ##[ { c( c) c^( c^) c_( c_) } #] % SlurEvent
133 \test "" ##[ { c\< c\! c^\< c^\! c_\< c_\! } #] % CrescendoEvent
134 \test "" ##[ { c\> c\! c^\> c^\! c_\> c_\! } #] % DecrescendoEvent
135 \test "" ##[ { c\episemInitium c\episemFinis } #] % EpisemaEvent
136 \test "" ##[ { c\( c\) c^\( c^\) c_\( c_\) } #] % PhrasingSlurEvent
137 \test "" ##[ { c\sustainOn c\sustainOff } #] % SustainEvent
138 \test "" ##[ { c\sostenutoOn c\sostenutoOff } #] % SostenutoEvent
139 \test "" ##[ \melisma #]
140 \test "" ##[ \melismaEnd #]
141 \test "" ##[ { c\startTextSpan c\stopTextSpan } #] % TextSpanEvent
142 \test "" ##[ { c\startTrillSpan c\stopTrillSpan } #] % TrillSpanEvent
143 \test "" ##[ { c \startStaff c \stopStaff } #] % StaffSpanEvent
144 \test "" ##[ { c\startGroup c\stopGroup c^\startGroup c^\stopGroup c_\startGroup c_\stopGroup } #] % NoteGroupingEvent
145 \test "" ##[ { c\unaCorda c\treCorde } #] % UnaCordaEvent
146 \test "" ##[ \breathe #]
147 \test "" ##[ { c \[ c \] } #] % LigatureEvent
148 \test "" ##[ \~ #] % PesOrFlexaEvent
149 \test "" ##[ { c-\bendAfter #3 } #] % BendAfterEvent
150 \test "" ##[ < c-\rightHandFinger #1 > #] % StrokeFingerEvent
152 \test "" ##[ \break #]
153 \test "" ##[ \noBreak #]
154 \test "" ##[ \pageBreak #]
155 \test "" ##[ \noPageBreak #]
156 \test "" ##[ \pageTurn #]
157 \test "" ##[ \noPageTurn #]
160 \test "" ##[ \octaveCheck a' #] % RelativeOctaveCheck
161 \test "" ##[ | #] % BarCheck
164 \test "" ##[ \mark \default #] % MarkEvent
165 \test "" ##[ \mark "Allegro" #]
166 \test "" ##[ \tempo 4 = 120 #] % MetronomeChangeEvent
167 \test "" ##[ \tempo 4 = 108 ~ 116 #]
168 \test "" ##[ \tempo "Allegro" 4 = 132 #]
169 \test "" ##[ \tempo "Andante" #]
171 %% key, time, clef, bar
172 \test "" ##[ \key \default #] % KeyChangeEvent
173 \test "" ##[ \key e \minor #]
174 \test "" ##[ \clef "bass" #]
175 \test "" ##[ \clef "french^2" #]
176 \test "" ##[ \clef "alto_3" #]
177 \test "" ##[ \time 2/4 #]
178 \test "" ##[ #(set-time-signature 5 8 '(3 2)) #]
179 \test "" ##[ \bar "|." #]
182 \test "" ##[ \autochange { c d } #] % AutoChangeMusic
183 \test "" ##[ { \change Staff = "up" { c d } } #] % ContextChange
186 \test "" ##[ \times 2/3 { c8 d e } #] % TimeScaledMusic
187 \test "" ##[ \times 4/6 { c16 d e f g a } #]
189 %% \relative and \tranpose
190 \test #"NOT A BUG" ##[ \relative c' { c b } #] % RelativeOctaveMusic
191 \test #"NOT A BUG" ##[ \transpose c d { c d } #] % TransposedMusic
194 \test "" ##[ \repeat volta 2 { c d } #] % VoltaRepeatedMusic
195 \test "" ##[ \repeat unfold 2 { c d } #] % UnfoldedRepeatedMusic
196 \test "" ##[ \repeat percent 2 { c d } #] % PercentRepeatedMusic
197 \test "" ##[ \repeat tremolo 4 { c16 d } #] % TremoloRepeatedMusic
198 \test "" ##[ \repeat volta 2 { c4 d } \alternative { { c d } { e f } } #] %
201 \test "" ##[ \new Staff { c d } #] % ContextSpeccedMusic
202 \test "" ##[ \new Staff = "up" { c d } #] % ContextSpeccedMusic
203 \test "" ##[ \context Staff { c d } #]
204 \test "" ##[ \context Staff = "up" { c d } #]
207 \consists "Timing_engraver"
208 \remove "Clef_engraver"
210 %% Context properties
211 \test "" ##[ \once \set Score . skipBars = ##t #] % PropertySet
212 \test "" ##[ \set autoBeaming = ##f #]
213 \test "" ##[ \unset Score . skipBars #] % PropertyUnset
214 \test "" ##[ \unset autoBeaming #]
216 \test "" ##[ \override Staff . Stem #'thickness = #4.0 #] % OverrideProperty
217 \test "" ##[ \once \override Beam #'beam-thickness = #0.6 #]
218 \test "" ##[ \revert Staff . Stem #'thickness #] % RevertProperty
219 \test "" ##[ \revert Beam #'beam-thickness #]
220 \test "NOT A BUG" ##[ \oneVoice #] % resetting a bunch of properties
221 \test "" ##[ \override StaffGrouper #'(staff-staff-spacing basic-distance) = #7 #] % nested properties
222 \test "" ##[ \revert StaffGrouper #'(staff-staff-spacing basic-distance) #] % nested properties
225 \test "" ##[ \applyOutput #'Foo #(lambda (arg) (list)) #]
227 \test "" ##[ \applyContext #(lambda (arg) (list)) #]
230 \test "" ##[ \partial 2 #]
231 \test "" ##[ \partial 8. #]
232 \test "" ##[ \partial 4*2/3 #]
235 \test "" ##[ \partcombine { c e }
236 { d f } #] % PartCombineMusic UnrelativableMusic
239 \test "" ##[ \cueDuring #"foo" #1 { c d } #]
240 \test "" ##[ \quoteDuring #"foo" { c d } #]
243 \test "" ##[ \ottava #1 #] % OttavaMusic
246 \test "" ##[ < \tweak #'duration-log #2 c > #]
247 \test "" ##[ < c \tweak #'transparent ##t e > #]
248 \test "" ##[ < \tweak #'color #'(1.0 0.0 0.0) \tweak #'duration-log #2 c > #]
249 \test "" ##[ c-\tweak #'font-size #3 -> #]
253 #(read-hash-extend #\[ #f) %{ ] %}