Skip to content

Commit

Permalink
chore(converter): adapt to latest version of linear-converter
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercejudo committed Oct 5, 2015
1 parent e7f76fa commit b99fe97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/linear-converter-to-go.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var lcApi = lcFactory(Decimal);
var api = {};

var asIs = {
equivalentPresets: lcApi.equivalentPresets
equivalentConversions: lcApi.equivalentConversions
};

var numerical = {
Expand All @@ -33,8 +33,8 @@ var numerical = {
};

var presetNumerical = {
invertPreset: lcApi.invertPreset,
composePresets: lcApi.composePresets
invertConversion: lcApi.invertConversion,
composeConversions: lcApi.composeConversions
};

forOwn(asIs, function(fn, name) {
Expand Down
21 changes: 19 additions & 2 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,28 @@ describe('linear converter to go', function() {
});

it('should invert presets', function() {
lc.invertPreset([[0, 1], [0, 3]]).should.eql([[0, 3], [0, 1]]);
lc.invertConversion([[0, 1], [0, 3]]).should.eql([[0, 3], [0, 1]]);
});

it('should compose presets returning scales with primitive numbers', function() {
lc.composePresets([[0, 1], [0, 3]], [[0, 1], [1, 2]]).should.eql([[0, 1], [1, 4]]);
lc.composeConversions([[0, 1], [0, 3]], [[0, 1], [1, 2]]).should.eql([[0, 1], [1, 4]]);
});

it('should be able to test for equavalence', function() {
lc.equivalentConversions(
[[0, 10], [10, 20]],
[[430245.1, -44.5], [430255.1, -34.5]]
).should.be.exactly(true);

lc.equivalentConversions(
[[0, 1], [0, 2]],
[[0, 1], [0, 3]]
).should.be.exactly(false);

lc.equivalentConversions(
[[0, 1], [1, 3]],
[[0, 1], [2, 4]]
).should.be.exactly(false);
});

it('should calculate coefficients as primitive numbers', function() {
Expand Down

0 comments on commit b99fe97

Please sign in to comment.