Skip to content

Commit

Permalink
* Raise maximum path depth again
Browse files Browse the repository at this point in the history
* Re-add tests cases that were previously removed
  • Loading branch information
lukastaegert committed Nov 18, 2017
1 parent 690510f commit 5c37051
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 118 deletions.
14 changes: 7 additions & 7 deletions src/ast/variables/LocalVariable.js
Expand Up @@ -2,7 +2,7 @@ import Variable from './Variable';
import VariableReassignmentTracker from './VariableReassignmentTracker';

// To avoid infinite recursions
const MAX_PATH_LENGTH = 6;
const MAX_PATH_DEPTH = 7;

export default class LocalVariable extends Variable {
constructor ( name, declarator, init ) {
Expand All @@ -18,7 +18,7 @@ export default class LocalVariable extends Variable {
}

reassignPath ( path, options ) {
if ( path.length > MAX_PATH_LENGTH ) return;
if ( path.length > MAX_PATH_DEPTH ) return;
if ( path.length === 0 ) {
this.isReassigned = true;
}
Expand All @@ -28,7 +28,7 @@ export default class LocalVariable extends Variable {
}

forEachReturnExpressionWhenCalledAtPath ( path, callOptions, callback, options ) {
if ( path.length > MAX_PATH_LENGTH ) return;
if ( path.length > MAX_PATH_DEPTH ) return;
this.boundExpressions.forEachAtPath( path, ( relativePath, node ) =>
!options.hasNodeBeenCalledAtPathWithOptions( relativePath, node, callOptions ) && node
.forEachReturnExpressionWhenCalledAtPath( relativePath, callOptions, callback,
Expand All @@ -43,7 +43,7 @@ export default class LocalVariable extends Variable {
}

hasEffectsWhenAccessedAtPath ( path, options ) {
return path.length > MAX_PATH_LENGTH
return path.length > MAX_PATH_DEPTH
|| this.boundExpressions.someAtPath( path, ( relativePath, node ) =>
relativePath.length > 0
&& !options.hasNodeBeenAccessedAtPath( relativePath, node )
Expand All @@ -52,7 +52,7 @@ export default class LocalVariable extends Variable {

hasEffectsWhenAssignedAtPath ( path, options ) {
return this.included
|| path.length > MAX_PATH_LENGTH
|| path.length > MAX_PATH_DEPTH
|| this.boundExpressions.someAtPath( path, ( relativePath, node ) =>
relativePath.length > 0
&& !options.hasNodeBeenAssignedAtPath( relativePath, node ) && node
Expand All @@ -61,7 +61,7 @@ export default class LocalVariable extends Variable {
}

hasEffectsWhenCalledAtPath ( path, callOptions, options ) {
return path.length > MAX_PATH_LENGTH
return path.length > MAX_PATH_DEPTH
|| (this.included && path.length > 0)
|| this.boundExpressions.someAtPath( path, ( relativePath, node ) =>
!options.hasNodeBeenCalledAtPathWithOptions( relativePath, node, callOptions ) && node
Expand All @@ -77,7 +77,7 @@ export default class LocalVariable extends Variable {
}

someReturnExpressionWhenCalledAtPath ( path, callOptions, predicateFunction, options ) {
return path.length > MAX_PATH_LENGTH
return path.length > MAX_PATH_DEPTH
|| (this.included && path.length > 0)
|| this.boundExpressions.someAtPath( path, ( relativePath, node ) =>
!options.hasNodeBeenCalledAtPathWithOptions( relativePath, node, callOptions ) && node
Expand Down
3 changes: 0 additions & 3 deletions test/form/samples/cyclic-assignments/_config.js

This file was deleted.

14 changes: 0 additions & 14 deletions test/form/samples/cyclic-assignments/_expected/amd.js

This file was deleted.

12 changes: 0 additions & 12 deletions test/form/samples/cyclic-assignments/_expected/cjs.js

This file was deleted.

10 changes: 0 additions & 10 deletions test/form/samples/cyclic-assignments/_expected/es.js

This file was deleted.

15 changes: 0 additions & 15 deletions test/form/samples/cyclic-assignments/_expected/iife.js

This file was deleted.

18 changes: 0 additions & 18 deletions test/form/samples/cyclic-assignments/_expected/umd.js

This file was deleted.

Expand Up @@ -11,6 +11,7 @@ define(function () { 'use strict';
};

const retained1b = retained1a.effect;
const retained1c = retained1a[ 'eff' + 'ect' ];

const retained3 = {
set effect ( value ) {
Expand All @@ -20,6 +21,14 @@ define(function () { 'use strict';

retained3.effect = 'retained';

const retained4 = {
set effect ( value ) {
console.log( value );
}
};

retained4[ 'eff' + 'ect' ] = 'retained';

const retained7 = {
foo: () => {},
get foo () {
Expand Down
Expand Up @@ -11,6 +11,7 @@ const retained1a = {
};

const retained1b = retained1a.effect;
const retained1c = retained1a[ 'eff' + 'ect' ];

const retained3 = {
set effect ( value ) {
Expand All @@ -20,6 +21,14 @@ const retained3 = {

retained3.effect = 'retained';

const retained4 = {
set effect ( value ) {
console.log( value );
}
};

retained4[ 'eff' + 'ect' ] = 'retained';

const retained7 = {
foo: () => {},
get foo () {
Expand Down
Expand Up @@ -9,6 +9,7 @@ const retained1a = {
};

const retained1b = retained1a.effect;
const retained1c = retained1a[ 'eff' + 'ect' ];

const retained3 = {
set effect ( value ) {
Expand All @@ -18,6 +19,14 @@ const retained3 = {

retained3.effect = 'retained';

const retained4 = {
set effect ( value ) {
console.log( value );
}
};

retained4[ 'eff' + 'ect' ] = 'retained';

const retained7 = {
foo: () => {},
get foo () {
Expand Down
Expand Up @@ -12,6 +12,7 @@
};

const retained1b = retained1a.effect;
const retained1c = retained1a[ 'eff' + 'ect' ];

const retained3 = {
set effect ( value ) {
Expand All @@ -21,6 +22,14 @@

retained3.effect = 'retained';

const retained4 = {
set effect ( value ) {
console.log( value );
}
};

retained4[ 'eff' + 'ect' ] = 'retained';

const retained7 = {
foo: () => {},
get foo () {
Expand Down
Expand Up @@ -15,6 +15,7 @@
};

const retained1b = retained1a.effect;
const retained1c = retained1a[ 'eff' + 'ect' ];

const retained3 = {
set effect ( value ) {
Expand All @@ -24,6 +25,14 @@

retained3.effect = 'retained';

const retained4 = {
set effect ( value ) {
console.log( value );
}
};

retained4[ 'eff' + 'ect' ] = 'retained';

const retained7 = {
foo: () => {},
get foo () {
Expand Down
9 changes: 9 additions & 0 deletions test/form/samples/side-effects-getters-and-setters/main.js
Expand Up @@ -10,6 +10,7 @@ const retained1a = {

const removed1 = retained1a.noEffect;
const retained1b = retained1a.effect;
const retained1c = retained1a[ 'eff' + 'ect' ];

const removed2a = {
get shadowedEffect () {
Expand All @@ -33,6 +34,14 @@ const retained3 = {

retained3.effect = 'retained';

const retained4 = {
set effect ( value ) {
console.log( value );
}
};

retained4[ 'eff' + 'ect' ] = 'retained';

const removed5 = {
set noEffect ( value ) {
const x = value;
Expand Down
Expand Up @@ -11,21 +11,18 @@ define(['exports'], function (exports) { 'use strict';
delete retained3.x;
retained3.x.y = 2;

const retained4 = { x: {} };
retained4.x = undefined;
const retained4 = { x: undefined };
retained4.x.y = 2;

const retained5 = { x: {} };
retained5.x = null;
const retained5 = { x: null };
retained5.x.y = 2;

const retained6 = { x: { y: {} } };
retained6.x = {};
retained6.x.y.z = 3;

const retained7 = { x: { y: globalVar } };
const retained8 = { x: { y: {} } };
retained8.x = retained7.x;
const retained8 = { x: retained7.x };
retained8.x.y.z = 3;

exports.retained1 = retained1;
Expand Down
Expand Up @@ -13,21 +13,18 @@ const retained3 = { x: {} };
delete retained3.x;
retained3.x.y = 2;

const retained4 = { x: {} };
retained4.x = undefined;
const retained4 = { x: undefined };
retained4.x.y = 2;

const retained5 = { x: {} };
retained5.x = null;
const retained5 = { x: null };
retained5.x.y = 2;

const retained6 = { x: { y: {} } };
retained6.x = {};
retained6.x.y.z = 3;

const retained7 = { x: { y: globalVar } };
const retained8 = { x: { y: {} } };
retained8.x = retained7.x;
const retained8 = { x: retained7.x };
retained8.x.y.z = 3;

exports.retained1 = retained1;
Expand Up @@ -9,21 +9,18 @@ const retained3 = { x: {} };
delete retained3.x;
retained3.x.y = 2;

const retained4 = { x: {} };
retained4.x = undefined;
const retained4 = { x: undefined };
retained4.x.y = 2;

const retained5 = { x: {} };
retained5.x = null;
const retained5 = { x: null };
retained5.x.y = 2;

const retained6 = { x: { y: {} } };
retained6.x = {};
retained6.x.y.z = 3;

const retained7 = { x: { y: globalVar } };
const retained8 = { x: { y: {} } };
retained8.x = retained7.x;
const retained8 = { x: retained7.x };
retained8.x.y.z = 3;

export { retained1 };
Expand Up @@ -12,21 +12,18 @@ var bundle = (function (exports) {
delete retained3.x;
retained3.x.y = 2;

const retained4 = { x: {} };
retained4.x = undefined;
const retained4 = { x: undefined };
retained4.x.y = 2;

const retained5 = { x: {} };
retained5.x = null;
const retained5 = { x: null };
retained5.x.y = 2;

const retained6 = { x: { y: {} } };
retained6.x = {};
retained6.x.y.z = 3;

const retained7 = { x: { y: globalVar } };
const retained8 = { x: { y: {} } };
retained8.x = retained7.x;
const retained8 = { x: retained7.x };
retained8.x.y.z = 3;

exports.retained1 = retained1;
Expand Down

0 comments on commit 5c37051

Please sign in to comment.