version bump 0.3.1-a: coverage testing

This commit is contained in:
SheetJS 2014-04-30 19:32:25 -07:00
parent c9c3adf002
commit 248eb2d8e8
7 changed files with 77 additions and 22 deletions

@ -1,3 +1,4 @@
test_files/*.tsv
.gitignore
node_modules/
coverage.html

@ -4,3 +4,7 @@ node_js:
- "0.8"
before_install:
- "npm install -g mocha"
- "npm install blanket"
- "npm install coveralls mocha-lcov-reporter"
after_success:
- "make coveralls"

@ -1,6 +1,21 @@
frac.js: frac.md
.PHONY: frac
frac: frac.md
voc frac.md
.PHONY: test
test:
mocha -R spec
.PHONY: lint
lint:
jshint --show-non-errors frac.js
.PHONY: cov
cov: coverage.html
coverage.html: frac
mocha --require blanket -R html-cov > coverage.html
.PHONY: coveralls
coveralls:
mocha --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js

@ -47,5 +47,9 @@ Tests generated from Excel have 4 columns. To produce a similar test:
- Column C format "Up to two digits (21/25)"
- Column D format "Up to three digits (312/943)"
[![Build Status](https://travis-ci.org/SheetJS/frac.svg?branch=master)](https://travis-ci.org/SheetJS/frac)
[![Coverage Status](https://coveralls.io/repos/SheetJS/frac/badge.png)](https://coveralls.io/r/SheetJS/frac)
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/731e31b3a26382ccd5d213b9e74ea552 "githalytics.com")](http://githalytics.com/SheetJS/frac)

43
frac.md

@ -203,6 +203,24 @@ function parsexl(f,w) {
var o = fs.readFileSync(f, 'utf-8').split("\n");
for(var j = 0, m = o.length-3; j < m/w; ++j) xlline(o,j,m,w);
}
function cmp(a,b) { assert.equal(a.length,b.length); for(var i = 0; i != a.length; ++i) assert.equal(a[i], b[i]); }
describe('mediant', function() {
it('should do the right thing for tenths', function() {
cmp(frac(0.1,9,false),[0,1,9]);
cmp(frac(0.2,9,false),[0,1,5]);
cmp(frac(0.3,9,false),[0,2,7]);
cmp(frac(0.4,9,false),[0,2,5]);
cmp(frac(0.5,9,false),[0,1,2]);
cmp(frac(0.6,9,false),[0,3,5]);
cmp(frac(0.7,9,false),[0,5,7]);
cmp(frac(0.8,9,false),[0,4,5]);
cmp(frac(0.9,9,false),[0,8,9]);
cmp(frac(1.0,9,false),[0,1,1]);
cmp(frac(1.0,9,true), [1,0,1]);
cmp(frac(1.7,9,true), [1,5,7]);
cmp(frac(1.7,9,false),[0,12,7]);
});
});
xltestfiles.forEach(function(x) {
var f = './test_files/' + x[0];
describe(x[0], function() {
@ -211,36 +229,27 @@ xltestfiles.forEach(function(x) {
});
```
# Miscellany
```make>Makefile
frac.js: frac.md
voc frac.md
.PHONY: test
test:
mocha -R spec
```
## Node Ilk
```json>package.json
{
"name": "frac",
"version": "0.3.1",
"version": "0.3.1-a",
"author": "SheetJS",
"description": "Rational approximation with bounded denominator",
"keywords": [ "math", "fraction", "rational", "approximation" ],
"main": "./frac.js",
"dependencies": {},
"devDependencies": {"mocha":"","voc":""},
"repository": {
"type":"git",
"url": "git://github.com/SheetJS/frac.git"
},
"repository": { "type":"git", "url": "git://github.com/SheetJS/frac.git" },
"scripts": {
"test": "make test"
},
"config": {
"blanket": {
"pattern": "frac.js"
}
},
"bugs": { "url": "https://github.com/SheetJS/frac/issues" },
"engines": { "node": ">=0.8" }
}
@ -252,6 +261,7 @@ And to make sure that test files are not included in npm:
test_files/*.tsv
.gitignore
node_modules/
coverage.html
```
Don't include the node modules in git:
@ -259,4 +269,5 @@ Don't include the node modules in git:
```>.gitignore
.gitignore
node_modules/
coverage.html
```

@ -1,19 +1,21 @@
{
"name": "frac",
"version": "0.3.1",
"version": "0.3.1-a",
"author": "SheetJS",
"description": "Rational approximation with bounded denominator",
"keywords": [ "math", "fraction", "rational", "approximation" ],
"main": "./frac.js",
"dependencies": {},
"devDependencies": {"mocha":"","voc":""},
"repository": {
"type":"git",
"url": "git://github.com/SheetJS/frac.git"
},
"repository": { "type":"git", "url": "git://github.com/SheetJS/frac.git" },
"scripts": {
"test": "make test"
},
"config": {
"blanket": {
"pattern": "frac.js"
}
},
"bugs": { "url": "https://github.com/SheetJS/frac/issues" },
"engines": { "node": ">=0.8" }
}

18
test.js

@ -35,6 +35,24 @@ function parsexl(f,w) {
var o = fs.readFileSync(f, 'utf-8').split("\n");
for(var j = 0, m = o.length-3; j < m/w; ++j) xlline(o,j,m,w);
}
function cmp(a,b) { assert.equal(a.length,b.length); for(var i = 0; i != a.length; ++i) assert.equal(a[i], b[i]); }
describe('mediant', function() {
it('should do the right thing for tenths', function() {
cmp(frac(0.1,9,false),[0,1,9]);
cmp(frac(0.2,9,false),[0,1,5]);
cmp(frac(0.3,9,false),[0,2,7]);
cmp(frac(0.4,9,false),[0,2,5]);
cmp(frac(0.5,9,false),[0,1,2]);
cmp(frac(0.6,9,false),[0,3,5]);
cmp(frac(0.7,9,false),[0,5,7]);
cmp(frac(0.8,9,false),[0,4,5]);
cmp(frac(0.9,9,false),[0,8,9]);
cmp(frac(1.0,9,false),[0,1,1]);
cmp(frac(1.0,9,true), [1,0,1]);
cmp(frac(1.7,9,true), [1,5,7]);
cmp(frac(1.7,9,false),[0,12,7]);
});
});
xltestfiles.forEach(function(x) {
var f = './test_files/' + x[0];
describe(x[0], function() {