Skip to content

Commit

Permalink
version bump 0.3.1-a: coverage testing
Browse files Browse the repository at this point in the history
  • Loading branch information
SheetJSDev committed May 1, 2014
1 parent c9c3adf commit 248eb2d
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 22 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test_files/*.tsv
.gitignore
node_modules/
coverage.html
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 27 additions & 16 deletions frac.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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" }
}
Expand All @@ -252,11 +261,13 @@ 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:

```>.gitignore
.gitignore
node_modules/
coverage.html
```
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 248eb2d

Please sign in to comment.