Teddy Katz
fdb35d8960
assert: ensure .rejects() disallows sync throws
...
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.
Fixes: https://github.com/nodejs/node/issues/19646
PR-URL: https://github.com/nodejs/node/pull/19650
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-04-03 22:41:01 -04:00
Ruben Bridgewater
a1c96f8e07
assert: improve assert.throws
...
This switches the assert.throws output to the one used in strict mode
if a error object is used for comparison. From now on it will show
the complete difference between two objects instead of only showing
the first failing property.
It also fixes detecting properties with a undefined value and fails
in case the thrown error does not contain the value at all.
PR-URL: https://github.com/nodejs/node/pull/19463
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-03-25 03:10:15 +02:00
Michaël Zasso
6a9f049968
tools,lib: forbid native Error constructors
...
This adds a rule that forbids the use of native Error constructors in
the `lib` directory. This is to encourage use of the `internal/errors`
mechanism. The rule is disabled for errors that are not created with
the `internal/errors` module but are still assigned an error code.
PR-URL: https://github.com/nodejs/node/pull/19373
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-03-21 20:15:33 +01:00
Brian White
3c61b87e59
assert: improve assert()/assert.ok() performance
...
PR-URL: https://github.com/nodejs/node/pull/19292
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Yuta Hiroto <hello@hiroppy.me >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-03-15 12:57:35 -04:00
Joyee Cheung
8484b40b3d
src: put bootstrappers in lib/internal/bootstrap/
...
Create `lib/internal/bootstrap/` and put bootstrappers there:
Before:
```
lib/internal
├── ...
├── bootstrap_loaders.js
└── bootstrap_node.js
```
After:
```
lib/internal
├── ...
└── bootstrap
├── loaders.js
└── node.js
```
PR-URL: https://github.com/nodejs/node/pull/19177
Refs: https://github.com/nodejs/node/pull/19112
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2018-03-15 20:50:34 +08:00
feugy
599337f43e
assert: add rejects() and doesNotReject()
...
Implement asynchronous equivalent for assert.throws() and
assert.doesNotThrow().
PR-URL: https://github.com/nodejs/node/pull/18023
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Shingo Inoue <leko.noor@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-03-11 04:58:32 +01:00
Joyee Cheung
2a9eb316a1
src: move internal loaders out of bootstrap_node.js
...
- Moves the creation of `process.binding()`, `process._linkedBinding()`
`internalBinding()` and `NativeModule` into a separate file
`lib/internal/bootstrap_loaders.js`, and documents them there.
This file will be compiled and run before `bootstrap_node.js`, which
means we now bootstrap the internal module & binding system before
actually bootstrapping Node.js.
- Rename the special ID that can be used to require `NativeModule`
as `internal/bootstrap_loaders` since it is setup there. Also put
`internalBinding` in the object exported by `NativeModule.require`
instead of putting it inside the `NativeModule.wrapper`
- Use the original `getBinding()` to get the source code of native
modules instead of getting it from `process.binding('native')`
so that users cannot fake native modules by modifying the binding
object.
- Names the bootstrapping functions so their names show up
in the stack trace.
PR-URL: https://github.com/nodejs/node/pull/19112
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
2018-03-06 22:12:46 +08:00
Michaël Zasso
1e8d110e64
lib: port errors to new system
...
This is a first batch of updates that touches non-underscored modules in
lib.
PR-URL: https://github.com/nodejs/node/pull/19034
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2018-03-05 19:51:30 +01:00
Ruben Bridgewater
cccddc59e5
assert: fix throws trace
...
The current stack trace thrown in case `assert.throws(fn, object)`
is used did not filter the stack trace. This fixes it.
PR-URL: https://github.com/nodejs/node/pull/18595
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
2018-02-09 08:45:51 -05:00
Anna Henningsen
82a7347050
doc,assert,timers: assign deprecation codes
...
Overlooked when landing the respective PRs.
PR-URL: https://github.com/nodejs/node/pull/18564
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
2018-02-06 13:57:31 +01:00
Ruben Bridgewater
a27f48d619
assert: fix generatedMessage
...
The generatedMessage was wrong in case simple assert was used and
a message was auto generated. This fixed the TODO.
PR-URL: https://github.com/nodejs/node/pull/18322
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2018-02-06 11:53:26 +01:00
Ruben Bridgewater
3e910fb8f7
assert: do not read Node.js modules
...
Prevent reading a Node.js module. That could theoretically lead to
false errors being thrown otherwise.
PR-URL: https://github.com/nodejs/node/pull/18322
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2018-02-06 11:53:25 +01:00
Ruben Bridgewater
70dcacd710
assert: deprecate assert.fail partially
...
Using `assert.fail()` with more than one argument is not intuitive
to use and has no benefit over using a message on its own.
Therefore this introduces a runtime deprecation in case it is used
in that way.
PR-URL: https://github.com/nodejs/node/pull/18418
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2018-02-02 19:05:22 +01:00
Ruben Bridgewater
3cd7977a42
assert: use a default message in assert
...
In case no arguments are passed to `assert.ok` it should just
use a default message. Otherwise `assert.ok` can not be used as
a callback.
PR-URL: https://github.com/nodejs/node/pull/18319
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Weijia Wang <starkwang@126.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2018-02-01 09:21:38 +01:00
Ruben Bridgewater
e65a6e81ef
assert: stricter ifError
...
This makes `assert.ifError` stricter by only accepting `null` and
`undefined` from now on. Before any truthy value was accepted.
PR-URL: https://github.com/nodejs/node/pull/18247
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-01-24 13:16:09 +01:00
Ruben Bridgewater
8e6e1c9dcc
assert: use destructuring for errors
...
Destructure the necessary Error classes from internal/errors.
This improves the readability of the error creation.
PR-URL: https://github.com/nodejs/node/pull/18247
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-01-24 13:16:08 +01:00
Ruben Bridgewater
72bb4445c6
assert: wrap original error in ifError
...
It is hard to know where ifError is actually triggered due to the
original error being thrown.
This changes it by wrapping the original error in a AssertionError.
This has the positive effect of also making clear that it is indeed
a assertion function that triggered that error.
The original stack can still be accessed by checking the `actual`
property.
PR-URL: https://github.com/nodejs/node/pull/18247
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-01-24 13:16:07 +01:00
Ruben Bridgewater
2d9e87695e
assert: improve error messages
...
From now on all error messages produced by `assert` in strict mode
will produce a error diff.
PR-URL: https://github.com/nodejs/node/pull/17615
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2018-01-24 13:07:34 +01:00
Ruben Bridgewater
d07c6f9739
assert: throw without args in ok
...
`assert.ok()` should always receive a value. Otherwise there
might be a bug or it was intended to use `assert.fail()`.
PR-URL: https://github.com/nodejs/node/pull/17581
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ron Korving <ron@ronkorving.nl >
2018-01-16 19:57:36 +01:00
Ruben Bridgewater
f76ef50432
assert: improve simple assert
...
This improves the error message in simple asserts by using the
real call information instead of the already evaluated part.
PR-URL: https://github.com/nodejs/node/pull/17581
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ron Korving <ron@ronkorving.nl >
2018-01-16 19:57:35 +01:00
Ben Noordhuis
71203f5230
lib: handle throw undefined in assert.throws()
...
And make `assert.doesNotThrow()` handle it as well.
PR-URL: https://github.com/nodejs/node/pull/18029
Fixes: https://github.com/nodejs/node/issues/18027
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Khaidi Chu <i@2333.moe >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-01-09 16:14:50 -08:00
Ruben Bridgewater
8578fe22a9
assert: fix strict regression
...
Using `assert()` or `assert.ok()` resulted in a error since a
refactoring.
Refs: https://github.com/nodejs/node/pull/17582
PR-URL: https://github.com/nodejs/node/pull/17903
Refs: https://github.com/nodejs/node/pull/17582
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-12-29 00:04:40 +01:00
Ruben Bridgewater
2d374916eb
assert: .throws accept objects
...
From now on it is possible to use a validation object in throws
instead of the other possibilites.
PR-URL: https://github.com/nodejs/node/pull/17584
Refs: https://github.com/nodejs/node/pull/17557
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Ron Korving <ron@ronkorving.nl >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
2017-12-21 03:01:02 -03:00
Ruben Bridgewater
da5c7d68cd
assert: improve assert.throws
...
Throw a TypeError in case a error message is provided in the second
argument and a third argument is present as well.
This is clearly a mistake and should not be done.
PR-URL: https://github.com/nodejs/node/pull/17585
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
2017-12-19 13:43:11 -03:00
Ruben Bridgewater
d9171fef3f
assert: fix throws and doesNotThrow stack frames
...
The stack frames from .throws and .doesNotThrow got included
even though that was not intended.
PR-URL: https://github.com/nodejs/node/pull/17703
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-12-19 13:03:40 -03:00
Ruben Bridgewater
7cf569a97b
assert: use object argument in innerFail
...
Right now it is difficult to know what argument stands for what
property. By refactoring the arguments into a object it is clear
what stands for what.
PR-URL: https://github.com/nodejs/node/pull/17582
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
2017-12-15 20:42:48 -02:00
Ruben Bridgewater
a6788b407b
assert: fix .throws operator
...
assert.throws and assert.doesNotThrow set the operator to a
internal function. That was by accident and originally the operator
was undefined. This changes it to show "throws" or "doesNotThrow".
PR-URL: https://github.com/nodejs/node/pull/17575
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
2017-12-15 19:21:52 -02:00
Ruben Bridgewater
9e00d8ca50
tools: prohibit notDeepEqual usage
...
PR-URL: https://github.com/nodejs/node/pull/16325
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2017-11-28 03:10:10 +01:00
Ruben Bridgewater
a319e90807
assert: add strict functionality export
...
Requireing the strict version will allow to use `assert.equal`,
`assert.deepEqual` and there negated counterparts to be used with
strict comparison instead of using e.g. `assert.strictEqual`.
The API is identical to the regular assert export and only differs
in the way that all functions use strict compairson.
PR-URL: https://github.com/nodejs/node/pull/17002
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2017-11-28 03:05:12 +01:00
Ruben Bridgewater
493340f56e
assert: use Object.is comparison in .strictEqual
...
This aligns assert.strictEqual and assert.notStrictEqual with
assert.deepStrictEqual to use the Object.is() comparison instead
of strict equality.
PR-URL: https://github.com/nodejs/node/pull/17003
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-11-22 09:16:49 -08:00
Weijia Wang
e22b8d0c46
lib: improve the usage of TypeError[INVALID_ARG_TYPE]
...
The initials of expected in TypeError[ERR_INVALID_ARG_TYPE]
are inconsistent. This change is to unify them.
PR-URL: https://github.com/nodejs/node/pull/16401
Fixes: https://github.com/nodejs/node/issues/16383
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2017-11-12 11:04:06 -08:00
Rich Trott
36732084db
util,assert: expose util.isDeepStrictEqual()
...
Provide `util.isDeepStrictEqual()` that works like
`assert.deepStrictEqual()` but returns a boolean rather than throwing an
error.
Several userland modules have needed this functionality and implemented
it independently. This functionality already exists in Node.js core, so
this exposes it for use by modules. Modules that have needed this
functionality include `lodash`, `concordance` (used by `ava`), and
`qunit`.
PR-URL: https://github.com/nodejs/node/pull/16084
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-10-25 22:30:37 -07:00
Timothy Gu
7907534a8d
lib: faster type checks for some types
...
PR-URL: https://github.com/nodejs/node/pull/15663
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-10-01 23:58:59 -03:00
Ruben Bridgewater
db2e093e05
assert: handle enumerable symbol keys
...
PR-URL: https://github.com/nodejs/node/pull/15169
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2017-09-19 20:13:02 -03:00
Ruben Bridgewater
b0d3bec95c
assert: use Same-value equality in deepStrictEqual
...
PR-URL: https://github.com/nodejs/node/pull/15398
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2017-09-15 23:37:22 -03:00
Ruben Bridgewater
22ae8c0248
assert: fix boxed primitives in deepStrictEqual
...
Unbox all primitives and compare them as well instead of
only comparing boxed strings.
PR-URL: https://github.com/nodejs/node/pull/15050
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2017-09-12 17:29:37 -03:00
geek
e13d1df89b
assert: support custom errors
...
This commit adds special handling of Error instances when passed
as the message argument to assert functions. With this commit,
if an Error is passed as the message, then that Error is thrown
instead of an AssertionError.
PR-URL: https://github.com/nodejs/node/pull/15304
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-09-12 15:02:00 -04:00
Ruben Bridgewater
ea2e6363f2
assert: use SameValueZero in deepStrictEqual
...
Comparing NaN will not throw anymore.
PR-URL: https://github.com/nodejs/node/pull/15036
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-09-05 08:15:33 -03:00
Ruben Bridgewater
204d94fc75
assert: handle errors properly with deep*Equal
...
PR-URL: https://github.com/nodejs/node/pull/15001
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-09-01 02:00:15 -03:00
Ruben Bridgewater
4381100371
assert: handle sparse arrays in deepStrictEqual
...
Detect sparse array ends and add a fail early path for
unequal array length.
PR-URL: https://github.com/nodejs/node/pull/15027
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2017-08-28 23:19:03 -03:00
Ruben Bridgewater
9aa709382a
lib: remove circular reference
...
PR-URL: https://github.com/nodejs/node/pull/14885
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-08-25 18:33:25 -03:00
Ruben Bridgewater
9222fe64ad
assert: optimize code path for deepEqual Maps
...
PR-URL: https://github.com/nodejs/node/pull/14501
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2017-08-13 13:58:11 -04:00
Ruben Bridgewater
a8149c4799
assert: fix deepEqual inconsistencies
...
PR-URL: https://github.com/nodejs/node/pull/14491
Fixes: https://github.com/nodejs/node/issues/14441
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Khaidi Chu <i@2333.moe >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2017-08-01 13:26:07 +02:00
James M Snell
355523fcfb
buffer: refactor module.exports, imports
...
* Move to more efficient module.exports pattern
* Refactor requires
* Eliminate circular dependency on internal/buffer
* Add names to some functions
* Fix circular dependency error in assert.js
PR-URL: https://github.com/nodejs/node/pull/13807
Reviewed-By: Refael Ackermann <refack@gmail.com >
2017-07-24 07:24:53 -07:00
Ruben Bridgewater
5203bb0b16
assert: improve deepEqual Set and Map worst case
...
This change improves the algorithm for the worst case from O(n^2)
to O(n log n) by using a lazily initiated set with object or
not strict equal primitives keys.
In addition a few comments got fixed and a statement simplified.
PR-URL: https://github.com/nodejs/node/pull/14258
Reviewed-By: Refael Ackermann <refack@gmail.com >
2017-07-19 19:25:46 -04:00
Ruslan Bekenev
c53db1e8e9
assert: show thrown message in doesNotThrow()
...
assert.doesNotThrow() should show actual error message instead
of "Got unwanted exception" which is not really helpful.
PR-URL: https://github.com/nodejs/node/pull/12167
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2017-07-19 15:53:26 -04:00
Ruben Bridgewater
be20e9ecfe
assert: refactor to reduce unecessary code paths
...
The lazy loading is not needed as the errors themself lazy
load assert. Therefore the circle is working as intended
even without this lazy loading.
Improve Array, object, ArrayBuffer, Set and Map performance
in all deepEqual checks by removing unecessary code paths and
by moving expensive checks further back.
Improve throws and doesNotThrow performance by removing dead
code and simplifying the overall logic.
PR-URL: https://github.com/nodejs/node/pull/13973
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2017-07-09 14:16:34 -04:00
kuroljov
6e86a70da2
assert: replace many if's with if-else statement
...
Replace multiple mutually exclusive `if` statements with if-else
statements.
PR-URL: https://github.com/nodejs/node/pull/14043
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: David Cai <davidcai1993@yahoo.com >
2017-07-05 11:55:02 +02:00
Tobias Nießen
1d7414354e
assert: fix incorrect use of ERR_INVALID_ARG_TYPE
...
PR-URL: https://github.com/nodejs/node/pull/14011
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2017-07-03 16:20:13 +02:00
Ruben Bridgewater
0455fff880
assert: refactor the code
...
1. Rename private functions
2. Use destructuring
3. Remove obsolete comments
PR-URL: https://github.com/nodejs/node/pull/13862
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2017-07-02 22:44:09 -04:00