-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from hpi-swa-teaching/feat/123-testing-3
Rewrite tests
- Loading branch information
Showing
29 changed files
with
384 additions
and
7 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
packages/MusicNotation-Graphics.package/MNNoteMorph.class/instance/drawBeam.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]]. |
4 changes: 4 additions & 0 deletions
4
packages/MusicNotation-Graphics.package/MNNoteMorph.class/instance/setupBeamVariables.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/MusicNotation-Graphics.package/MNSymbolMorph.class/instance/isNote.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
accessing | ||
isNote | ||
^ self isKindOf: MNNoteMorph | ||
^ self isKindOf: MNNoteMorph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/MusicNotation-Tests.package/MNContextTest.class/instance/testDynamics.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'). |
16 changes: 16 additions & 0 deletions
16
packages/MusicNotation-Tests.package/MNContextTest.class/instance/testPrelude.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/MusicNotation-Tests.package/MNEditorTest.class/instance/testMethodCode.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')). |
12 changes: 12 additions & 0 deletions
12
packages/MusicNotation-Tests.package/MNEditorTest.class/instance/testStatements.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)'). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/createEighth.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/hiddenCanvas.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
47 changes: 47 additions & 0 deletions
47
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/testBeamSixNotes.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
33 changes: 33 additions & 0 deletions
33
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/testBeamThreeNotes.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
31 changes: 31 additions & 0 deletions
31
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/testDiagonalBeam.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
52 changes: 52 additions & 0 deletions
52
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/testIgnoreBeamEightNotes.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
42 changes: 42 additions & 0 deletions
42
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/testIgnoreBeamSixNotes.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
27 changes: 27 additions & 0 deletions
27
packages/MusicNotation-Tests.package/MNNoteTest.class/instance/testIgnoreBeamThreeNote.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
Oops, something went wrong.