diff --git a/AUTHORS b/AUTHORS index cdae2fc99..0e4b9b73f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -247,5 +247,6 @@ Sukka Rohil Shah Laurent Gérin <41303636+lgerin@users.noreply.github.com> Adam Jones +Lucas Eng # Generated by tools/update-authors.js diff --git a/HISTORY.md b/HISTORY.md index 6292ff2ce..a5abab9c0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,6 @@ # History -# unpublished changes since 12.4.2 +# 2024-05-31, 12.4.3 - Fix: serialization of Units without a value, see #1240. - Fix: outdated, incorrect documentation about the order of precedence for diff --git a/package.json b/package.json index 3cf884b7a..100d95259 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mathjs", - "version": "12.4.2", + "version": "12.4.3", "description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.", "author": "Jos de Jong (https://github.com/josdejong)", "homepage": "https://mathjs.org", diff --git a/src/version.js b/src/version.js index 48f9706d1..6cf204477 100644 --- a/src/version.js +++ b/src/version.js @@ -1,3 +1,3 @@ -export const version = '12.4.2' +export const version = '12.4.3' // Note: This file is automatically generated when building math.js. // Changes made in this file will be overwritten. diff --git a/test/unit-tests/type/matrix/utils/deepForEach.test.js b/test/unit-tests/type/matrix/utils/deepForEach.test.js index 36d0e030c..6245eb380 100644 --- a/test/unit-tests/type/matrix/utils/deepForEach.test.js +++ b/test/unit-tests/type/matrix/utils/deepForEach.test.js @@ -1 +1,63 @@ -// TODO: test deepForEach +import assert from 'assert' +import math from '../../../../../src/defaultInstance.js' +import { deepForEach } from '../../../../../src/utils/collection.js' + +const DenseMatrix = math.DenseMatrix + +describe('deepForEach', function () { + it('should iterate over all elements in a simple array', function () { + const array = [1, 2, 3] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3]) + }) + + it('should iterate over all elements in a nested array', function () { + const array = [[1, 2], [3, [4, 5]]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3, 4, 5]) + }) + + it('should iterate over all elements in a mixed type array', function () { + const array = [1, 'two', [3, null, undefined, true]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 'two', 3, null, undefined, true]) + }) + + it('should handle an empty array', function () { + const array = [] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, []) + }) + + it('should handle an array with empty nested arrays', function () { + const array = [[], [1, []], [2, [3, []]]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3]) + }) + + it('should iterate over all elements in a DenseMatrix', function () { + const matrix = new DenseMatrix([[1, 2], [3, 4]]) + const result = [] + deepForEach(matrix, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3, 4]) + }) + + it('should call the callback with each element of a matrix after converting to array', function () { + const matrix = math.matrix([[1, 2], [3, 4]]) + const result = [] + deepForEach(matrix, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3, 4]) + }) + + it('should work with arrays containing complex numbers', function () { + const array = [math.complex(2, 3), [math.complex(4, 5)]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [math.complex(2, 3), math.complex(4, 5)]) + }) +})