Browse Source

Merge pull request #918 from rollup/empty-statements

Remove non-expression statements without effects
gh-953
Rich Harris 8 years ago
committed by GitHub
parent
commit
e761e22acc
  1. 29
      src/ast/nodes/ArrowFunctionExpression.js
  2. 4
      src/ast/nodes/AssignmentExpression.js
  3. 32
      src/ast/nodes/BlockStatement.js
  4. 7
      src/ast/nodes/EmptyStatement.js
  5. 5
      src/ast/nodes/ForInStatement.js
  6. 5
      src/ast/nodes/ForOfStatement.js
  7. 31
      src/ast/nodes/ForStatement.js
  8. 4
      src/ast/nodes/FunctionDeclaration.js
  9. 4
      src/ast/nodes/FunctionExpression.js
  10. 11
      src/ast/nodes/index.js
  11. 3
      test/form/empty-block-statement/_config.js
  12. 6
      test/form/empty-block-statement/_expected/amd.js
  13. 4
      test/form/empty-block-statement/_expected/cjs.js
  14. 2
      test/form/empty-block-statement/_expected/es.js
  15. 7
      test/form/empty-block-statement/_expected/iife.js
  16. 10
      test/form/empty-block-statement/_expected/umd.js
  17. 5
      test/form/empty-block-statement/main.js
  18. 3
      test/form/empty-do-while-statement/_config.js
  19. 6
      test/form/empty-do-while-statement/_expected/amd.js
  20. 4
      test/form/empty-do-while-statement/_expected/cjs.js
  21. 2
      test/form/empty-do-while-statement/_expected/es.js
  22. 7
      test/form/empty-do-while-statement/_expected/iife.js
  23. 10
      test/form/empty-do-while-statement/_expected/umd.js
  24. 6
      test/form/empty-do-while-statement/main.js
  25. 3
      test/form/empty-for-in-statement/_config.js
  26. 6
      test/form/empty-for-in-statement/_expected/amd.js
  27. 4
      test/form/empty-for-in-statement/_expected/cjs.js
  28. 2
      test/form/empty-for-in-statement/_expected/es.js
  29. 7
      test/form/empty-for-in-statement/_expected/iife.js
  30. 10
      test/form/empty-for-in-statement/_expected/umd.js
  31. 5
      test/form/empty-for-in-statement/main.js
  32. 3
      test/form/empty-for-of-statement/_config.js
  33. 6
      test/form/empty-for-of-statement/_expected/amd.js
  34. 4
      test/form/empty-for-of-statement/_expected/cjs.js
  35. 2
      test/form/empty-for-of-statement/_expected/es.js
  36. 7
      test/form/empty-for-of-statement/_expected/iife.js
  37. 10
      test/form/empty-for-of-statement/_expected/umd.js
  38. 5
      test/form/empty-for-of-statement/main.js
  39. 3
      test/form/empty-for-statement/_config.js
  40. 6
      test/form/empty-for-statement/_expected/amd.js
  41. 4
      test/form/empty-for-statement/_expected/cjs.js
  42. 2
      test/form/empty-for-statement/_expected/es.js
  43. 7
      test/form/empty-for-statement/_expected/iife.js
  44. 10
      test/form/empty-for-statement/_expected/umd.js
  45. 5
      test/form/empty-for-statement/main.js
  46. 3
      test/form/empty-if-statement/_config.js
  47. 6
      test/form/empty-if-statement/_expected/amd.js
  48. 4
      test/form/empty-if-statement/_expected/cjs.js
  49. 2
      test/form/empty-if-statement/_expected/es.js
  50. 7
      test/form/empty-if-statement/_expected/iife.js
  51. 10
      test/form/empty-if-statement/_expected/umd.js
  52. 5
      test/form/empty-if-statement/main.js
  53. 3
      test/form/empty-statement/_config.js
  54. 7
      test/form/empty-statement/_expected/amd.js
  55. 5
      test/form/empty-statement/_expected/cjs.js
  56. 3
      test/form/empty-statement/_expected/es.js
  57. 8
      test/form/empty-statement/_expected/iife.js
  58. 11
      test/form/empty-statement/_expected/umd.js
  59. 4
      test/form/empty-statement/main.js
  60. 3
      test/form/empty-switch-statement/_config.js
  61. 6
      test/form/empty-switch-statement/_expected/amd.js
  62. 4
      test/form/empty-switch-statement/_expected/cjs.js
  63. 2
      test/form/empty-switch-statement/_expected/es.js
  64. 7
      test/form/empty-switch-statement/_expected/iife.js
  65. 10
      test/form/empty-switch-statement/_expected/umd.js
  66. 11
      test/form/empty-switch-statement/main.js
  67. 3
      test/form/empty-try-catch-statement/_config.js
  68. 6
      test/form/empty-try-catch-statement/_expected/amd.js
  69. 4
      test/form/empty-try-catch-statement/_expected/cjs.js
  70. 2
      test/form/empty-try-catch-statement/_expected/es.js
  71. 7
      test/form/empty-try-catch-statement/_expected/iife.js
  72. 10
      test/form/empty-try-catch-statement/_expected/umd.js
  73. 9
      test/form/empty-try-catch-statement/main.js
  74. 3
      test/form/empty-while-statement/_config.js
  75. 6
      test/form/empty-while-statement/_expected/amd.js
  76. 4
      test/form/empty-while-statement/_expected/cjs.js
  77. 2
      test/form/empty-while-statement/_expected/es.js
  78. 7
      test/form/empty-while-statement/_expected/iife.js
  79. 10
      test/form/empty-while-statement/_expected/umd.js
  80. 6
      test/form/empty-while-statement/main.js
  81. 4
      test/form/erroneous-nested-member-expression/_expected/amd.js
  82. 4
      test/form/erroneous-nested-member-expression/_expected/cjs.js
  83. 4
      test/form/erroneous-nested-member-expression/_expected/es.js
  84. 4
      test/form/erroneous-nested-member-expression/_expected/iife.js
  85. 4
      test/form/erroneous-nested-member-expression/_expected/umd.js
  86. 2
      test/form/spacing-after-function-with-semicolon/_expected/amd.js
  87. 2
      test/form/spacing-after-function-with-semicolon/_expected/cjs.js
  88. 2
      test/form/spacing-after-function-with-semicolon/_expected/es.js
  89. 2
      test/form/spacing-after-function-with-semicolon/_expected/iife.js
  90. 4
      test/form/spacing-after-function-with-semicolon/_expected/umd.js

