-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test: test-file-write-stream3.js refactor #10035
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Next
Next commit
test: test-file-write-stream3.js refactor
- Loading branch information
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ const filepath = path.join(common.tmpDir, 'write_pos.txt'); | |
|
|
||
|
|
||
| const cb_expected = 'write open close write open close write open close '; | ||
| var cb_occurred = ''; | ||
| let cb_occurred = ''; | ||
|
|
||
| const fileDataInitial = 'abcdefghijklmnopqrstuvwxyz'; | ||
|
|
||
|
|
@@ -34,10 +34,8 @@ common.refreshTmpDir(); | |
|
|
||
|
|
||
| function run_test_1() { | ||
| var file, buffer, options; | ||
|
|
||
| options = {}; | ||
| file = fs.createWriteStream(filepath, options); | ||
| const options = {}; | ||
| const file = fs.createWriteStream(filepath, options); | ||
| console.log(' (debug: start ', file.start); | ||
| console.log(' (debug: pos ', file.pos); | ||
|
|
||
|
|
@@ -51,10 +49,10 @@ function run_test_1() { | |
| console.log(' (debug: start ', file.start); | ||
| console.log(' (debug: pos ', file.pos); | ||
| assert.strictEqual(file.bytesWritten, buffer.length); | ||
| var fileData = fs.readFileSync(filepath, 'utf8'); | ||
| const fileData = fs.readFileSync(filepath, 'utf8'); | ||
| console.log(' (debug: file data ', fileData); | ||
| console.log(' (debug: expected ', fileDataExpected_1); | ||
| assert.equal(fileData, fileDataExpected_1); | ||
| assert.strictEqual(fileData, fileDataExpected_1); | ||
|
|
||
| run_test_2(); | ||
| }); | ||
|
|
@@ -65,7 +63,7 @@ function run_test_1() { | |
| throw err; | ||
| }); | ||
|
|
||
| buffer = Buffer.from(fileDataInitial); | ||
| const buffer = Buffer.from(fileDataInitial); | ||
| file.write(buffer); | ||
| cb_occurred += 'write '; | ||
|
|
||
|
|
@@ -74,13 +72,12 @@ function run_test_1() { | |
|
|
||
|
|
||
| function run_test_2() { | ||
| var file, buffer, options; | ||
|
|
||
| buffer = Buffer.from('123456'); | ||
| const buffer = Buffer.from('123456'); | ||
|
|
||
| options = { start: 10, | ||
| const options = { start: 10, | ||
| flags: 'r+' }; | ||
| file = fs.createWriteStream(filepath, options); | ||
| const file = fs.createWriteStream(filepath, options); | ||
| console.log(' (debug: start ', file.start); | ||
| console.log(' (debug: pos ', file.pos); | ||
|
|
||
|
|
@@ -94,10 +91,10 @@ function run_test_2() { | |
| console.log(' (debug: start ', file.start); | ||
| console.log(' (debug: pos ', file.pos); | ||
| assert.strictEqual(file.bytesWritten, buffer.length); | ||
| var fileData = fs.readFileSync(filepath, 'utf8'); | ||
| const fileData = fs.readFileSync(filepath, 'utf8'); | ||
| console.log(' (debug: file data ', fileData); | ||
| console.log(' (debug: expected ', fileDataExpected_2); | ||
| assert.equal(fileData, fileDataExpected_2); | ||
| assert.strictEqual(fileData, fileDataExpected_2); | ||
|
|
||
| run_test_3(); | ||
| }); | ||
|
|
@@ -116,13 +113,12 @@ function run_test_2() { | |
|
|
||
|
|
||
| function run_test_3() { | ||
| var file, options; | ||
|
|
||
| const data = '\u2026\u2026'; // 3 bytes * 2 = 6 bytes in UTF-8 | ||
|
|
||
| options = { start: 10, | ||
| const options = { start: 10, | ||
| flags: 'r+' }; | ||
|
Member
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 line this up so that start and flags line up like they did before (ie need to indent flags to align with new position of start) |
||
| file = fs.createWriteStream(filepath, options); | ||
| const file = fs.createWriteStream(filepath, options); | ||
| console.log(' (debug: start ', file.start); | ||
| console.log(' (debug: pos ', file.pos); | ||
|
|
||
|
|
@@ -139,7 +135,7 @@ function run_test_3() { | |
| const fileData = fs.readFileSync(filepath, 'utf8'); | ||
| console.log(' (debug: file data ', fileData); | ||
| console.log(' (debug: expected ', fileDataExpected_3); | ||
| assert.equal(fileData, fileDataExpected_3); | ||
| assert.strictEqual(fileData, fileDataExpected_3); | ||
|
|
||
| run_test_4(); | ||
| }); | ||
|
|
||
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.
Can you line this up so that start and flags line up like they did before (ie need to indent flags to align with new position of start)