Skip to content

Commit

Permalink
Integrate elm-check
Browse files Browse the repository at this point in the history
  • Loading branch information
gkubisa committed Apr 26, 2016
1 parent e3960ba commit ad09b0a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Provides an efficient development workflow and a starting point for building Elm
- automated build of all application resources using [webpack](http://webpack.github.io/)
- Hot Module Replacement for the Elm code using [elm-hot-loader](https://github.com/fluxxu/elm-hot-loader)
- automatic re-execution of tests on source change for Elm and JavaScript code
- property based testing using [elm-check](https://github.com/NoRedInk/elm-check) for the Elm tests
- test coverage using [istanbul](https://github.com/gotwarlost/istanbul) for the JavaScript tests
- [Semantic UI](http://semantic-ui.com/) integration
- JavaScript code written in ES6, transpiled using [Babel](https://babeljs.io/)
- JavaScript linted using [eslint](http://eslint.org/)
Expand Down
3 changes: 2 additions & 1 deletion elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"exposed-modules": [],
"dependencies": {
"NoRedInk/elm-check": "3.0.0 <= v < 4.0.0",
"deadfoxygrandpa/elm-test": "3.1.0 <= v < 4.0.0",
"elm-lang/core": "3.0.0 <= v < 4.0.0",
"evancz/elm-effects": "2.0.1 <= v < 3.0.0",
Expand All @@ -18,4 +19,4 @@
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.16.0 <= v < 0.17.0"
}
}
20 changes: 17 additions & 3 deletions elm-test/App/SampleTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ module App.SampleTest

import App.Sample exposing (sum, product)
import ElmTest exposing (Test, test, suite, assertEqual)
import Check exposing (Claim, Evidence, claim, that, is, true, for, quickCheck)
import Check.Producer exposing (filter, tuple, int, float)
import Check.Test exposing (evidenceToTest)

testSuite : Test
testSuite =
suite "App.Sample"
[ suite "sum"
[ test "should return a sum of 2 numbers" <| assertEqual 8 (sum 3 5)
[ test "should return a sum of 2 Ints" <| assertEqual 8 (sum 3 5)
, test "should return a sum of 2 Floats" <| assertEqual -10.5 (sum -20.5 10)
]
, suite "product"
[ test "should return a product of 2 numbers" <| assertEqual 15 (product 3 5)
, evidenceToTest << quickCheck <| Check.suite "product"
[ claim "should multiply Ints"
`that` (\(a, b) -> product a b)
`is` (\(a, b) -> a * b)
`for` tuple (int, int)
, claim "should multiply Floats"
`that` (\(a, b) -> product a b)
`is` (\(a, b) -> a * b)
`for` tuple (float, float)
, claim "should be inverted by division with minimal imprecision"
`true` (\(a, b) -> abs (product a b / b - a) < 1e-10)
`for` (filter (\(a, b) -> b /= 0) (tuple (float, float)))
]
]

0 comments on commit ad09b0a

Please sign in to comment.