File tree Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ install:
1212 - npm install -g bower
1313 - npm install
1414script :
15- - npm run build
15+ - npm run build && npm test
1616after_success :
1717- >-
1818 test $TRAVIS_TAG &&
Original file line number Diff line number Diff line change 33 "scripts" : {
44 "postinstall" : " pulp dep install" ,
55 "clean" : " rimraf output && rimraf .pulp-cache" ,
6- "build" : " jshint src && jscs src && pulp build"
6+ "build" : " jshint src && jscs src && pulp build" ,
7+ "test" : " pulp test"
78 },
89 "devDependencies" : {
910 "jscs" : " ^2.8.0" ,
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ // module Test.Main
4+
5+ exports . mainImpl = function ( showNumber ) {
6+ return function ( ) {
7+ function testAll ( cases ) {
8+ cases . forEach ( function ( c ) {
9+ var expected = c [ 1 ] ;
10+ var actual = showNumber ( c [ 0 ] ) ;
11+ if ( expected !== actual ) {
12+ throw new Error (
13+ "For " + c [ 0 ] +
14+ ", expected " + expected +
15+ ", got: " + actual + "." ) ;
16+ }
17+ } ) ;
18+ }
19+
20+ testAll ( [
21+ // Within Int range
22+ [ 0.0 , "0.0" ] ,
23+ [ 1.0 , "1.0" ] ,
24+ [ - 1.0 , "-1.0" ] ,
25+ [ 500.0 , "500.0" ] ,
26+
27+ // Outside Int range
28+ [ 1e10 , "10000000000.0" ] ,
29+ [ 1e10 + 0.5 , "10000000000.5" ] ,
30+ [ - 1e10 , "-10000000000.0" ] ,
31+ [ - 1e10 - 0.5 , "-10000000000.5" ] ,
32+
33+ // With exponent
34+ [ 1e21 , "1e+21" ] ,
35+ [ 1e-21 , "1e-21" ] ,
36+
37+ // With decimal and exponent
38+ [ 1.5e21 , "1.5e+21" ] ,
39+ [ 1.5e-10 , "1.5e-10" ] ,
40+
41+ [ NaN , "NaN" ] ,
42+ [ Infinity , "Infinity" ] ,
43+ [ - Infinity , "-Infinity" ] ,
44+ ] ) ;
45+ } ;
46+ } ;
47+
Original file line number Diff line number Diff line change 1+ module Test.Main where
2+
3+ import Prelude
4+
5+ type AlmostEff = Unit -> Unit
6+
7+ main :: AlmostEff
8+ main = mainImpl show
9+
10+ foreign import mainImpl :: (Number -> String ) -> AlmostEff
You can’t perform that action at this time.
0 commit comments