-
Notifications
You must be signed in to change notification settings - Fork 623
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
fix(node/fs): Enable test-fs-read-zero-length.js
and test-fs-read-type.js
#2692
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bec4d05
fix(node/fs): Enable test-fs-read-zero-length.js
639cbf3
fix(node/fs): Enable test-fs-read-type.js
2e4c323
test(node/fs): Enable test-fs-read.js
037ad96
docs: Add license
76d4984
chore(node/fs): Delete tests that don't pass because we enable native…
4a3f2d1
fix(node/fs): null to -1
df6d675
chore(node/fs): Leave tests until completed.
2257c15
refactor(node/fs): use validateInteger
e19d20f
refactor(node/fs): use internal/fs/utils.mjs
1e4c61d
fix(node/fs): Enable test-fs-read.js completely
32ae69e
chore: resolve conflict
833593f
fix(node/fs): Intentionally create TypeError
de143bd
chore: deno fmt
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. | ||
cjihrig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Copyright Joyent and Node contributors. All rights reserved. MIT license. | ||
|
||
import { | ||
ERR_INVALID_ARG_TYPE, | ||
ERR_OUT_OF_RANGE, | ||
hideStackFrames, | ||
} from "../internal/errors.ts"; | ||
import { validateInteger } from "../internal/validators.mjs"; | ||
|
||
export const validatePosition = hideStackFrames((position: unknown) => { | ||
cjihrig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (typeof position === "number") { | ||
validateInteger(position, "position"); | ||
} else if (typeof position === "bigint") { | ||
if (!(position >= -(2n ** 63n) && position <= 2n ** 63n - 1n)) { | ||
throw new ERR_OUT_OF_RANGE( | ||
"position", | ||
`>= ${-(2n ** 63n)} && <= ${2n ** 63n - 1n}`, | ||
position, | ||
); | ||
} | ||
} else { | ||
throw new ERR_INVALID_ARG_TYPE("position", ["integer", "bigint"], position); | ||
} | ||
}); | ||
|
||
export const validateOffsetLengthRead = hideStackFrames( | ||
cjihrig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(offset: number, length: number, bufferLength: number) => { | ||
if (offset < 0) { | ||
throw new ERR_OUT_OF_RANGE("offset", ">= 0", offset); | ||
} | ||
if (length < 0) { | ||
throw new ERR_OUT_OF_RANGE("length", ">= 0", length); | ||
} | ||
if (offset + length > bufferLength) { | ||
throw new ERR_OUT_OF_RANGE( | ||
"length", | ||
`<= ${bufferLength - offset}`, | ||
length, | ||
); | ||
} | ||
}, | ||
); | ||
|
||
export default { | ||
validatePosition, | ||
validateOffsetLengthRead, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this check be: