Skip to content

Commit

Permalink
feat: expose implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercejudo committed Feb 13, 2016
1 parent 2d15059 commit 068faae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = function factory(adapter) {
Decimal.getPrecision = getPrecision;
Decimal.setPrecision = setPrecision;
Decimal.JSONReviver = JSONReviver;
Decimal.Impl = Impl;

var p = Decimal.prototype;

Expand Down
14 changes: 14 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ describe('core functionality', function() {
});
});

describe('implementation', function() {
it('should expose the implementation constructor', function() {
new Decimal.Impl(2).plus(new Decimal.Impl(3)).valueOf().should.be.exactly(5);
});

it('should be able to set the current precision', function() {
var initialPrecision = Decimal.getPrecision();

Decimal.setPrecision(42);
Decimal.getPrecision().should.be.exactly(42);
Decimal.setPrecision(initialPrecision);
});
});

describe('toString, valueOf and JSON', function() {
it('should be able to return a string representation', function() {
var decimalOne = new Decimal('1');
Expand Down

0 comments on commit 068faae

Please sign in to comment.