Browse Source

remove identifier comparison checks

better-aggressive
Rich Harris 9 years ago
parent
commit
9c8f12d49c
  1. 1
      src/ast/conditions.js
  2. 2
      test/function/skips-dead-branches-f/_config.js
  3. 2
      test/function/skips-dead-branches-f/main.js
  4. 8
      test/function/skips-dead-branches-g/_config.js
  5. 11
      test/function/skips-dead-branches-g/main.js

1
src/ast/conditions.js

@ -14,7 +14,6 @@ function not ( value ) {
function equals ( a, b, strict ) {
if ( a.type !== b.type ) return undefined;
if ( a.type === 'Identifier' ) return a.name === b.name && a.name !== 'NaN';
if ( a.type === 'Literal' ) return strict ? a.value === b.value : a.value == b.value;
}

2
test/function/skips-dead-branches-f/_config.js

@ -1,7 +1,7 @@
var assert = require( 'assert' );
module.exports = {
description: 'skips a dead branch (f)',
description: 'skips a dead branch (g)',
code: function ( code ) {
assert.equal( code.indexOf( 'obj.foo = function' ), -1, code );
}

2
test/function/skips-dead-branches-f/main.js

@ -7,5 +7,5 @@ function bar () {
console.log( 'this should be included' );
}
if ( NaN === NaN ) obj.foo();
if ( 42 != '42' ) obj.foo();
bar();

8
test/function/skips-dead-branches-g/_config.js

@ -1,8 +0,0 @@
var assert = require( 'assert' );
module.exports = {
description: 'skips a dead branch (g)',
code: function ( code ) {
assert.equal( code.indexOf( 'obj.foo = function' ), -1, code );
}
}

11
test/function/skips-dead-branches-g/main.js

@ -1,11 +0,0 @@
var obj = {};
obj.foo = function () {
console.log( 'this should be excluded' );
}
function bar () {
console.log( 'this should be included' );
}
if ( 42 != '42' ) obj.foo();
bar();
Loading…
Cancel
Save