mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Merge branch 'refs/heads/develop' into v13
# Conflicts: # AUTHORS # package-lock.json
This commit is contained in:
commit
fe4667cd8f
1
AUTHORS
1
AUTHORS
@ -247,5 +247,6 @@ Sukka <isukkaw@gmail.com>
|
||||
Rohil Shah <shah5963@gmail.com>
|
||||
Laurent Gérin <41303636+lgerin@users.noreply.github.com>
|
||||
Adam Jones <domdomegg+git@gmail.com>
|
||||
Lucas Eng <lucaseng19@gmail.com>
|
||||
|
||||
# Generated by tools/update-authors.js
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
||||
"homepage": "https://mathjs.org",
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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)])
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user