Skip to content

Commit ea9d64e

Browse files
test with @aureooms/js-{number,integer}
1 parent 9527cf8 commit ea9d64e

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Parent is [@aureooms/js-algorithms](https://github.com/aureooms/js-algorithms).
99

1010
```js
1111
import { list , map } from '@aureooms/js-itertools' ;
12-
import * as integer from '@aureooms/js-number' ;
12+
import * as integer from '@aureooms/js-integer' ;
1313

1414
let F = new Fibonacci( integer ) ;
1515
list( map ( integer.stringify , F.range( 10 ) ) ) ; // 0 1 1 2 3 5 8 13 21 34

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@
2525
"dependencies": {
2626
"@aureooms/js-error": "^3.0.0",
2727
"@aureooms/js-fibonacci": "^3.1.0",
28-
"@aureooms/js-itertools": "^3.2.1"
28+
"@aureooms/js-itertools": "^3.3.0"
2929
},
3030
"devDependencies": {
31+
"@aureooms/js-integer": "^3.0.0",
3132
"@aureooms/js-number": "^3.0.0",
3233
"ava": "^0.19.1",
3334
"babel-cli": "^6.24.1",
3435
"babel-polyfill": "^6.23.0",
3536
"babel-preset-latest": "^6.24.1",
3637
"codeclimate-test-reporter": "^0.4.1",
37-
"coveralls": "^2.13.0",
38+
"coveralls": "^2.13.1",
3839
"esdoc": "^0.5.2",
39-
"nyc": "^10.2.0"
40+
"nyc": "^10.3.2"
4041
},
4142
"homepage": "https://aureooms.github.io/js-integer-sequences",
4243
"keywords": [

test/src/Fibonacci.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
import test from 'ava' ;
2+
import https from 'https' ;
23

3-
import * as integer from '@aureooms/js-number' ;
4-
import { list , map } from '@aureooms/js-itertools' ;
4+
import * as number from '@aureooms/js-number' ;
5+
import * as integer from '@aureooms/js-integer' ;
6+
import { list , map , range } from '@aureooms/js-itertools' ;
57
import { Fibonacci } from '../../src' ;
68

7-
test( 'Fibonacci' , t => {
9+
const URL = 'https://raw.githubusercontent.com/aureooms/integer-sequence-fibonacci/master/sequence/' ;
810

9-
const F = new Fibonacci( integer ) ;
11+
const N = 78 ; // biggest fibonacci number smaller than 2^53
1012

11-
const n = 10 ;
12-
const a = [ "0" , "1" , "1" , "2" , "3" , "5" , "8" , "13" , "21" , "34" ] ;
13+
function macro ( t , [ name , impl ] , i ) {
1314

14-
t.deepEqual( list( map ( integer.stringify , F.range( n ) ) ) , a ) ;
15+
const F = new Fibonacci( impl ) ;
1516

16-
t.deepEqual( integer.stringify( F.nth( 0 ) ) , "0" ) ;
17-
t.deepEqual( integer.stringify( F.nth( 38 ) ) , "39088169" ) ;
17+
let data = '' ;
1818

19-
} ) ;
19+
https.get(
20+
URL + i ,
21+
res => {
22+
res.on( 'data' , chunk => { data += chunk ; } ) ;
23+
res.on( 'end' , ( ) => {
24+
t.is( impl.stringify( F.nth( i ) ) , data.trim() ) ;
25+
t.end( ) ;
26+
} ) ;
27+
}
28+
).on('error', e => {
29+
t.fail( e.message ) ;
30+
t.end( ) ;
31+
} ) ;
32+
33+
}
34+
35+
macro.title = ( _ , [ name , impl ] , i ) => `Fibonacci (${name}, ${i})` ;
36+
37+
for ( const model of [ [ '@aureooms/js-number' , number ] , [ '@aureooms/js-integer' , integer ] ] )
38+
for ( const i of range( 0 , N + 1 ) )
39+
test.cb( macro , model , i ) ;
40+
41+
// t.deepEqual( list( map ( integer.stringify , F.range( n ) ) ) , a ) ;

0 commit comments

Comments
 (0)