29
src/ast/nodes/ArrowFunctionExpression.js

@ -3,8 +3,22 @@ import Scope from '../scopes/Scope.js';
import extractNames from '../utils/extractNames.js';
export default class ArrowFunctionExpression extends Node {
bind ( scope ) {
super.bind( this.scope || scope );
}
findScope ( functionScope ) {
return this.scope || this.parent.findScope( functionScope );
}
hasEffects () {
return false;
}
initialise ( scope ) {
if ( this.body.type !== 'BlockStatement' ) {
if ( this.body.type === 'BlockStatement' ) {
this.body.createScope( scope );
} else {
this.scope = new Scope({
parent: scope,
isBlockScope: false,
@ -18,18 +32,7 @@ export default class ArrowFunctionExpression extends Node {
}
}
scope = this.scope || this.body.scope;
super.initialise( scope );
}
bind ( scope ) {
super.bind( this.scope || scope );
}
findScope ( functionScope ) {
return this.scope || this.parent.findScope( functionScope );
}
hasEffects () {
return false;
}
}

4
src/ast/nodes/AssignmentExpression.js

@ -35,11 +35,13 @@ export default class AssignmentExpression extends Node {
}
initialise ( scope ) {
this.scope = scope;
this.module.bundle.dependentExpressions.push( this );
super.initialise( scope );
}
isUsedByBundle () {
return isUsedByBundle( this.findScope(), this.subject );
return isUsedByBundle( this.scope, this.subject );
}
}

32
src/ast/nodes/BlockStatement.js

@ -1,8 +1,8 @@
import Node from '../Node.js';
import Statement from './shared/Statement.js';
import Scope from '../scopes/Scope.js';
import extractNames from '../utils/extractNames.js';
export default class BlockStatement extends Node {
export default class BlockStatement extends Statement {
bind () {
for ( const node of this.body ) {
node.bind( this.scope );
@ -14,9 +14,9 @@ export default class BlockStatement extends Node {
this.isFunctionBlock = this.parentIsFunction || this.parent.type === 'Module';
this.scope = new Scope({
parent,
isBlockScope: !this.isFunctionBlock,
isLexicalBoundary: this.isFunctionBlock && this.parent.type !== 'ArrowFunctionExpression',
parent: parent || this.parent.findScope( false ), // TODO always supply parent
owner: this // TODO is this used anywhere?
});
@ -35,14 +35,8 @@ export default class BlockStatement extends Node {
return functionScope && !this.isFunctionBlock ? this.parent.findScope( functionScope ) : this.scope;
}
hasEffects () {
for ( const node of this.body ) {
if ( node.hasEffects( this.scope ) ) return true;
}
}
initialise () {
if ( !this.scope ) this.createScope(); // scope can be created early in some cases, e.g for (let i... )
initialise ( scope ) {
if ( !this.scope ) this.createScope( scope ); // scope can be created early in some cases, e.g for (let i... )
let lastNode;
for ( const node of this.body ) {
@ -52,20 +46,4 @@ export default class BlockStatement extends Node {
lastNode = node;
}
}
render ( code, es ) {
for ( const node of this.body ) {
node.render( code, es );
}
}
run () {
if ( this.ran ) return;
this.ran = true;
for ( const node of this.body ) {
// TODO only include non-top-level statements if necessary
node.run( this.scope );
}
}
}

7
src/ast/nodes/EmptyStatement.js

@ -0,0 +1,7 @@
import Statement from './shared/Statement.js';
export default class EmptyStatement extends Statement {
render ( code ) {
code.remove( this.start, this.end );
}
}

5
src/ast/nodes/ForInStatement.js

@ -4,7 +4,8 @@ import { STRING } from '../values.js';
export default class ForInStatement extends Statement {
initialise ( scope ) {
super.initialise( scope );
assignTo( this.left, scope, STRING );
this.body.createScope( scope );
super.initialise( this.body.scope );
assignTo( this.left, this.body.scope, STRING );
}
}

5
src/ast/nodes/ForOfStatement.js

@ -4,7 +4,8 @@ import { UNKNOWN } from '../values.js';
export default class ForOfStatement extends Statement {
initialise ( scope ) {
super.initialise( scope );
assignTo( this.left, scope, UNKNOWN );
this.body.createScope( scope );
super.initialise( this.body.scope );
assignTo( this.left, this.body.scope, UNKNOWN );
}
}

31
src/ast/nodes/ForStatement.js

@ -0,0 +1,31 @@
import Statement from './shared/Statement.js';
export default class ForStatement extends Statement {
bind () {
const scope = this.body.scope;
this.init.bind( scope );
this.test.bind( scope );
this.update.bind( scope );
this.body.bind( scope );
}
hasEffects () {
return super.hasEffects( this.body.scope );
}
initialise ( scope ) {
this.body.createScope( scope );
scope = this.body.scope;
// can't use super, because we need to control the order
this.init.initialise( scope );
this.test.initialise( scope );
this.update.initialise( scope );
this.body.initialise( scope );
}
run ( scope ) {
super.run( scope );
}
}

4
src/ast/nodes/FunctionDeclaration.js

@ -36,11 +36,11 @@ export default class FunctionDeclaration extends Node {
this.name = this.id.name; // may be overridden by bundle.deconflict
scope.addDeclaration( this.name, this, false, false );
this.body.createScope();
this.body.createScope( scope );
this.id.initialise( scope );
this.params.forEach( param => param.initialise( this.body.scope ) );
this.body.initialise( scope );
this.body.initialise();
}
render ( code, es ) {

4
src/ast/nodes/FunctionExpression.js

@ -11,8 +11,8 @@ export default class FunctionExpression extends Node {
return false;
}
initialise () {
this.body.createScope(); // TODO we'll also need to do this for For[Of|In]Statement
initialise ( scope ) {
this.body.createScope( scope );
if ( this.id ) this.id.initialise( this.body.scope );
this.params.forEach( param => param.initialise( this.body.scope ) );

11
src/ast/nodes/index.js

@ -7,10 +7,12 @@ import CallExpression from './CallExpression.js';
import ClassDeclaration from './ClassDeclaration.js';
import ClassExpression from './ClassExpression.js';
import ConditionalExpression from './ConditionalExpression.js';
import EmptyStatement from './EmptyStatement.js';
import ExportAllDeclaration from './ExportAllDeclaration.js';
import ExportDefaultDeclaration from './ExportDefaultDeclaration.js';
import ExportNamedDeclaration from './ExportNamedDeclaration.js';
import ExpressionStatement from './ExpressionStatement.js';
import ForStatement from './ForStatement.js';
import ForInStatement from './ForInStatement.js';
import ForOfStatement from './ForOfStatement.js';
import FunctionDeclaration from './FunctionDeclaration.js';
@ -24,6 +26,7 @@ import NewExpression from './NewExpression.js';
import ObjectExpression from './ObjectExpression.js';
import ParenthesizedExpression from './ParenthesizedExpression.js';
import ReturnStatement from './ReturnStatement.js';
import Statement from './shared/Statement.js';
import TemplateLiteral from './TemplateLiteral.js';
import ThisExpression from './ThisExpression.js';
import ThrowStatement from './ThrowStatement.js';
@ -42,10 +45,13 @@ export default {
ClassDeclaration,
ClassExpression,
ConditionalExpression,
DoWhileStatement: Statement,
EmptyStatement,
ExportAllDeclaration,
ExportDefaultDeclaration,
ExportNamedDeclaration,
ExpressionStatement,
ForStatement,
ForInStatement,
ForOfStatement,
FunctionDeclaration,
@ -59,11 +65,14 @@ export default {
ObjectExpression,
ParenthesizedExpression,
ReturnStatement,
SwitchStatement: Statement,
TemplateLiteral,
ThisExpression,
ThrowStatement,
TryStatement: Statement,
UnaryExpression,
UpdateExpression,
VariableDeclarator,
VariableDeclaration
VariableDeclaration,
WhileStatement: Statement
};

3
test/form/empty-block-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty block statement'
};

6
test/form/empty-block-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-block-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-block-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-block-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-block-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

5
test/form/empty-block-statement/main.js

@ -0,0 +1,5 @@
console.log( 1 );
{
// empty
}
console.log( 2 );

3
test/form/empty-do-while-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty do-while statement'
};

6
test/form/empty-do-while-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-do-while-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-do-while-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-do-while-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-do-while-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

6
test/form/empty-do-while-statement/main.js

@ -0,0 +1,6 @@
console.log( 1 );
var condition = true;
do {
condition = false;
} while ( condition );
console.log( 2 );

3
test/form/empty-for-in-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty for-in statement'
};

6
test/form/empty-for-in-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-for-in-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-for-in-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-for-in-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-for-in-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

5
test/form/empty-for-in-statement/main.js

@ -0,0 +1,5 @@
console.log( 1 );
for ( const i in whatever ) {
// do nothing
}
console.log( 2 );

3
test/form/empty-for-of-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty for-of statement'
};

6
test/form/empty-for-of-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-for-of-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-for-of-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-for-of-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-for-of-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

5
test/form/empty-for-of-statement/main.js

@ -0,0 +1,5 @@
console.log( 1 );
for ( const i of whatever ) {
// do nothing
}
console.log( 2 );

3
test/form/empty-for-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty for statement'
};

6
test/form/empty-for-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-for-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-for-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-for-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-for-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

5
test/form/empty-for-statement/main.js

@ -0,0 +1,5 @@
console.log( 1 );
for ( let i = 0; i < 10; i += 1 ) {
// do nothing
}
console.log( 2 );

3
test/form/empty-if-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty if statement'
};

6
test/form/empty-if-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-if-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-if-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-if-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-if-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

5
test/form/empty-if-statement/main.js

@ -0,0 +1,5 @@
console.log( 1 );
if ( nothing ) {
// empty
}
console.log( 2 );

3
test/form/empty-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty statement'
};

7
test/form/empty-statement/_expected/amd.js

@ -0,0 +1,7 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

5
test/form/empty-statement/_expected/cjs.js

@ -0,0 +1,5 @@
'use strict';
console.log( 1 );
console.log( 2 );

3
test/form/empty-statement/_expected/es.js

@ -0,0 +1,3 @@
console.log( 1 );
console.log( 2 );

8
test/form/empty-statement/_expected/iife.js

@ -0,0 +1,8 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

11
test/form/empty-statement/_expected/umd.js

@ -0,0 +1,11 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

4
test/form/empty-statement/main.js

@ -0,0 +1,4 @@
;
console.log( 1 );;
;
console.log( 2 );;

3
test/form/empty-switch-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty switch statement'
};

6
test/form/empty-switch-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-switch-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-switch-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-switch-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-switch-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

11
test/form/empty-switch-statement/main.js

@ -0,0 +1,11 @@
console.log( 1 );
var result;
switch ( whatever ) {
case foo:
result = 'foo';
break;
default:
result = 'default';
}
console.log( 2 );

3
test/form/empty-try-catch-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty try-catch-finally statement'
};

6
test/form/empty-try-catch-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-try-catch-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-try-catch-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-try-catch-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-try-catch-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

9
test/form/empty-try-catch-statement/main.js

@ -0,0 +1,9 @@
console.log( 1 );
try {
// do nothing
} catch ( err ) {
// do nothing
} finally {
// do nothing
}
console.log( 2 );

3
test/form/empty-while-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes an empty while statement'
};

6
test/form/empty-while-statement/_expected/amd.js

@ -0,0 +1,6 @@
define(function () { 'use strict';
console.log( 1 );
console.log( 2 );
});

4
test/form/empty-while-statement/_expected/cjs.js

@ -0,0 +1,4 @@
'use strict';
console.log( 1 );
console.log( 2 );

2
test/form/empty-while-statement/_expected/es.js

@ -0,0 +1,2 @@
console.log( 1 );
console.log( 2 );

7
test/form/empty-while-statement/_expected/iife.js

@ -0,0 +1,7 @@
(function () {
'use strict';
console.log( 1 );
console.log( 2 );
}());

10
test/form/empty-while-statement/_expected/umd.js

@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
console.log( 2 );
})));

