diff --git a/src/ast/conditions.js b/src/ast/conditions.js index e3d905f..e544e43 100644 --- a/src/ast/conditions.js +++ b/src/ast/conditions.js @@ -8,8 +8,8 @@ function isNotEqualTest ( node ) { function nodesAreEqual ( a, b ) { if ( a.type !== b.type ) return false; - if ( a.type === 'Literal' ) return a.value === b.value; - if ( a.type === 'Identifier' ) return a.name === b.name; + if ( a.type === 'Literal' ) return a.value === b.value + if ( a.type === 'Identifier' ) return a.name === b.name && a.name !== 'NaN'; return false; } @@ -17,7 +17,7 @@ function nodesAreEqual ( a, b ) { function nodesAreNotEqual ( a, b ) { if ( a.type !== b.type ) return false; if ( a.type === 'Literal' ) return a.value != b.value; - if ( a.type === 'Identifier' ) return a.name != b.name; + if ( a.type === 'Identifier' ) return a.name != b.name || a.name === 'NaN'; return false; } diff --git a/test/function/skips-dead-branches-d/_config.js b/test/function/skips-dead-branches-d/_config.js index 47111d5..3cc97d3 100644 --- a/test/function/skips-dead-branches-d/_config.js +++ b/test/function/skips-dead-branches-d/_config.js @@ -1,7 +1,7 @@ var assert = require( 'assert' ); module.exports = { - description: 'skips a dead branch (c)', + description: 'skips a dead branch (d)', code: function ( code ) { assert.equal( code.indexOf( 'obj.foo = function' ), -1, code ); } diff --git a/test/function/skips-dead-branches-e/_config.js b/test/function/skips-dead-branches-e/_config.js index 47111d5..15deabf 100644 --- a/test/function/skips-dead-branches-e/_config.js +++ b/test/function/skips-dead-branches-e/_config.js @@ -1,7 +1,7 @@ var assert = require( 'assert' ); module.exports = { - description: 'skips a dead branch (c)', + description: 'skips a dead branch (e)', code: function ( code ) { assert.equal( code.indexOf( 'obj.foo = function' ), -1, code ); } diff --git a/test/function/skips-dead-branches-f/_config.js b/test/function/skips-dead-branches-f/_config.js new file mode 100644 index 0000000..7893ccb --- /dev/null +++ b/test/function/skips-dead-branches-f/_config.js @@ -0,0 +1,9 @@ +var assert = require( 'assert' ); + +module.exports = { + solo: true, + description: 'skips a dead branch (f)', + code: function ( code ) { + assert.equal( code.indexOf( 'obj.foo = function' ), -1, code ); + } +} diff --git a/test/function/skips-dead-branches-f/main.js b/test/function/skips-dead-branches-f/main.js new file mode 100644 index 0000000..ab95b46 --- /dev/null +++ b/test/function/skips-dead-branches-f/main.js @@ -0,0 +1,11 @@ +var obj = {}; +obj.foo = function () { + console.log( 'this should be excluded' ); +} + +function bar () { + console.log( 'this should be included' ); +} + +if ( NaN === NaN ) obj.foo(); +bar();