mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
Added lcm fraction tests
This commit is contained in:
parent
917d82c6fd
commit
0a8dbd352e
@ -77,6 +77,17 @@ describe('lcm', function() {
|
||||
assert.throws(function () {lcm('a', 2); }, /Cannot convert "a" to a number/);
|
||||
});
|
||||
|
||||
it('should find the least common multiple of fractions', function () {
|
||||
var a = math.fraction(5,8);
|
||||
assert.equal(lcm(a, math.fraction(3,7)).toString(), '15');
|
||||
assert.equal(a.toString(), '0.625');
|
||||
});
|
||||
|
||||
it('should find the least common multiple of mixed numbers and fractions', function () {
|
||||
assert.deepEqual(lcm(math.fraction(12), 8), math.fraction(24));
|
||||
assert.deepEqual(lcm(12, math.fraction(8)), math.fraction(24));
|
||||
});
|
||||
|
||||
it('should throw an error with units', function() {
|
||||
assert.throws(function () { lcm(math.unit('5cm'), 2); }, TypeError, 'Function lcm(unit, number) not supported');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user