Skip to content

Commit

Permalink
fixed issue in test cases for error handling v2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vrushaket committed Sep 14, 2023
1 parent 73a9cd0 commit aacc0cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ Evan Miller <[email protected]>
Timur <[email protected]>
Ari Markowitz <[email protected]>
Jay Wang <[email protected]>
David Contreras <[email protected]
Jaeu Jeong <[email protected]>
cyavictor88 <[email protected]>
David Contreras <[email protected]>
Expand All @@ -232,6 +231,7 @@ MaybePixem <[email protected]>
Aly Khaled <[email protected]>
BuildTools <[email protected]>
Anik Patel <[email protected]>
Vrushaket Chaudhari <[email protected]>
Vrushaket Chaudhari <[email protected]>
vrushaket <[email protected]>

# Generated by tools/update-authors.js
3 changes: 3 additions & 0 deletions src/function/statistics/corr.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export const createCorr = /* #__PURE__ */ factory(name, dependencies, ({ typed,
}
return correlations
} else {
if (A.length !== B.length) {
throw new SyntaxError('Dimension mismatch. Array A and B must have the same number of elements.')
}
return correlation(A, B)
}
}
Expand Down
7 changes: 5 additions & 2 deletions test/unit-tests/function/statistics/corr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ describe('correlation', function () {
})

it('should throw an error if called with different number of arguments', function () {
assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7, 8],[9, 10, 11, 12]], [[1, 2, 3, 4, 5],[4, 5, 6, 7, 8]]) })
assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [9, 10, 11, 12]], [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8]]) })
})

it('should throw an error if called with number of arguments do not have same size', function () {
assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7]], [[1, 2, 3, 4, 5],[]]) })
assert.throws(function () { corr([[1, 2, 3, 4, 5], [4, 5, 6, 7]], [[1, 2, 3, 4, 5], []]) })
})
it('should throw an error if called with number of arguments do not have same size', function () {
assert.throws(function () { corr([1, 2, 3, 4, 5], [1, 2, 3, 4]) })
})
})

0 comments on commit aacc0cb

Please sign in to comment.