Skip to content

Commit 29d8b6e

Browse files
authored
test: cover rowEchelon leaving the input matrix unchanged
1 parent 9f4fbb8 commit 29d8b6e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎Maths/test/RowEchelon.test.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,16 @@ describe('Determinant', () => {
8686
])('Should return the error message.', (matrix, expected) => {
8787
expect(() => rowEchelon(matrix)).toThrowError(expected)
8888
})
89+
90+
test('Should not mutate the input matrix.', () => {
91+
const matrix = [
92+
[1, 2, 3],
93+
[4, 5, 6],
94+
[7, 8, 10]
95+
]
96+
const original = matrix.map((row) => [...row])
97+
const result = rowEchelon(matrix)
98+
expect(matrix).toEqual(original)
99+
expect(result).not.toBe(matrix)
100+
})
89101
})

0 commit comments

Comments
 (0)