This file contains hidden or 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
| #!/bin/bash | |
| mkdir -p tmp | |
| rm tmp/run.js | |
| elm-make test/TwelveToneTest.elm --output tmp/run.js | |
| node tmp/run.js |
This file contains hidden or 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
| import ElmTest exposing (..) | |
| tests : Test | |
| tests = | |
| suite "Chapter 9: Etudes, Op. 3: Iteration, Rows and Sets" | |
| [ | |
| test "noteToPc" (assertEqual 7 (noteToPc 55)) | |
| ] | |
| main = |
This file contains hidden or 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
| module TwelveTone exposing (noteToPc) | |
| type alias Note = Int | |
| type alias Pc = Int | |
| noteToPc : Note -> Pc | |
| noteToPc note = | |
| note % 12 |
This file contains hidden or 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
| import ElmTest exposing (..) | |
| import TwelveTone exposing (..) | |
| tests : Test | |
| tests = | |
| suite "Chapter 9: Etudes, Op. 3: Iteration, Rows and Sets" | |
| [ | |
| test "noteToPc" (assertEqual 7 (noteToPc 55)) | |
| ] |
This file contains hidden or 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
| Success! Compiled 1 module. | |
| Successfully generated tmp/run.js | |
| 1 suites run, containing 1 tests | |
| All tests passed | |
This file contains hidden or 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
| test "listToPcs" (assertEqual [7,10,2,6] (listToPcs [55,58,62,66])) |
This file contains hidden or 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
| import List exposing (map) | |
| ... | |
| listToPcs : List(Note) -> List Pc | |
| listToPcs notes = | |
| map noteToPc notes |
This file contains hidden or 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
| test "normalizedPcs" (assertEqual [0,3,7,11] (normalizedPcs [55,58,62,66])) |
This file contains hidden or 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
| import List exposing (map, head) | |
| ... | |
| normalizedPcs : List(Note) -> List Pc | |
| normalizedPcs notes = | |
| let | |
| first = head notes | |
| in | |
| map (\note -> noteToPc (note - first)) notes |
This file contains hidden or 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
| -- TYPE MISMATCH ------------------------------------------ ./src/TwelveTone.elm | |
| The right argument of (-) is causing a type mismatch. | |
| 22| note - first) | |
| ^^^^^ | |
| (-) is expecting the right argument to be a: | |
| number |