mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
// test setMultiplicity
|
|
import assert from 'assert'
|
|
|
|
import math from '../../../../src/bundleAny'
|
|
|
|
describe('setMultiplicity', function () {
|
|
it('should return the multiplicity on an element of a set', function () {
|
|
assert.deepStrictEqual(math.setMultiplicity(1, [1, 2]), 1)
|
|
assert.deepStrictEqual(math.setMultiplicity(1, []), 0)
|
|
})
|
|
|
|
it('should return the multiplicity on an element of a multiset', function () {
|
|
assert.deepStrictEqual(math.setMultiplicity(1, [1, 1, 2]), 2)
|
|
assert.deepStrictEqual(math.setMultiplicity(1, [1, 2, 1]), 2)
|
|
})
|
|
|
|
it('should return a number', function () {
|
|
assert.strictEqual(math.typeOf(math.setMultiplicity(3, [3, 4, 5])), 'number')
|
|
})
|
|
|
|
it('should throw an error in case of invalid number of arguments', function () {
|
|
assert.throws(function () { math.setMultiplicity() }, /TypeError: Too few arguments/)
|
|
assert.throws(function () { math.setMultiplicity(1, [], []) }, /TypeError: Too many arguments/)
|
|
})
|
|
|
|
it('should throw an error in case of invalid order of arguments', function () {
|
|
assert.throws(function () { math.setMultiplicity([], 1) }, /TypeError: Unexpected type of argument/)
|
|
})
|
|
})
|