Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd43ae4

Browse files
authored
clean up a bit
1 parent9506205 commitdd43ae4

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

‎Maths/test/Determinant.test.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import{expect}from'vitest'
22
import{determinant}from'../Determinant'
33
describe('Determinant',()=>{
4-
constvalidTestCases=[
4+
test.each([
55
[
66
[
77
[8,1,6],
@@ -37,9 +37,14 @@ describe('Determinant', () => {
3737
2476
3838
],
3939
[[[23]],23]
40-
]
40+
])(
41+
'Should return the determinant of the square matrix.',
42+
(matrix,expected)=>{
43+
expect(determinant(matrix)).toEqual(expected)
44+
}
45+
)
4146

42-
consterrorTestCases=[
47+
test.each([
4348
[
4449
[
4550
[1,6],
@@ -49,27 +54,10 @@ describe('Determinant', () => {
4954
'Square matrix is required.'
5055
],
5156
[[1,3,2,[5,8,6],3],'Input is not a valid 2D matrix.']
52-
]
53-
54-
test.each(validTestCases)(
55-
'Should return the determinant of the square matrix.',
56-
(matrix,expected)=>{
57-
try{
58-
expect(determinant(matrix)).toEqual(expected)
59-
}catch(err){
60-
expect(err.message).toEqual(expected)
61-
}
62-
}
63-
)
64-
65-
test.each(errorTestCases)(
57+
])(
6658
'Should return the error message.',
6759
(matrix,expected)=>{
68-
try{
69-
expect(determinant(matrix)).toEqual(expected)
70-
}catch(err){
71-
expect(err.message).toEqual(expected)
72-
}
60+
expect(()=>determinant(matrix)).toThrowError(expected)
7361
}
7462
)
7563
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp