File tree Expand file tree Collapse file tree 5 files changed +61
-5
lines changed Expand file tree Collapse file tree 5 files changed +61
-5
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ install:
12
12
- npm install -g bower
13
13
- npm install
14
14
script :
15
- - npm run build
15
+ - npm run build && npm test
16
16
after_success :
17
17
- >-
18
18
test $TRAVIS_TAG &&
Original file line number Diff line number Diff line change 3
3
"scripts" : {
4
4
"postinstall" : " pulp dep install" ,
5
5
"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"
7
8
},
8
9
"devDependencies" : {
9
10
"jscs" : " ^2.8.0" ,
Original file line number Diff line number Diff line change @@ -8,9 +8,7 @@ exports.showIntImpl = function (n) {
8
8
9
9
exports . showNumberImpl = function ( n ) {
10
10
var str = n . toString ( ) ;
11
- return str . indexOf ( "e" ) === - 1 && str . indexOf ( "." ) === - 1 ?
12
- str + ".0" :
13
- str ;
11
+ return isNaN ( str + ".0" ) ? str : str + ".0" ;
14
12
} ;
15
13
16
14
exports . showCharImpl = function ( c ) {
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