6
test/form/empty-while-statement/main.js

@ -0,0 +1,6 @@
console.log( 1 );
var condition = true;
while ( condition ) {
condition = false;
}
console.log( 2 );

4
test/form/erroneous-nested-member-expression/_expected/amd.js

@ -6,8 +6,8 @@ define(function () { 'use strict';
console.log('har?');
}
};
};
}
yar.har();
});
});

4
test/form/erroneous-nested-member-expression/_expected/cjs.js

@ -6,6 +6,6 @@ function yar() {
console.log('har?');
}
};
};
}
yar.har();
yar.har();

4
test/form/erroneous-nested-member-expression/_expected/es.js

@ -4,6 +4,6 @@ function yar() {
console.log('har?');
}
};
};
}
yar.har();
yar.har();

4
test/form/erroneous-nested-member-expression/_expected/iife.js

@ -7,8 +7,8 @@
console.log('har?');
}
};
};
}
yar.har();
}());
}());

4
test/form/erroneous-nested-member-expression/_expected/umd.js

@ -10,8 +10,8 @@
console.log('har?');
}
};
};
}
yar.har();
})));
})));

2
test/form/spacing-after-function-with-semicolon/_expected/amd.js

@ -1,6 +1,6 @@
define(function () { 'use strict';
function x () { return 'x' };
function x () { return 'x' }
assert.equal( x(), 'x' );

2
test/form/spacing-after-function-with-semicolon/_expected/cjs.js

@ -1,5 +1,5 @@
'use strict';
function x () { return 'x' };
function x () { return 'x' }
assert.equal( x(), 'x' );

2
test/form/spacing-after-function-with-semicolon/_expected/es.js

@ -1,3 +1,3 @@
function x () { return 'x' };
function x () { return 'x' }
assert.equal( x(), 'x' );

2
test/form/spacing-after-function-with-semicolon/_expected/iife.js

@ -1,7 +1,7 @@
(function () {
'use strict';
function x () { return 'x' };
function x () { return 'x' }
assert.equal( x(), 'x' );

4
test/form/spacing-after-function-with-semicolon/_expected/umd.js

@ -4,8 +4,8 @@
(factory());
}(this, (function () { 'use strict';
function x () { return 'x' };
function x () { return 'x' }
assert.equal( x(), 'x' );
})));
})));

Loading…
Cancel
Save