Skip to content

Instantly share code, notes, and snippets.

View danigb's full-sized avatar

danigb danigb

  • InVideo
  • Seville, spain
View GitHub Profile
@danigb
danigb / run-tests.sh
Last active May 25, 2016 07:40
Run tests with elm
#!/bin/bash
mkdir -p tmp
rm tmp/run.js
elm-make test/TwelveToneTest.elm --output tmp/run.js
node tmp/run.js
@danigb
danigb / TwelveToneTest.elm
Last active May 25, 2016 08:15
Twelve Tone Test v1
import ElmTest exposing (..)
tests : Test
tests =
suite "Chapter 9: Etudes, Op. 3: Iteration, Rows and Sets"
[
test "noteToPc" (assertEqual 7 (noteToPc 55))
]
main =
@danigb
danigb / TwelveTone.elm
Last active May 25, 2016 08:15
Twelve Tone v1
module TwelveTone exposing (noteToPc)
type alias Note = Int
type alias Pc = Int
noteToPc : Note -> Pc
noteToPc note =
note % 12
@danigb
danigb / TwelveToneTest.elm
Last active May 25, 2016 08:17
Twelve Tone Test v2
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))
]
@danigb
danigb / Elm test pass output
Created May 23, 2016 20:00
Elm Test Passes
Success! Compiled 1 module.
Successfully generated tmp/run.js
1 suites run, containing 1 tests
All tests passed
test "listToPcs" (assertEqual [7,10,2,6] (listToPcs [55,58,62,66]))
import List exposing (map)
...
listToPcs : List(Note) -> List Pc
listToPcs notes =
map noteToPc notes
test "normalizedPcs" (assertEqual [0,3,7,11] (normalizedPcs [55,58,62,66]))
@danigb
danigb / TwelveTone.elm
Created May 25, 2016 08:23
normalizedPcs v1
import List exposing (map, head)
...
normalizedPcs : List(Note) -> List Pc
normalizedPcs notes =
let
first = head notes
in
map (\note -> noteToPc (note - first)) notes
@danigb
danigb / Test Output.txt
Last active May 25, 2016 08:28
Elm Test Output
-- 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