-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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 2 commits
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,30 @@ const array = [ | |
] | ||
]; | ||
|
||
assert.strictEqual(test_array.Test(array, array.length + 1), | ||
'Index out of bound!'); | ||
assert.throws( | ||
() => { | ||
test_array.TestGetElement(array, array.length + 1); | ||
}, | ||
/Index out of bounds!/ | ||
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 able to make this more strict? We've been moving toward adding 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. Oops missed that one, will add. 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. Also fixed up the other instance which was there from the existing version of the test. |
||
); | ||
|
||
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.
Does this arrow function fit on a single line?
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.
I was keeping it consistent with what I saw most often in tests. For example: test/parallel/test-punycode.js.