summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-read.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2017-02-03 04:06:25 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2017-02-27 18:39:40 +0800
commit562cf5a81c213f893a4787d1143e322c720e0eb9 (patch)
treed753cb46dd7c9b948f3184d5b05aa76039021ab4 /test/parallel/test-fs-read.js
parent813b312b0efaff3ff0301967075a8ad7ddc226a8 (diff)
downloadandroid-node-v8-562cf5a81c213f893a4787d1143e322c720e0eb9.tar.gz
android-node-v8-562cf5a81c213f893a4787d1143e322c720e0eb9.tar.bz2
android-node-v8-562cf5a81c213f893a4787d1143e322c720e0eb9.zip
assert: fix premature deep strict comparison
Refactors _deepEqual and fixes a few code paths that lead to behaviors contradicting what the doc says. Before this commit certain types of objects (Buffers, Dates, etc.) are not checked properly, and can get away with different prototypes AND different enumerable owned properties because _deepEqual would jump to premature conclusion for them. Since we no longer follow CommonJS unit testing spec, the checks for primitives and object prototypes are moved forward for faster failure. Improve regexp and float* array checks: * Don't compare lastIndex of regexps, because they are not enumerable, so according to the docs they should not be compared * Compare flags of regexps instead of separate properties * Use built-in tags to test for float* arrays instead of using instanceof Use full link to the archived GitHub repository. Use util.objectToString for future improvements to that function that makes sure the call won't be tampered with. PR-URL: https://github.com/nodejs/node/pull/11128 Refs: https://github.com/nodejs/node/pull/10282#issuecomment-274267895 Refs: https://github.com/nodejs/node/issues/10258#issuecomment-266963234 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test/parallel/test-fs-read.js')
-rw-r--r--test/parallel/test-fs-read.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/parallel/test-fs-read.js b/test/parallel/test-fs-read.js
index 733be5ba0d..350f287f79 100644
--- a/test/parallel/test-fs-read.js
+++ b/test/parallel/test-fs-read.js
@@ -18,11 +18,11 @@ function test(bufferAsync, bufferSync, expected) {
common.mustCall((err, bytesRead) => {
assert.ifError(err);
assert.strictEqual(bytesRead, expected.length);
- assert.deepStrictEqual(bufferAsync, Buffer.from(expected));
+ assert.deepStrictEqual(bufferAsync, expected);
}));
const r = fs.readSync(fd, bufferSync, 0, expected.length, 0);
- assert.deepStrictEqual(bufferSync, Buffer.from(expected));
+ assert.deepStrictEqual(bufferSync, expected);
assert.strictEqual(r, expected.length);
}