From 248eb2d8e8544cfcfc53e61a1a1cb56876ecf19d Mon Sep 17 00:00:00 2001 From: SheetJS Date: Wed, 30 Apr 2014 19:32:25 -0700 Subject: [PATCH] version bump 0.3.1-a: coverage testing --- .npmignore | 1 + .travis.yml | 4 ++++ Makefile | 17 ++++++++++++++++- README.md | 4 ++++ frac.md | 43 +++++++++++++++++++++++++++---------------- package.json | 12 +++++++----- test.js | 18 ++++++++++++++++++ 7 files changed, 77 insertions(+), 22 deletions(-) diff --git a/.npmignore b/.npmignore index 44f0fb4..ebd49bf 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ test_files/*.tsv .gitignore node_modules/ +coverage.html diff --git a/.travis.yml b/.travis.yml index a1f55b5..dc9e596 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/Makefile b/Makefile index d37a13d..06e5451 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index eef52c9..1e78d8f 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/frac.md b/frac.md index 01e0ef2..4a9bb21 100644 --- a/frac.md +++ b/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 ``` diff --git a/package.json b/package.json index cbf05e0..0bbe065 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/test.js b/test.js index 18ca4ff..c5a2a2f 100644 --- a/test.js +++ b/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() {