gentooboontoo / js-quantities

JavaScript library for quantity calculation and unit conversion
http://gentooboontoo.github.io/js-quantities/
MIT License
396 stars 102 forks source link

test: add a test to verify point/pint compatibility #111

Open Ugzuzg opened 3 years ago

Ugzuzg commented 3 years ago

Trying to parse the pint unit before the point unit makes the point and meters incompatible.

For some reason, the signature of point and pint always matches and depends on the order they were parsed:

const Qty = require('js-quantities');

const point = new Qty('1point');
const pint = new Qty('1pint');
console.log(pint.signature, point.signature); // -> 1 1
const Qty = require('js-quantities');

const pint = new Qty('1pint');
const point = new Qty('1point');
console.log(pint.signature, point.signature); // -> 3 3

Linked to https://github.com/gentooboontoo/js-quantities/issues/26, I guess.

Ugzuzg commented 3 years ago

@gentooboontoo, I will gladly implement a fix if you can give me some directions.