Skip to content

Commit

Permalink
Merge pull request #131 from hpi-swa-teaching/feat/123-testing-3
Browse files Browse the repository at this point in the history
Rewrite tests
  • Loading branch information
rdunker committed Jul 12, 2021
2 parents 0beb9cc + 53881c3 commit af4ff90
Show file tree
Hide file tree
Showing 29 changed files with 384 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
beams & bows
drawBeam
self setupBeamVariables.
(self ignoreBeam or: [self isPause]) ifFalse: [
self addNotesToBeam: self position: 4.0.
(self beam size ~= 1 and: [self note isEighthOrShorter]) ifTrue: [
(MNBeamDrawer canvas: self partCanvas notes: self beam reverse) draw]].
(self beam size ~= 1 and: [self note isEighthOrShorter]) ifTrue: [
(MNBeamDrawer canvas: self partCanvas notes: self beam reverse) draw]].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
beams & bows
setupBeamVariables
(self ignoreBeam or: [self isPause]) ifFalse: [
self addNotesToBeam: self position: 4.0].
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"beam:" : "NH 6/27/2021 18:29",
"checkForMultiObjects" : "OS 7/11/2021 19:02",
"clickedMessage" : "RAD 6/11/2021 17:34",
"drawBeam" : "OS 7/1/2021 22:41",
"drawBeam" : "RAD 7/11/2021 16:13",
"drawBowTo:" : "OS 7/11/2021 13:06",
"drawOn:" : "OS 7/11/2021 19:05",
"drawTriole" : "OS 7/9/2021 17:15",
Expand All @@ -28,6 +28,7 @@
"noteLayout" : "OS 7/11/2021 19:03",
"noteLayout:" : "mgjm 5/25/2019 19:50",
"partCanvas" : "RAD 6/11/2021 17:35",
"setupBeamVariables" : "RAD 7/11/2021 16:12",
"shouldAddToBeam:position:" : "OS 7/4/2021 10:40",
"shouldAddToTriole:position:" : "OS 7/4/2021 10:40",
"triole" : "OS 7/4/2021 10:48",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
accessing
isNote
^ self isKindOf: MNNoteMorph
^ self isKindOf: MNNoteMorph
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"findNextTieStop" : "OS 6/10/2021 18:32",
"handlesMouseDown:" : "MP 5/20/2021 19:50",
"initialize" : "MP 5/20/2021 19:53",
"isNote" : "NH 6/27/2021 20:15",
"isNote" : "RAD 7/11/2021 15:24",
"lastSymbol" : "NH 6/18/2021 15:42",
"leftSibling" : "OS 6/17/2021 21:14",
"measureMorph" : "MP 5/28/2021 17:23",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests
testDynamics
| context |

context := MNContext new.

context addNote: self createC4.
context setDynamics: 'ff'.
self assert: (context lastNote dynamics = 'ff').
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
tests
testPrelude
| context |

context := MNContext new.

context addNote: self createC4.
context prelude.
context addNote: self createC4.
context addNote: self createC4.
context addNote: self createC4.

self assert: (context measure isAfterPrelude = true).
self assert: (context part measures first isAfterPrelude = false).
self assert: (context measure isPrelude = false).
self assert: (context part measures first isPrelude = true).
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
"testAddC4Twice" : "mgjm 6/19/2019 22:04",
"testAddTies" : "OS 5/16/2021 21:07",
"testAddTriplets" : "OS 7/11/2021 19:24",
"testEmptyContext" : "mgjm 6/19/2019 21:56" } }
"testDynamics" : "RAD 7/11/2021 15:15",
"testEmptyContext" : "mgjm 6/19/2019 21:56",
"testPrelude" : "RAD 7/11/2021 15:14" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests
testMethodCode
| editor |

editor := MNEditor new.
editor updateContents: 'c4/8.'.
self assert: (editor methodCodePrefix = ('DoIt', String cr)).
self assert: (editor methodCode = ('DoIt', String cr, 'c4/8.')).
self assert: ((editor statementMethodCode: 'Method not understood') = ('DoIt', String cr, 'Method not understood')).
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tests
testStatements
| editor |

