summaryrefslogtreecommitdiff
path: root/lib/assert.js
AgeCommit message (Collapse)AuthorFilesLines
2015-06-11lib: don't use global BufferRoman Reiss1-0/+1
Port of https://github.com/joyent/node/pull/8603 The race condition present in the original PR didn't occur, so no workaround was needed. PR-URL: https://github.com/nodejs/io.js/pull/1794 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-05-09lib: fix eslint stylesYosuke Furukawa1-1/+1
PR-URL: https://github.com/iojs/io.js/pull/1539 Fixes: https://github.com/iojs/io.js/issues/1253 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-03-23assert: simplify logic of testing buffer equalityAlex Yursha1-7/+2
Delegate buffer equality check to `buffer.equals()` PR-URL: https://github.com/iojs/io.js/pull/1171 Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com> Reviewed-By: Christian Vaagland Tellnes <christian@tellnes.com>
2015-02-09assert: introduce `deepStrictEqual`Vladimir Kurchatkin1-10/+26
`deepStrictEqual` works the same way as `strictEqual`, but uses `===` to compare primitives and requires prototypes of equal objects to be the same object. Fixes: https://github.com/joyent/node/issues/7161 Fixes: https://github.com/iojs/io.js/issues/620 PR-URL: https://github.com/iojs/io.js/pull/639 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-by: Rod Vagg <rod@vagg.org>
2015-02-06assert: don't compare object `prototype` propertyVladimir Kurchatkin1-2/+0
All own enumerable properties are compared already. Comparing `prototype` property specifically can cause weird behaviour. PR-URL: https://github.com/iojs/io.js/pull/636 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31lib: reduce util.is*() usagecjihrig1-7/+7
Many of the util.is*() methods used to check data types simply compare against a single value or the result of typeof. This commit replaces calls to these methods with equivalent checks. This commit does not touch calls to the more complex methods (isRegExp(), isDate(), etc.). Fixes: https://github.com/iojs/io.js/issues/607 PR-URL: https://github.com/iojs/io.js/pull/647 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31assert: use util.inspect() to create error messagescjihrig1-15/+2
Currently, JSON.stringify() is used to create error messages on failed assertions. This causes an error when stringifying objects with circular references. This commit switches out JSON.stringify() for util.inspect(), which can handle circular references. PR-URL: https://github.com/iojs/io.js/pull/668 Reviewed-By: Julien Gilli <julien.gilli@joyent.com> Reviewed-By: Bert Belder <bertbelder@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-01-21lib: use const to define constantscjihrig1-3/+3
This commit replaces a number of var statements throughout the lib code with const statements. PR-URL: https://github.com/iojs/io.js/pull/541 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12assert: throw when block is not a functioncjihrig1-0/+4
Currently, anything passed as the block argument to throws() and doesNotThrow() is interpreted as a function, which can lead to unexpected results. This commit checks the type of block, and throws a TypeError if it is not a function. Fixes: https://github.com/iojs/io.js/issues/275 PR-URL: https://github.com/iojs/io.js/pull/308 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-22assert: fix deepEqual regressionteppeis1-9/+6
Change of Object.keys in ES6 breaks assert.deepEqual about primitive values. V8: https://code.google.com/p/v8/issues/detail?id=3443 Previously deepEqual depends on Object.key that throws an error for a primitive value, but now Object.key does not throw. PR-URL: https://github.com/iojs/io.js/pull/193 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2014-11-22lib: turn on strict modeBen Noordhuis1-0/+2
Turn on strict mode for the files in the lib/ directory. It helps catch bugs and can have a positive effect on performance. PR-URL: https://github.com/node-forward/node/pull/64 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-07-29Merge remote-tracking branch 'origin/v0.10' into masterFedor Indutny1-1/+1
Conflicts: doc/api/buffer.markdown lib/_stream_readable.js lib/assert.js lib/buffer.js lib/child_process.js lib/http.js lib/string_decoder.js lib/zlib.js node.gyp test/simple/test-buffer.js test/simple/test-https-foafssl.js test/simple/test-stream2-compatibility.js test/simple/test-tls-server-verify.js
2014-07-10lib: remove and restructure calls to isNaN()cjihrig1-1/+1
Switch condition order to check for null before calling isNaN(). Also remove two unnecessary calls to isNaN() that are already covered by calls to isFinite(). This commit targets v0.10, as opposed to #7891, which targets master (suggested by @bnoordhuis). Closes #7840. Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-03-02Merge remote-tracking branch 'origin/v0.10'Fedor Indutny1-4/+5
Conflicts: configure lib/_stream_readable.js lib/http.js src/node_dtrace.cc
2014-02-25assert: Ensure reflexivity of deepEqualMike Pennisi1-4/+5
Ensure that the behavior of `assert.deepEqual` does not depend on argument ordering when comparing an `arguments` object with a non-`arguments` object.
2013-10-11assert: indicate if exception message is generatedGlen Mailer1-1/+7
AssertionError.generatedMessage is now true when AssertionError.message was generated from expected and actual Fixes #5836, #6206
2013-08-01src: Replace macros with util functionsisaacs1-10/+10
2013-07-30assert: replace !!!value with just !valueBen Noordhuis1-1/+1
Not harmful, just code cleanup. Fixes #5885.
2013-07-24lib: macro-ify type checksBen Noordhuis1-14/+10
Increases the grep factor. Makes it easier to harmonize type checks across the code base.
2013-05-14lintisaacs1-1/+1
2013-04-19lintisaacs1-1/+1
2013-04-18assert: put info in err.message, not err.nameRyan Doenges1-12/+6
4716dc6 made assert.equal() and related functions work better by generating a better toString() from the expected, actual, and operator values passed to fail(). Unfortunately, this was accomplished by putting the generated message into the error's `name` property. When you passed in a custom error message, the error would put the custom error into `name` *and* `message`, resulting in helpful string representations like "AssertionError: Oh no: Oh no". This commit resolves that issue by storing the generated message in the `message` property while leaving the error's name alone and adding a regression test so that this doesn't pop back up later. Closes #5292.
2013-04-03assert: Simplify AssertError creationisaacs1-14/+10
2012-12-29assert: improve support for new execution contextslukebayes1-1/+1
More detailed information in GH-693
2012-08-29doc: update assert.doesNotThrow() docsBen Noordhuis1-1/+1
It takes an optional "expected exception" argument that is not used meaningfully but is nevertheless documented. Undocument it, it confuses casual readers of the documentation. Fixes #3935.
2012-07-29assert: fix throws() throws an error without message propertykoichik1-2/+2
Fixes #2893.
2012-07-25assert: remove unnecessary use of __proto__Nathan Rajlich1-4/+2
AssertionError already inherits from Error above using util.inherits(), so this extra line was redundant. test/simple/test-assert.js already tests for `instanceof`, and still passes.
2012-03-12docs: correct the description of assert.ok()Nao Iizuka1-1/+1
2011-12-20assert: test `RegExp`'s properties when checking for equalityMaciej Małecki1-2/+7
Previous code ignored the fact that `/a/ != /a/g`. Test case included.
2011-12-20assert: .deepEqual() support for RegExp objectsPedro Teixeira1-2/+7
2011-10-05Fixed a lot of jslint errors.Colton Baker1-2/+2
Fixes #1831
2011-10-02assert: Make `assert` module an `assert.ok` functionMaciej Małecki1-2/+3
Code can be written: var assert = require('assert'); assert(true); instead of: var assert = require('assert'); assert.ok(true);
2011-08-09Improve assert error messagesRyan Dahl1-17/+28
1. actual and expected should be displayed in the same order they were given 2. long values should be truncated.
2011-07-14Improvements AssertionError messagekoichik1-2/+14
Fixes #217.
2011-01-06LintRyan Dahl1-1/+1
2010-12-21fix assert.throwsOleg Slobodskoi1-5/+6
2010-12-01lintRyan Dahl1-41/+43
2010-11-29assert.throws can now accept as RegExpOleg Slobodskoi1-30/+33
makes validation of errors more flexible
2010-10-11Soft migration of sys -> util, Removal of deprecated utils module.Micheil Smith1-2/+2
2010-10-06syntax fixes to pass jslintJoshaven Potter1-2/+2
2010-09-07Special deepEquals for bufferRyan Dahl1-0/+9
2010-05-21Add assert.ifErrorMikeal Rogers1-0/+1
2010-04-11trailing whitespace fixesisaacs1-1/+1
2010-03-15Include lib/ directory in node executable. Compile on demand.Ryan Dahl1-3/+3
Instead of installing the files in /usr/lib/node/libraries and loading them from the file system, the files are built-in to the node executable. However, they are only compiled on demand. The reasoning is: 1. Allow for more complex internal javascript. In particular, process.stdout and process.stdin can be js implemented streams. 2. Ease system installs. Loading from disk each time is unnecessary overhead. Note that there is no "system" path for modules anymore. Only $HOME/.node_libraries.
2010-03-01Move process.inherits to sysRyan Dahl1-2/+2
2010-01-24Make assert.AssertionError instance of ErrorRyan Dahl1-0/+1
2009-12-29Stack trace for asserts shouldn't include assert moduleRyan Dahl1-24/+22
2009-12-29Fix assert.js code styleRyan Dahl1-155/+156
2009-12-05Dependency free assert module with unit testsKarl Guertin1-50/+160
2009-12-05CommonJS testing for node.jsFelix Geisendörfer1-0/+176
Refactored test suite to use the assert module for testing rather than mjsunit.