| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ const filepath = path.join(common.tmpDir, 'write_pos.txt'); | |||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | 11 | const cb_expected = 'write open close write open close write open close '; | |
| 12 | - var cb_occurred = ''; | ||
| 12 | + let cb_occurred = ''; | ||
| 13 | 13 | ||
| 14 | 14 | const fileDataInitial = 'abcdefghijklmnopqrstuvwxyz'; | |
| 15 | 15 | ||
@@ -34,10 +34,8 @@ common.refreshTmpDir(); | |||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | 36 | function run_test_1() { | |
| 37 | - var file, buffer, options; | ||
| 38 | - | ||
| 39 | - options = {}; | ||
| 40 | - file = fs.createWriteStream(filepath, options); | ||
| 37 | + const options = {}; | ||
| 38 | + const file = fs.createWriteStream(filepath, options); | ||
| 41 | 39 | console.log(' (debug: start ', file.start); | |
| 42 | 40 | console.log(' (debug: pos ', file.pos); | |
| 43 | 41 | ||
@@ -51,10 +49,10 @@ function run_test_1() { | |||
| 51 | 49 | console.log(' (debug: start ', file.start); | |
| 52 | 50 | console.log(' (debug: pos ', file.pos); | |
| 53 | 51 | assert.strictEqual(file.bytesWritten, buffer.length); | |
| 54 | - var fileData = fs.readFileSync(filepath, 'utf8'); | ||
| 52 | + const fileData = fs.readFileSync(filepath, 'utf8'); | ||
| 55 | 53 | console.log(' (debug: file data ', fileData); | |
| 56 | 54 | console.log(' (debug: expected ', fileDataExpected_1); | |
| 57 | - assert.equal(fileData, fileDataExpected_1); | ||
| 55 | + assert.strictEqual(fileData, fileDataExpected_1); | ||
| 58 | 56 | ||
| 59 | 57 | run_test_2(); | |
| 60 | 58 | }); | |
@@ -65,7 +63,7 @@ function run_test_1() { | |||
| 65 | 63 | throw err; | |
| 66 | 64 | }); | |
| 67 | 65 | ||
| 68 | - buffer = new Buffer(fileDataInitial); | ||
| 66 | + const buffer = Buffer.from(fileDataInitial); | ||
| 69 | 67 | file.write(buffer); | |
| 70 | 68 | cb_occurred += 'write '; | |
| 71 | 69 | ||
@@ -74,13 +72,12 @@ function run_test_1() { | |||
| 74 | 72 | ||
| 75 | 73 | ||
| 76 | 74 | function run_test_2() { | |
| 77 | - var file, buffer, options; | ||
| 78 | 75 | ||
| 79 | - buffer = new Buffer('123456'); | ||
| 76 | + const buffer = Buffer.from('123456'); | ||
| 80 | 77 | ||
| 81 | - options = { start: 10, | ||
| 82 | - flags: 'r+' }; | ||
| 83 | - file = fs.createWriteStream(filepath, options); | ||
| 78 | + const options = { start: 10, | ||
| 79 | + flags: 'r+' }; | ||
| 80 | + const file = fs.createWriteStream(filepath, options); | ||
| 84 | 81 | console.log(' (debug: start ', file.start); | |
| 85 | 82 | console.log(' (debug: pos ', file.pos); | |
| 86 | 83 | ||
@@ -94,10 +91,10 @@ function run_test_2() { | |||
| 94 | 91 | console.log(' (debug: start ', file.start); | |
| 95 | 92 | console.log(' (debug: pos ', file.pos); | |
| 96 | 93 | assert.strictEqual(file.bytesWritten, buffer.length); | |
| 97 | - var fileData = fs.readFileSync(filepath, 'utf8'); | ||
| 94 | + const fileData = fs.readFileSync(filepath, 'utf8'); | ||
| 98 | 95 | console.log(' (debug: file data ', fileData); | |
| 99 | 96 | console.log(' (debug: expected ', fileDataExpected_2); | |
| 100 | - assert.equal(fileData, fileDataExpected_2); | ||
| 97 | + assert.strictEqual(fileData, fileDataExpected_2); | ||
| 101 | 98 | ||
| 102 | 99 | run_test_3(); | |
| 103 | 100 | }); | |
@@ -116,13 +113,12 @@ function run_test_2() { | |||
| 116 | 113 | ||
| 117 | 114 | ||
| 118 | 115 | function run_test_3() { | |
| 119 | - var file, options; | ||
| 120 | 116 | ||
| 121 | 117 | const data = '\u2026\u2026'; // 3 bytes * 2 = 6 bytes in UTF-8 | |
| 122 | 118 | ||
| 123 | - options = { start: 10, | ||
| 124 | - flags: 'r+' }; | ||
| 125 | - file = fs.createWriteStream(filepath, options); | ||
| 119 | + const options = { start: 10, | ||
| 120 | + flags: 'r+' }; | ||
| 121 | + const file = fs.createWriteStream(filepath, options); | ||
| 126 | 122 | console.log(' (debug: start ', file.start); | |
| 127 | 123 | console.log(' (debug: pos ', file.pos); | |
| 128 | 124 | ||
@@ -139,7 +135,7 @@ function run_test_3() { | |||
| 139 | 135 | const fileData = fs.readFileSync(filepath, 'utf8'); | |
| 140 | 136 | console.log(' (debug: file data ', fileData); | |
| 141 | 137 | console.log(' (debug: expected ', fileDataExpected_3); | |
| 142 | - assert.equal(fileData, fileDataExpected_3); | ||
| 138 | + assert.strictEqual(fileData, fileDataExpected_3); | ||
| 143 | 139 | ||
| 144 | 140 | run_test_4(); | |
| 145 | 141 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments