Skip to content

Commit

Permalink
feat: add inequality functions and update core
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercejudo committed May 7, 2016
1 parent 59aff2a commit e13f951
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
"gulp-istanbul": "^0.10.2",
"gulp-mocha": "^2.1.3",
"rimraf": "^2.4.3",
"should": "^8.0.2"
"should": "^8.3.1"
},
"dependencies": {
"core-arbitrary-precision": "^2.0.0",
"core-arbitrary-precision": "^3.1.0",
"div-arbitrary-precision": "^1.0.0",
"equals-arbitrary-precision": "^1.0.1",
"inequality-arbitrary-precision": "^1.0.1",
"lodash.flow": "^3.2.1",
"minus-arbitrary-precision": "^1.0.0",
"mod-arbitrary-precision": "^1.0.0",
Expand Down
7 changes: 3 additions & 4 deletions src/linear-arbitrary-precision.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ var extend = flow(
require('times-arbitrary-precision'),
require('div-arbitrary-precision'),
require('mod-arbitrary-precision'),
require('equals-arbitrary-precision')
require('equals-arbitrary-precision'),
require('inequality-arbitrary-precision')
);

module.exports = function factory(adapter) {
return extend(coreArbitraryPrecision(adapter));
};
module.exports = flow(coreArbitraryPrecision, extend);
17 changes: 13 additions & 4 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

'use strict';

require('should');
var should = require('should');

var decimalFactory = require('../src/linear-arbitrary-precision');
var adapter = require('floating-adapter');

describe('linear operations with Floating', function() {
var Decimal = decimalFactory(adapter);
var ONE = new Decimal('1');

describe('constructor', function() {
it('should throw if called without new', function() {
Expand Down Expand Up @@ -70,6 +71,14 @@ describe('linear operations with Floating', function() {
new Decimal('1').equals(new Decimal('1')).should.be.exactly(true);
new Decimal('1').equals(new Decimal('2')).should.be.exactly(false);
});

it('should have an inequality methods', function() {
should(ONE.lt).have.type('function');
should(ONE.lte).have.type('function');
should(ONE.gt).have.type('function');
should(ONE.gte).have.type('function');
should(ONE.cmp).have.type('function');
});
});

describe('toString, valueOf and JSON', function() {
Expand All @@ -90,11 +99,11 @@ describe('linear operations with Floating', function() {

it('should play nicely with JSON.stringify()', function() {
var decimalOne = new Decimal('1');
var stringified = JSON.stringify([decimalOne]);
var stringified = JSON.stringify(decimalOne);

stringified.should.be.exactly('["1"]');
stringified.should.be.exactly('"1"');

JSON.parse(stringified, Decimal.JSONReviver)[0].should.eql(decimalOne);
JSON.parse(stringified, Decimal.reviver).should.eql(decimalOne);
});
});
});

0 comments on commit e13f951

Please sign in to comment.