Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
4a077cc
deps: backport 7c3748a from upstream V8
cristiancavalli Jan 18, 2017
9b35715
build: don't squash signal handlers with --shared
Dec 30, 2016
6e8edf9
crypto: fix handling of root_cert_store.
agl Oct 30, 2016
01280a0
src: fix memory leak introduced in 34febfbf4
bnoordhuis Nov 14, 2016
a118bb8
src: use ABORT() macro instead of abort()
evanlucas Nov 15, 2016
6fa3c73
crypto: use CHECK_NE instead of ABORT or abort
sam-github Dec 22, 2016
3b11d89
test: exclude pseudo-tty test pertinent to #11541
gireeshpunathil Feb 28, 2017
94964d0
constants: define ENGINE_METHOD_RSA
sam-github Feb 27, 2016
98d6b3f
doc: correct name of engine methods
sam-github Jan 25, 2017
b264cf2
http: reject control characters in http.request()
bnoordhuis Oct 4, 2016
67f7281
test: simplify test-http-client-unescaped-path
rvagg Nov 17, 2016
756cc91
build: Don't regenerate node symlink
Nov 28, 2016
aff1a92
build: fix node_g target
danbev Dec 6, 2016
c82e5b2
doc: improve rinfo object documentation
Dec 1, 2016
61a0e9e
doc: update LTS info for current releases
evanlucas Jan 10, 2017
a2cf0cb
doc: "s/git apply/git am -3" in V8 guide
MylesBorins Jan 6, 2017
b2da62f
doc: add test naming information to guide
Trott Jan 3, 2017
aa6320f
doc: sort require statements in tests
sam-github Jan 4, 2017
a88aa0b
doc: add links for zlib convenience methods
addaleax Jan 16, 2017
3272eec
doc: clarifying variables in fs.write()
jalafel Nov 24, 2016
3a72096
doc: add edsadr to collaborators
edsadr Jan 18, 2017
d488813
doc: add TimothyGu to collaborators
TimothyGu Jan 22, 2017
7d3001d
doc: update AUTHORS list to fix name
Jan 22, 2017
6deb562
test: refactor test-https-truncate
Trott Dec 11, 2016
7d71316
lib,src: support values > 4GB in heap statistics
bnoordhuis Dec 8, 2016
0db73fd
doc: update TheAlphaNerd to MylesBorins
MylesBorins Jan 3, 2017
33a3861
assert: update comments
Jan 2, 2017
deaf3f6
benchmark: improve readability of net benchmarks
mscdex Dec 25, 2016
71ae03b
meta: decharter the http working group
jasnell Jan 4, 2017
7d0f808
net: prefer === to ==
notarseniy Feb 22, 2017
f16dd61
doc: document clientRequest.aborted
zbjornson Feb 24, 2017
67a6b13
test: favor assertions over console logging
Trott Feb 25, 2017
4403975
doc: argument types for assert methods
ameliavoncat Feb 25, 2017
e95d87f
assert: apply minor refactoring
Trott Feb 22, 2017
d481996
test: fix flaky test-vm-timeout-rethrow
kunalspathak Feb 24, 2017
4af3da9
doc: note message event listeners ref IPC channels
DiegoRBaquero Feb 22, 2017
e2af074
test: throw check in test-zlib-write-after-close
Feb 21, 2017
df5f7d4
build: fail on CI if leftover processes
Trott Feb 9, 2017
eb8d406
src: update http-parser link
danbev Feb 21, 2017
b3c6d97
build: fix newlines in addon build output
mscdex Feb 20, 2017
0479885
tty: avoid oob warning in TTYWrap::GetWindowSize()
reklatsmasters Feb 18, 2017
6ed16c6
tls: do not crash on STARTTLS when OCSP requested
indutny Jan 9, 2017
69a423b
benchmark: add dgram bind(+/- params) benchmark
vsemozhetbyt Feb 11, 2017
5ac7be8
test: add regex check to test-module-loading
tarang9211 Feb 16, 2017
ebb3a09
doc: add comment for net.Server's error event
jjqq2013 Feb 12, 2017
4a642b9
test: improve coverage in test-crypto.dh
ejc-main Feb 9, 2017
a7d5edb
test: refactor test-http-response-splitting
notarseniy Feb 16, 2017
6316e53
child_process: refactor internal/child_process.js
notarseniy Feb 14, 2017
ab982e7
child_process: remove empty if condition
cjihrig Feb 16, 2017
769a737
test: remove unused args and comparison fix
sashashakun Feb 14, 2017
d13e043
doc: add STYLE_GUIDE (moved from nodejs/docs)
gibfahn Feb 12, 2017
7fce8f8
doc: change STYLE-GUIDE to STYLE_GUIDE
Dean-Coakley Feb 20, 2017
936d6f2
tools: suggest python2 command in configure
silverwind Feb 15, 2017
6d03af4
test: refactor test-dgram-membership
Trott Feb 14, 2017
eaad395
test: improve message in net-connect-local-error
Trott Feb 15, 2017
f6ddf8f
doc: dns examples implied string args were arrays
sam-github Feb 13, 2017
488cb02
assert: remove unneeded condition
Trott Feb 11, 2017
e652927
assert: unlock the assert API
Trott Feb 10, 2017
dbcae5a
test: improve crypto coverage
akito0107 Feb 10, 2017
39a184c
doc: update code examples in domain.md
vsemozhetbyt Feb 1, 2017
280bae4
src: remove unused typedef
bnoordhuis Feb 12, 2017
ee93460
test: add coverage for dgram _createSocketHandle()
cjihrig Feb 10, 2017
afa1219
test: improve punycode test coverage
seppevs Feb 3, 2017
0d180e0
doc: update email and add personal pronoun
JungMinu Feb 12, 2017
3a30105
meta: adding Italo A. Casas PGP Fingerprint
Feb 6, 2017
16b7bf2
test: add vm module edge cases
fhinkel Feb 9, 2017
886a7a5
meta: remove Chris Dickinson from CTC
chrisdickinson Feb 9, 2017
5f041d1
doc: drop "and io.js" from release section
bnoordhuis Jan 28, 2017
51702ef
doc: improve consistency in documentation titles
vsemozhetbyt Feb 7, 2017
cd2b3ab
doc: clarify the behavior of Buffer.byteLength
seishun Feb 9, 2017
25be1df
tools: add compile_commands.json gyp generator
bnoordhuis Aug 5, 2016
1c87bfb
doc: add and fix System Error properties
darai0512 Jan 24, 2017
25eaeb6
doc: fix typo in dgram doc
Trott Feb 5, 2017
b47b8f5
build: disable C4267 conversion compiler warning
bnoordhuis Feb 6, 2017
888ca4a
test: increase specificity in dgram test
Trott Feb 5, 2017
7e3bd8e
doc: remove extraneous paragraph from assert doc
Trott Feb 5, 2017
660137e
doc: improve testing guide
joyeecheung Feb 3, 2017
a3e7461
doc: add not-an-aardvark as ESLint contact
Trott Feb 4, 2017
761b8dd
meta: add explicit deprecation and semver-major policy
jasnell Aug 3, 2016
d6b8e75
doc: typographical fixes in COLLABORATOR_GUIDE.md
addaleax Feb 4, 2017
c47c764
doc: fix "initial delay" link in http.md
Krinkle Feb 1, 2017
8394093
doc: remove assertions about assert
Trott Feb 2, 2017
6f81f99
doc: edit stability text for clarity and style
Trott Feb 2, 2017
e18a138
doc: clarify msg when doc/api/cli.md not updated
Jan 18, 2017
f12fd17
doc: add personal pronouns option
Trott Jan 31, 2017
8a76705
src: unconsume stream fix in internal http impl
Kasher Jan 26, 2017
92e2767
readline: update 6 comparions to strict
umairishaq Jan 31, 2017
d9607c2
crypto: Remove expired certs from CNNIC whitelist
shigeki Nov 4, 2016
f87a422
crypto: add cert check issued by StartCom/WoSign
shigeki Nov 4, 2016
039f3f4
test: improve coverage on removeListeners functions
Feb 3, 2017
39872c5
test: improve error messages in test-npm-install
gonenduk Jan 26, 2017
b1d9028
doc: fix confusing example in dns.md
vsemozhetbyt Jan 26, 2017
1e5b40c
doc: edit CONTRIBUTING.md for clarity
Trott Jan 27, 2017
88415b7
doc: correct and complete dgram's Socket.bind docs
strugee Jan 26, 2017
a228c34
doc: add who to CC list for dgram
cjihrig Jan 27, 2017
dfff9d1
doc: fix typo in http.md
magnetikonline Jan 24, 2017
22f7e23
test: add 2nd argument to throws in test-assert
Marlena Jan 29, 2017
d14d262
test: require handler to be run in sigwinch test
Trott Jan 30, 2017
a0f1b23
test: refactor test-fs-utimes
jun-oka Oct 26, 2016
05b048c
test: improve test-fs-readfile-zero-byte-liar
edsadr Jan 2, 2017
2941672
test: improve test-http-chunked-304
edsadr Jan 7, 2017
166ac14
test: refactor the code in test-child-process-spawn-loop.js
sivaprs Jan 4, 2017
743bdf9
test: refactor test-watch-file.js
sivaprs Jan 7, 2017
4a9a43c
test: refactor test-doctool-html.js
hiroppy Jan 8, 2017
0262497
test: refactor the code of test-keep-alive.js
sivaprs Jan 8, 2017
6361e35
src: enable writev for pipe handles on Unix
aqrln Jan 7, 2017
1866b68
benchmark: don't lint autogenerated modules
mscdex Jan 12, 2017
28e0762
test: use realpath for NODE_TEST_DIR in common.js
gibfahn Jan 10, 2017
4cca3f2
test: fix temp-dir option in tools/test.py
gibfahn Jan 10, 2017
9aeb34a
readline: refactor construct Interface
JacksonTian Jan 18, 2016
f68fb7c
test: improve tests in pummel/test-exec
chasestarr Jan 12, 2017
b74fb85
doc: remove duplicate properties bullet in readme
trendsetter37 Jan 11, 2017
4f6b8bf
test: improve the code in test-process-cpuUsage
edsadr Jan 12, 2017
fe316c4
build: move source files from headers section
danbev Jan 17, 2017
385e3fe
test: tests for _readableStream.awaitDrain
shmuga Jan 17, 2017
43bc890
test: add http-common's test
hiroppy Jan 16, 2017
8a21d2a
test: add message verification on assert.throws
tmeisenh Jan 19, 2017
f735344
crypto: freelist_max_len is gone in OpenSSL 1.1.0
agl Jan 17, 2017
de1faeb
src: add a missing space in node_os.cc
aqrln Jan 21, 2017
df8438a
test: check fd 0,1,2 are used, not access mode
jBarz Dec 16, 2016
6c11106
test: increase coverage for punycode's decode
hiroppy Jan 21, 2017
7c186da
test: improve test-assert
richnologies Jan 20, 2017
6c91914
buffer: improve toJSON() performance
mscdex Jan 19, 2017
abee209
test: don't connect to :: (use localhost instead)
gibfahn Jan 17, 2017
beb0943
test: test hmac binding robustness
sam-github Jan 20, 2017
ba0b838
tools: rename eslintrc to an undeprecated format
thefourtheye Jul 13, 2016
d04c7ff
test: refactor cluster-preload.js
hiroppy Jan 9, 2017
65b7200
test: improve code in test-http-host-headers
edsadr Jan 16, 2017
562f23f
test: improve test-stream2-large-read-stall
stefanjudis Jan 10, 2017
5294723
test: improve code in test-domain-multi
edsadr Jan 15, 2017
a7a8681
test: improve code in test-console-instance
edsadr Jan 17, 2017
eb74100
test: improving coverage for dgram
hiroppy Jan 13, 2017
535a424
test: add dgram.Socket.prototype.bind's test
hiroppy Jan 19, 2017
5e5a38d
test: improve code in test-crypto-verify
edsadr Jan 20, 2017
0277eea
crypto: return the retval of HMAC_Update
tmeisenh Jan 19, 2017
1e96c8d
test: add process.assert's test
hiroppy Jan 20, 2017
cfbbf64
tools,doc: add Google Analytics tracking.
phillipj Jan 25, 2017
f866bac
test: enhance test-timers
Trott Jan 23, 2017
c6fa7b6
benchmark: add benchmark for object properties
targos Jan 21, 2017
10e06d1
test: expand test coverage of fs.js
vinimdocarmo Jan 23, 2017
dc207cd
benchmark: add more thorough timers benchmarks
Fishrock123 Jan 20, 2017
5cb1b05
test: allow for slow hosts in spawnSync() test
Trott Jan 25, 2017
f69d94b
test: increase coverage for stream's duplex
hiroppy Jan 23, 2017
b5985f4
doc: remove Chris Dickinson from active releasers
bnoordhuis Jan 26, 2017
bbf2484
test: add known_issues test for #10223
AnnaMag Jan 26, 2017
67f9f85
test: increase setMulticastLoopback() coverage
cjihrig Feb 10, 2017
281999e
util: don't init Debug if it's not needed yet
bengl Sep 8, 2016
b8629f7
dgram: fix possibly deoptimizing use of arguments
vsemozhetbyt Feb 8, 2017
0fe9ac3
http: make request.abort() destroy the socket
lpinca Jan 15, 2017
ffde243
doc: handle backpressure when write() return false
mcollina Jan 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
assert: update comments
Remove the numbers from the comments to make it clear that
assert does not follow the
[CJS spec](http://wiki.commonjs.org/wiki/Unit_Testing/1.0).
Additionally, clean up the existing comments for consistent
formatting/language and ease of reading.

PR-URL: #10579
Fixes: #9063
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
Kai Cataldo authored and MylesBorins committed Mar 7, 2017
commit 33a3861cb8eaebb03e4bafa138d63ab1de89be36
74 changes: 42 additions & 32 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ const util = require('util');
const Buffer = require('buffer').Buffer;
const pToString = (obj) => Object.prototype.toString.call(obj);

// 1. The assert module provides functions that throw
// The assert module provides functions that throw
// AssertionError's when particular conditions are not met. The
// assert module must conform to the following interface.

const assert = module.exports = ok;

// 2. The AssertionError is defined in assert.
// The AssertionError is defined in assert.
// new assert.AssertionError({ message: message,
// actual: actual,
// expected: expected })
// expected: expected });

assert.AssertionError = function AssertionError(options) {
this.name = 'AssertionError';
Expand Down Expand Up @@ -75,7 +75,7 @@ function getMessage(self) {
// other keys to the AssertionError's constructor - they will be
// ignored.

// 3. All of the following functions must throw an AssertionError
// All of the following functions must throw an AssertionError
// when a corresponding condition is not met, with a message that
// may be undefined if not provided. All assertion methods provide
// both the actual and expected values to the assertion error for
Expand All @@ -94,7 +94,7 @@ function fail(actual, expected, message, operator, stackStartFunction) {
// EXTENSION! allows for well behaved errors defined elsewhere.
assert.fail = fail;

// 4. Pure assertion tests whether a value is truthy, as determined
// Pure assertion tests whether a value is truthy, as determined
// by !!guard.
// assert.ok(guard, message_opt);
// This statement is equivalent to assert.equal(true, !!guard,
Expand All @@ -106,24 +106,25 @@ function ok(value, message) {
}
assert.ok = ok;

// 5. The equality assertion tests shallow, coercive equality with
// The equality assertion tests shallow, coercive equality with
// ==.
// assert.equal(actual, expected, message_opt);

assert.equal = function equal(actual, expected, message) {
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
};

// 6. The non-equality assertion tests for whether two objects are not equal
// with != assert.notEqual(actual, expected, message_opt);
// The non-equality assertion tests for whether two objects are not
// equal with !=.
// assert.notEqual(actual, expected, message_opt);

assert.notEqual = function notEqual(actual, expected, message) {
if (actual == expected) {
fail(actual, expected, message, '!=', assert.notEqual);
}
};

// 7. The equivalence assertion tests a deep equality relation.
// The equivalence assertion tests a deep equality relation.
// assert.deepEqual(actual, expected, message_opt);

assert.deepEqual = function deepEqual(actual, expected, message) {
Expand All @@ -139,18 +140,22 @@ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
};

function _deepEqual(actual, expected, strict, memos) {
// 7.1. All identical values are equivalent, as determined by ===.
// All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;

// If both values are instances of buffers, equivalence is
// determined by comparing the values and ensuring the result
// === 0.
} else if (actual instanceof Buffer && expected instanceof Buffer) {
return compare(actual, expected) === 0;

// 7.2. If the expected value is a Date object, the actual value is
// If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
} else if (util.isDate(actual) && util.isDate(expected)) {
return actual.getTime() === expected.getTime();

// 7.3 If the expected value is a RegExp object, the actual value is
// If the expected value is a RegExp object, the actual value is
// equivalent if it is also a RegExp object with the same source and
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
Expand All @@ -160,18 +165,18 @@ function _deepEqual(actual, expected, strict, memos) {
actual.lastIndex === expected.lastIndex &&
actual.ignoreCase === expected.ignoreCase;

// 7.4. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
// If both values are primitives, equivalence is determined by
// == or, if checking for strict equivalence, ===.
} else if ((actual === null || typeof actual !== 'object') &&
(expected === null || typeof expected !== 'object')) {
return strict ? actual === expected : actual == expected;

// If both values are instances of typed arrays, wrap their underlying
// ArrayBuffers in a Buffer each to increase performance
// ArrayBuffers in a Buffer to increase performance.
// This optimization requires the arrays to have the same type as checked by
// Object.prototype.toString (aka pToString). Never perform binary
// comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
// bit patterns are not identical.
// Object.prototype.toString (pToString). Never perform binary
// comparisons for Float*Arrays, though, since +0 === -0 is true despite the
// two values' bit patterns not being identical.
} else if (ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected) &&
pToString(actual) === pToString(expected) &&
!(actual instanceof Float32Array ||
Expand All @@ -184,7 +189,7 @@ function _deepEqual(actual, expected, strict, memos) {
expected.byteOffset +
expected.byteLength)) === 0;

// 7.5 For all other Object pairs, including Array objects, equivalence is
// For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
Expand Down Expand Up @@ -214,7 +219,8 @@ function isArguments(object) {
function objEquiv(a, b, strict, actualVisitedObjects) {
if (a === null || a === undefined || b === null || b === undefined)
return false;
// if one is a primitive, the other must be same

// If one is a primitive, the other must be the same.
if (util.isPrimitive(a) || util.isPrimitive(b))
return a === b;
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
Expand All @@ -226,20 +232,23 @@ function objEquiv(a, b, strict, actualVisitedObjects) {
const ka = Object.keys(a);
const kb = Object.keys(b);
var key, i;
// having the same number of owned properties (keys incorporates
// hasOwnProperty)

// The pair must have the same number of owned properties (keys
// incorporates hasOwnProperty).
if (ka.length !== kb.length)
return false;
//the same set of keys (although not necessarily the same order),

// The pair must have the same set of keys (although not
// necessarily in the same order).
ka.sort();
kb.sort();
//~~~cheap key test
// Cheap key test:
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] !== kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
// The pair must have equivalent values for every corresponding key.
// Possibly expensive deep test:
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
Expand All @@ -248,7 +257,7 @@ function objEquiv(a, b, strict, actualVisitedObjects) {
return true;
}

// 8. The non-equivalence assertion tests for any deep inequality.
// The non-equivalence assertion tests for any deep inequality.
// assert.notDeepEqual(actual, expected, message_opt);

assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
Expand All @@ -265,7 +274,7 @@ function notDeepStrictEqual(actual, expected, message) {
}


// 9. The strict equality assertion tests strict equality, as determined by ===.
// The strict equality assertion tests strict equality, as determined by ===.
// assert.strictEqual(actual, expected, message_opt);

assert.strictEqual = function strictEqual(actual, expected, message) {
Expand All @@ -274,8 +283,9 @@ assert.strictEqual = function strictEqual(actual, expected, message) {
}
};

// 10. The strict non-equality assertion tests for strict inequality, as
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
// The strict non-equality assertion tests for strict inequality, as
// determined by !==.
// assert.notStrictEqual(actual, expected, message_opt);

assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
if (actual === expected) {
Expand All @@ -297,7 +307,7 @@ function expectedException(actual, expected) {
return true;
}
} catch (e) {
// Ignore. The instanceof check doesn't work for arrow functions.
// Ignore. The instanceof check doesn't work for arrow functions.
}

if (Error.isPrototypeOf(expected)) {
Expand Down Expand Up @@ -355,7 +365,7 @@ function _throws(shouldThrow, block, expected, message) {
}
}

// 11. Expected to throw an error:
// Expected to throw an error.
// assert.throws(block, Error_opt, message_opt);

assert.throws = function(block, /*optional*/error, /*optional*/message) {
Expand Down