Skip to content
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

fs: complete error code for validateLen func in internal/fs #19909

Closed
wants to merge 4 commits into from

Conversation

ah-yu
Copy link
Contributor

@ah-yu ah-yu commented Apr 10, 2018

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Apr 10, 2018
@ah-yu
Copy link
Contributor Author

ah-yu commented Apr 10, 2018

@BridgeAR

@mscdex
Copy link
Contributor

mscdex commented Apr 10, 2018

The prefix for the first commit should just be fs: instead of feat(internal/fs):.

@ah-yu
Copy link
Contributor Author

ah-yu commented Apr 10, 2018

fixed it, thanks for your suggestion! @mscdex

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to also add a test for floating point numbers.

err = new ERR_INVALID_ARG_TYPE('len', 'number', len);
} else {
} else if (!Number.isInteger(len)) {
// TODO(BridgeAR): Improve this error message.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually remove my comment now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -350,11 +350,14 @@ function validateLen(len) {
let err;

if (!isInt32(len)) {
if (typeof value !== 'number') {
if (typeof len !== 'number') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@BridgeAR
Copy link
Member

@ah-yu
Copy link
Contributor Author

ah-yu commented Apr 11, 2018

Fixed the comments. @BridgeAR

@@ -190,6 +190,31 @@ function testFtruncate(cb) {
);
});

[-1.5, 1.5].forEach((input) => {
assert.throws(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use common.expectsError in our tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. thanks for review :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@starkwang I must disagree. The original reason for using common.expectsError is that it allowed to use the error object. Now, assert.throws is more powerful than common.expectsError due to a much better error message output and since that feature was added to assert.throws.

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 12, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Apr 13, 2018
PR-URL: nodejs#19909
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@BridgeAR
Copy link
Member

Landed in 61e232b 🎉

I removed the common.expectsError change while landing.

@BridgeAR BridgeAR closed this Apr 13, 2018
jasnell pushed a commit that referenced this pull request Apr 16, 2018
PR-URL: #19909
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants