caolan / caolan/nodeunit

test.equal prints values in incorrect order for Boolean values

Open
#175 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.9k
Forks
359
PR merge metrics
No merged PRs in 30d

Description

test.equal(1, 2) prints values in this order
test.equal(false, true) prints values in reverse order
## reproduction printout

```
$ nodeunit ../nodejs3/snippets/modules/nodeunit/nodeunit-order.js

nodeunit-order.js
assert module works as expected
BUG: As of nodeunit 0.7.4, the order of the boolean values is swapped.
The second error should be "AssertionError: false == true" not "AssertionError: true == false"
✖ f

AssertionError: 1 == 2
at Object.assertWrapper [as equal] (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at Object.module.exports.f (/home/foxyboy/Desktop/c505/node/nodejs3/snippets/modules/nodeunit/nodeunit-order.js:25:7)
at Object.wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at Object.exports.runTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:69:9)
at exports.runSuite (/usr/local/lib/node_modules/nodeunit/lib/core.js:117:25)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:508:13)
at async.forEachSeries.iterate (/usr/local/lib/node_modules/nodeunit/deps/async.js:118:13)
at async.forEachSeries (/usr/local/lib/node_modules/nodeunit/deps/async.js:134:9)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:507:9)

AssertionError: true == false
at Object.assertWrapper [as equal] (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at Object.module.exports.f (/home/foxyboy/Desktop/c505/node/nodejs3/snippets/modules/nodeunit/nodeunit-order.js:26:7)
at Object.wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at Object.exports.runTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:69:9)
at exports.runSuite (/usr/local/lib/node_modules/nodeunit/lib/core.js:117:25)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:508:13)
at async.forEachSeries.iterate (/usr/local/lib/node_modules/nodeunit/deps/async.js:118:13)
at async.forEachSeries (/usr/local/lib/node_modules/nodeunit/deps/async.js:134:9)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:507:9)

FAILURES: 2/2 assertions failed (4ms)
```
## reproduction code

``` js
// nodeunit-order.js

var assert = require('assert')

module.exports.f = function (test) {

// check assert
try {
assert.equal(1, 2)
} catch(e) {
if (e.toString() != 'AssertionError: 1 == 2') throw Error()
}
try {
assert.equal(false, true)
} catch(e) {
if (e.toString() != 'AssertionError: false == true') throw Error(e)
}
console.log('assert module works as expected')

console.log('BUG: As of nodeunit 0.7.4, the order of the boolean values is swapped.')
console.log('The second error should be ' +
'"AssertionError: false == true"' +
' not ' +
'"AssertionError: true == false"')
test.equal(1, 2)
test.equal(false, true)
test.done()
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.