editor := MNEditor new.
editor updateContents: '"Comment"c1/4.2 timesRepeat: [ {c4 . d4 . e4 . f4} / 4 ].'.
self assert: ((editor statementAt: 1) = '"Comment"').
self assert: ((editor statementAt: 2) = 'c1/4.').
self assert: ((editor statementAt: 3) = '2 timesRepeat: [ {c4 . d4 . e4 . f4} / 4 ].').

editor updateContents: '|var| var:=c1/4.2 timesRepeat: [var].'.
self assert: ((editor localVariablesStatement: 'var:=c1/4.') = '| var |var :=c1/4.^ ((Dictionary new) at: ''var'' put: var; yourself)').
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"testDoItEnvironment" : "RAD 7/3/2021 12:21",
"testLocalVariableStatement" : "RAD 7/3/2021 12:21",
"testMenuItems" : "RAD 7/3/2021 12:21",
"testMethodCode" : "RAD 7/11/2021 15:06",
"testOpenEditor" : "RAD 7/3/2021 12:21",
"testOpenEditorClass" : "mgjm 7/5/2019 20:44",
"testOpenPreview" : "RAD 7/3/2021 12:21",
"testSmuflFontDisplay" : "RAD 7/3/2021 12:21",
"testStatementMapping" : "RAD 7/3/2021 12:21",
"testStatements" : "RAD 7/11/2021 15:07",
"testTextContents" : "RAD 7/3/2021 12:21" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fixtures
createEighth
^ MNNote new
duration: 1/8;
addPitch: MNPitch new;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixtures
hiddenCanvas
^ self currentWorld canvas copyClipRect: (0@0 corner: 0@0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
tests
testBeamSixNotes
"Ignore while linting"
| measure measureMorph note1 note2 note3 note4 note5 note6 |

note1 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note2 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note3 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note4 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note5 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note6 := self createNoteWithDuration: (1/8) step: $c octave: 4.

measure := MNMeasure new
addNote: note1 note;
addNote: note2 note;
addNote: note3 note;
addNote: note4 note;
addNote: note5 note;
addNote: note6 note;
yourself.

measureMorph := MNMeasureMorph measure: measure.
measureMorph addMorph: note6.
measureMorph addMorph: note5.
measureMorph addMorph: note4.
measureMorph addMorph: note3.
measureMorph addMorph: note2.
measureMorph addMorph: note1.

note6 setupBeamVariables.
note5 setupBeamVariables.
note4 setupBeamVariables.
note3 setupBeamVariables.
note2 setupBeamVariables.
note1 setupBeamVariables.

self assert: (note1 beam size = 1).
self assert: (note2 beam size = 2).
self assert: (note3 beam size = 1).
self assert: (note4 beam size = 1).
self assert: (note5 beam size = 1).
self assert: (note6 beam size = 4).

self assert: (note2 beam second = note1).
self assert: (note6 beam second = note5).
self assert: (note6 beam third = note4).
self assert: (note6 beam fourth = note3).
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
tests
testBeamThreeNotes
"Ignore while linting"
| measure measureMorph note1 note2 note3 |

note1 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note2 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note3 := self createNoteWithDuration: (1/8) step: $c octave: 4.

measure := MNMeasure new
addNote: note1 note;
addNote: note2 note;
addNote: note3 note;
yourself.

measureMorph := MNMeasureMorph measure: measure.
measureMorph addMorph: note3.
measureMorph addMorph: note2.
measureMorph addMorph: note1.

note3 setupBeamVariables.
note2 setupBeamVariables.
note1 setupBeamVariables.

self assert: (note1 beam size = 1).
self assert: (note2 beam size = 1).
self assert: (note3 beam size = 3).

self assert: (note1 beam first = note1).
self assert: (note2 beam first = note2).
self assert: (note3 beam first = note3).
self assert: (note3 beam second = note2).
self assert: (note3 beam third = note1).
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tests
testDiagonalBeam
"Ignore while linting"
| beamDrawer measure measureMorph note1 note2 note3 |

beamDrawer := MNBeamDrawer new.
note1 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note2 := self createNoteWithDuration: (1/8) step: $d octave: 4.
note3 := self createNoteWithDuration: (1/8) step: $e octave: 4.

measure := MNMeasure new
addNote: note1 note;
addNote: note2 note;
addNote: note3 note;
yourself.

measureMorph := MNMeasureMorph measure: measure.
measureMorph addMorph: note3.
measureMorph addMorph: note2.
measureMorph addMorph: note1.

note3 setupBeamVariables.
note2 setupBeamVariables.
note1 setupBeamVariables.

beamDrawer notes: note3 beam reverse.

self assert: (beamDrawer isDiagonalOrSamePitch=true).

self assert: (note1 noteLayout stemLength = note2 noteLayout stemLength).
self assert: (note2 noteLayout stemLength = note3 noteLayout stemLength).
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
tests
testIgnoreBeamEightNotes
"Ignore while linting"
| measure measureMorph note1 note2 note3 note4 note5 note6 note7 note8 |

note1 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note2 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note3 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note4 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note5 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note6 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note7 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note8 := self createNoteWithDuration: (1/8) step: $c octave: 4.

measure := MNMeasure new
addNote: note1 note;
addNote: note2 note;
addNote: note3 note;
addNote: note4 note;
addNote: note5 note;
addNote: note6 note;
addNote: note7 note;
addNote: note8 note;
yourself.

measureMorph := MNMeasureMorph measure: measure.
measureMorph addMorph: note8.
measureMorph addMorph: note7.
measureMorph addMorph: note6.
measureMorph addMorph: note5.
measureMorph addMorph: note4.
measureMorph addMorph: note3.
measureMorph addMorph: note2.
measureMorph addMorph: note1.

note8 setupBeamVariables.
note7 setupBeamVariables.
note6 setupBeamVariables.
note5 setupBeamVariables.
note4 setupBeamVariables.
note3 setupBeamVariables.
note2 setupBeamVariables.
note1 setupBeamVariables.

self assert: (note1 ignoreBeam).
self assert: (note2 ignoreBeam).
self assert: (note3 ignoreBeam).
self assert: (note4 ignoreBeam=false).
self assert: (note5 ignoreBeam).
self assert: (note6 ignoreBeam).
self assert: (note7 ignoreBeam).
self assert: (note8 ignoreBeam=false).
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
tests
testIgnoreBeamSixNotes
"Ignore while linting"
| measure measureMorph note1 note2 note3 note4 note5 note6 |

note1 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note2 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note3 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note4 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note5 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note6 := self createNoteWithDuration: (1/8) step: $c octave: 4.

measure := MNMeasure new
addNote: note1 note;
addNote: note2 note;
addNote: note3 note;
addNote: note4 note;
addNote: note5 note;
addNote: note6 note;
yourself.

measureMorph := MNMeasureMorph measure: measure.
measureMorph addMorph: note6.
measureMorph addMorph: note5.
measureMorph addMorph: note4.
measureMorph addMorph: note3.
measureMorph addMorph: note2.
measureMorph addMorph: note1.

note6 setupBeamVariables.
note5 setupBeamVariables.
note4 setupBeamVariables.
note3 setupBeamVariables.
note2 setupBeamVariables.
note1 setupBeamVariables.

self assert: (note1 ignoreBeam).
self assert: (note2 ignoreBeam=false).
self assert: (note3 ignoreBeam).
self assert: (note4 ignoreBeam).
self assert: (note5 ignoreBeam).
self assert: (note6 ignoreBeam=false).
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
tests
testIgnoreBeamThreeNote
"Ignore while linting"
| measure measureMorph note1 note2 note3 |

note1 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note2 := self createNoteWithDuration: (1/8) step: $c octave: 4.
note3 := self createNoteWithDuration: (1/8) step: $c octave: 4.

measure := MNMeasure new
addNote: note1 note;
addNote: note2 note;
addNote: note3 note;
yourself.

measureMorph := MNMeasureMorph measure: measure.
measureMorph addMorph: note3.
measureMorph addMorph: note2.
measureMorph addMorph: note1.

note3 setupBeamVariables.
note2 setupBeamVariables.
note1 setupBeamVariables.

self assert: (note1 ignoreBeam).
self assert: (note2 ignoreBeam).
self assert: (note3 ignoreBeam=false).
Loading

0 comments on commit af4ff90

Please sign in to comment.