-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: improve n-api array func coverage #12890
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,19 +19,26 @@ const array = [ | |
] | ||
]; | ||
|
||
assert.strictEqual(test_array.Test(array, array.length + 1), | ||
assert.strictEqual(test_array.TestGetElement(array, array.length + 1), | ||
'Index out of bound!'); | ||
|
||
assert.throws( | ||
() => { | ||
test_array.Test(array, -2); | ||
test_array.TestGetElement(array, -2); | ||
}, | ||
/Invalid index\. Expects a positive integer\./ | ||
); | ||
|
||
array.forEach(function(element, index) { | ||
assert.strictEqual(test_array.Test(array, index), element); | ||
assert.strictEqual(test_array.TestGetElement(array, index), element); | ||
}); | ||
|
||
|
||
assert.deepStrictEqual(test_array.New(array), array); | ||
|
||
assert(test_array.TestHasElement(array, 0)); | ||
assert.strictEqual(false, test_array.TestHasElement(array, array.length + 1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you switch the argument order to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will do. |
||
|
||
assert(test_array.NewWithLength(0) instanceof Array); | ||
assert(test_array.NewWithLength(1) instanceof Array); | ||
assert(test_array.NewWithLength(2 ^ 32 - 1) instanceof Array); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you attempting to do exponentiation here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would need to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, maybe coding at 2am in your hotel room is not always the best idea. Will fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally unrelated to this PR, but just wanted to say that this implementation doesn't look correct to me. "Index out of bound!" should be thrown as an Error. As it is, "Index out of bound!" could be a value in the Array.