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)))
30 #(define-void-function (parser location harmless strings)
32 (let ((input (car strings))
33 (output (cdr strings))
34 (result-info (or harmless "BUG")))
35 (if (not (equal? input output))
37 (ly:progress "Test unequal: ~a.\nin = ~a\nout = ~a\n"
38 harmless input output)
39 (ly:input-warning location "Test unequal: BUG.\nin = ~a\nout = ~a\n"
46 texidoc = "This is a test of the display-lily-music unit. Problems are reported on the
51 \test ##[ { { a b } { c d } } #] % SequentialMusic
52 \test ##[ << { a b } { c d } >> #] % SimultaneousMusic
53 \test ##[ << { a b } \\ { c d } >> #] % VoiceSeparator
56 \test ##[ { ceses ces c cis cisis } #] % NoteEvent
57 \test ##[ { deses des d dis disis } #]
58 \test ##[ { eeses ees e eis eisis } #]
59 \test ##[ { feses fes f fis fisis } #]
60 \test ##[ { geses ges g gis gisis } #]
61 \test ##[ { aeses aes a ais aisis } #]
62 \test ##[ { beses bes b bis bisis } #]
63 \test ##[ { c,, d' } #]
64 \test ##[ { c' d'=' } #]
65 \test ##[ { c! c? } #]
66 \test ##[ r1.*4/3 #] % RestEvent
67 \test ##[ c1\rest #] % RestEvent
68 \test ##[ s2..*3/4 #] % SkipEvent
69 \test ##[ R1.*2/3 #] % MultiMeasureRestMusicGroup, MultiMeasureRestEvent
70 \test ##[ \skip 2.*3/4 #] % SkipMusic
71 \test ##[ < c\1 e\3 >4.*3/4-. #] % EventChord, NoteEvent, StringNumberEvent, ArticulationEvent
72 \test ##[ < c-1\4 >8 #]
73 \test ##[ { < c e g c' >4 q8-. } #] % RepeatedChord
76 \test ##[ { \tag #'foo { c4 d } } #]
77 \test ##[ c-\tag #'foo -\tag #'baz -^-. #]
80 \test ##[ { \grace c8 d2 } #] % GraceMusic
81 \test ##[ { \appoggiatura c8 d2 } #]
82 \test ##[ { \acciaccatura c8 d2 } #]
83 \test ##[ { c1 \afterGrace { b,16 c } d2 } #]
86 \test ##[ { \makeClusters { c4 g } } #] % ClusterNoteEvent
89 \test ##[ \figures { < 6 > } #] % BassFigureEvent
90 \test ##[ \figuremode { < 1-- 3- > < 2+ 4++ > < _! 7! > } #]
91 \test ##[ \figuremode { < [6 > < 5] > } #]
94 \test ##[ \lyrics { a b } #]
95 \test ##[ \lyricmode { a -- b } #] % HyphenEvent
96 \test ##[ \lyricmode { a __ b } #] % ExtenderEvent
97 \test ##[ \lyricmode { "a " } #] % LyricEvent
98 \test ##[ \lyricsto "foo" { bla bla } #] % LyricCombineMusic
100 \addlyrics { bla bla } } #]
103 \test ##[ \drums { hihat } #]
104 \test ##[ \drummode { hihat4.*3/4 } #]
107 \test ##[ c4 ~ #] % TieEvent
108 \test ##[ c\noBeam #] % BeamForbidEvent
109 \test ##[ c\1 #] % StringNumberEvent
110 \test ##[ { c:8 c:1 } #] % TremoloEvent
111 \test ##[ { c-^ c^^ c_^ } #] % ArticulationEvent
112 \test ##[ { c-+ c^+ c_+ } #]
113 \test ##[ { c-- c^- c_- } #]
114 \test ##[ { c-! c^! c_! } #]
115 \test ##[ { c-> c^> c_> } #]
116 \test ##[ { c-. c^. c_. } #]
117 \test ##[ { c-_ c^_ c__ } #]
118 \test ##[ { c\trill c^\trill c_\trill } #]
119 \test ##[ { c-1 c^2 c_3 } #] % FingerEvent
120 \test ##[ { c-"foo" c^"foo" c_"foo" } #] % TextScriptEvent
121 \test ##[ { R1*4-"foo" R^"foo" R_"foo" } #] % MultiMeasureTextEvent
122 \test ##[ { < c\harmonic >4 < c e\harmonic > } #] % HarmonicEvent
123 \test ##[ { c\glissando c^\glissando c_\glissando } #] % GlissandoEvent
124 \test ##[ { c\arpeggio c^\arpeggio c_\arpeggio } #] % ArpeggioEvent
125 \test ##[ { c\p c^\ff c_\sfz } #] % AbsoluteDynamicEvent
126 \test ##[ { c[ c] c^[ c^] c_[ c_] } #] % BeamEvent
127 \test ##[ { c( c) c^( c^) c_( c_) } #] % SlurEvent
128 \test ##[ { c\< c\! c^\< c^\! c_\< c_\! } #] % CrescendoEvent
129 \test ##[ { c\> c\! c^\> c^\! c_\> c_\! } #] % DecrescendoEvent
130 \test ##[ { c\episemInitium c\episemFinis } #] % EpisemaEvent
131 \test ##[ { c\( c\) c^\( c^\) c_\( c_\) } #] % PhrasingSlurEvent
132 \test ##[ { c\sustainOn c\sustainOff } #] % SustainEvent
133 \test ##[ { c\sostenutoOn c\sostenutoOff } #] % SostenutoEvent
134 \test ##[ \melisma #]
135 \test ##[ \melismaEnd #]
136 \test ##[ { c\startTextSpan c\stopTextSpan } #] % TextSpanEvent
137 \test ##[ { c\startTrillSpan c\stopTrillSpan } #] % TrillSpanEvent
138 \test ##[ { c \startStaff c \stopStaff } #] % StaffSpanEvent
139 \test ##[ { c\startGroup c\stopGroup c^\startGroup c^\stopGroup c_\startGroup c_\stopGroup } #] % NoteGroupingEvent
140 \test ##[ { c\unaCorda c\treCorde } #] % UnaCordaEvent
141 \test ##[ \breathe #]
142 \test ##[ { c \[ c \] } #] % LigatureEvent
143 \test ##[ \~ #] % PesOrFlexaEvent
144 \test ##[ c\bendAfter #3 #] % BendAfterEvent
145 \test ##[ c\rightHandFinger #1 #] % StrokeFingerEvent
148 \test ##[ \noBreak #]
149 \test ##[ \pageBreak #]
150 \test ##[ \noPageBreak #]
151 \test ##[ \pageTurn #]
152 \test ##[ \noPageTurn #]
155 \test ##[ \octaveCheck a' #] % RelativeOctaveCheck
156 \test ##[ | #] % BarCheck
159 \test ##[ \mark \default #] % MarkEvent
160 \test ##[ \mark "Allegro" #]
161 \test ##[ \tempo 4 = 120 #] % MetronomeChangeEvent
162 \test ##[ \tempo 4 = 108 - 116 #]
163 \test ##[ \tempo "Allegro" 4 = 132 #]
164 \test ##[ \tempo "Andante" #]
166 %% key, time, clef, bar
167 \test ##[ \key \default #] % KeyChangeEvent
168 \test ##[ \key e \minor #]
169 \test ##[ \clef "bass" #]
170 \test ##[ \clef "french^2" #]
171 \test ##[ \clef "treble_[8]" #]
172 \test ##[ \clef "bass^(15)" #]
173 \test ##[ \clef "alto_3" #]
174 \test ##[ \time 2/4 #]
175 \test ##[ \time #'(3 2) 5/8 #]
176 \test ##[ \bar "|." #]
179 \test ##[ \autochange { c d } #] % AutoChangeMusic
180 \test ##[ { \change Staff = "up" { c d } } #] % ContextChange
183 \test ##[ \tuplet 3/2 { c8 d e } #] % TimeScaledMusic
184 \test ##[ \tuplet 6/4 { c16 d e f g a } #]
185 \test ##[ \tuplet 3/2 { c4 d e \tuplet 5/2 { f4 e d2 d4 } c4 } #]
186 \test ##[ \tuplet 3/2 2 { c4 d e \tuplet 5/2 2 { f4 e d2 d4 } c4 } #]
189 \test ##[ { 4 4 8 \tuplet 3/2 { 8[ 16] } 16 } #]
191 %% \relative and \tranpose
192 \test #"NOT A BUG" ##[ \relative c' { c b } #] % RelativeOctaveMusic
193 \test #"NOT A BUG" ##[ \transpose c d { c d } #] % TransposedMusic
196 \test ##[ \repeat volta 2 { c d } #] % VoltaRepeatedMusic
197 \test ##[ \repeat unfold 2 { c d } #] % UnfoldedRepeatedMusic
198 \test ##[ \repeat percent 2 { c d } #] % PercentRepeatedMusic
199 \test ##[ \repeat tremolo 4 { c16 d } #] % TremoloRepeatedMusic
200 \test ##[ \repeat tremolo 7 { c''32 b' } #]
201 \test ##[ \repeat tremolo 15 { c''16 b' } #]
202 \test ##[ \repeat volta 2 { c4 d } \alternative { { c d } { e f } } #] %
205 \test ##[ \new Staff { c d } #] % ContextSpeccedMusic
206 \test ##[ \new Staff = "up" { c d } #] % ContextSpeccedMusic
207 \test ##[ \context Staff { c d } #]
208 \test ##[ \context Staff = "up" { c d } #]
211 \consists "Timing_engraver"
212 \remove "Clef_engraver"
214 %% Context properties
215 \test ##[ \once \set Score . skipBars = ##t #] % PropertySet
216 \test ##[ \set autoBeaming = ##f #]
217 \test ##[ \unset Score . skipBars #] % PropertyUnset
218 \test ##[ \unset autoBeaming #]
220 \test ##[ \override Staff.Stem.thickness = #4.0 #] % OverrideProperty
221 \test ##[ \once \override Beam.beam-thickness = #0.6 #]
222 \test ##[ \revert Staff.Stem.thickness #] % RevertProperty
223 \test ##[ \revert Beam.beam-thickness #]
224 \test "NOT A BUG" ##[ \oneVoice #] % resetting a bunch of properties
225 \test ##[ \override StaffGrouper.staff-staff-spacing.basic-distance = #7 #] % nested properties
226 \test ##[ \revert StaffGrouper.staff-staff-spacing.basic-distance #] % nested properties
229 \test ##[ \applyOutput #'Foo #(lambda (arg) (list)) #]
231 \test ##[ \applyContext #(lambda (arg) (list)) #]
234 \test ##[ \partial 2 #]
235 \test ##[ \partial 8. #]
236 \test ##[ \partial 4*2/3 #]
239 \test ##[ \partcombine { c e }
240 { d f } #] % PartCombineMusic UnrelativableMusic
243 \test ##[ \cueDuring #"foo" #1 { c d } #]
244 \test ##[ \quoteDuring #"foo" { c d } #]
247 \test ##[ \ottava #1 #] % OttavaMusic
250 \test ##[ < \tweak duration-log #2 c > #]
251 \test ##[ < c \tweak transparent ##t e > #]
252 \test ##[ < \tweak color #'(1.0 0.0 0.0) \tweak duration-log #2 c > #]
253 \test ##[ c-\tweak font-size #3 -> #]
254 \test ##[ < \tweak Accidental.color #'(1.0 0.0 0.0) cis eis g > #]
258 #(read-hash-extend #\[ #f) %{ ] %}