mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
// test setSize
|
|
import assert from 'assert'
|
|
|
|
import math from '../../../../src/bundleAny'
|
|
|
|
describe('setSize', function () {
|
|
it('should return the number of elements of a set', function () {
|
|
assert.strictEqual(math.setSize([]), 0)
|
|
assert.strictEqual(math.setSize([1]), 1)
|
|
assert.strictEqual(math.setSize([1, 2]), 2)
|
|
assert.strictEqual(math.setSize([1, math.complex(2, 2)]), 2)
|
|
})
|
|
|
|
it('should return the number of elements of a multiset', function () {
|
|
assert.strictEqual(math.setSize([1, 1]), 2)
|
|
assert.strictEqual(math.setSize([1, 1], true), 1)
|
|
assert.strictEqual(math.setSize([1, 2, 1], true), 2)
|
|
})
|
|
|
|
it('should return a number', function () {
|
|
assert.strictEqual(math.typeOf(math.setSize([1, 2, 3])), 'number')
|
|
})
|
|
|
|
it('should throw an error in case of invalid type of arguments', function () {
|
|
assert.throws(function () { math.setSize([], []) }, /TypeError: Unexpected type of argument/)
|
|
})
|
|
|
|
it('should throw an error in case of invalid number of arguments', function () {
|
|
assert.throws(function () { math.setSize() }, /TypeError: Too few arguments/)
|
|
})
|
|
})
|