Tom Hickson 9a66b80bff Finalized Diff function
Added tests and then fixed all linting issues
2020-04-08 19:28:02 +01:00

22 lines
765 B
JavaScript

import assert from 'assert'
import math from '../../../../src/bundleAny'
const matrix = math.matrix
describe('crush', function () {
it('should return original array/matrix for less than 2 elements', function () {
assert.deepStrictEqual(math.diff([]), [])
assert.deepStrictEqual(math.diff(matrix([])), matrix([]))
assert.deepStrictEqual(math.diff([2]), [2])
assert.deepStrictEqual(math.diff(matrix([2])), matrix([2]))
})
it('should return difference between elements of an array', function () {
assert.deepStrictEqual(math.diff([1, 2, 4, 7, 0]), [1, 2, 3, -7])
})
it('should return difference between elements of a matrix', function () {
assert.deepStrictEqual(math.diff(matrix([1, 2, 4, 7, 0])), matrix([1, 2, 3, -7]))
})
})