Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8926 from noelebrun/bugfix/8874
fixes #8874
- Loading branch information
Showing
7 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import myFunction from './module'; | ||
import myFunctionDefaultParameter from './moduleDefaultParameter'; | ||
import myFunctionExportedFunctionExpression from './moduleExportedFunctionExpression'; | ||
import myFunctionExportedFunctionExpressionDefaultParameter from './moduleExportedFunctionExpressionDefaultParameter'; | ||
|
||
it('should execute IIFE twice', () => { | ||
expect(myFunction()).toBe(2); | ||
}); | ||
|
||
it('should execute IIFE twice when using IIFE function name as default parameter', () => { | ||
expect(myFunctionDefaultParameter()).toBe(2); | ||
}); | ||
|
||
it('should execute Function Expression twice', () => { | ||
expect(myFunctionExportedFunctionExpression()).toBe(2); | ||
}); | ||
|
||
it('should execute Function Expression twice when using IIFE function name as default parameter', () => { | ||
expect(myFunctionExportedFunctionExpressionDefaultParameter()).toBe(2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import someFunction from './someFunction'; | ||
|
||
export default function myFunction() { | ||
let iifeExecutionCount = 0; | ||
|
||
(function someFunction (recurse) { | ||
iifeExecutionCount++; | ||
|
||
if (recurse) { | ||
someFunction(false); | ||
} | ||
})(true); | ||
|
||
return iifeExecutionCount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function myFunction() { | ||
let iifeExecutionCount = 0; | ||
|
||
(function someFunction (recurse, recurseFunction = someFunction) { | ||
iifeExecutionCount++; | ||
|
||
if (recurse) { | ||
recurseFunction(false); | ||
} | ||
})(true); | ||
|
||
return iifeExecutionCount; | ||
} |
9 changes: 9 additions & 0 deletions
9
test/cases/parsing/issue-8874/moduleExportedFunctionExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import someFunction from './someFunction'; | ||
|
||
export default (function someFunction (recurse = true) { | ||
if (recurse) { | ||
return 1 + someFunction(false); | ||
} | ||
|
||
return 1; | ||
}); |
10 changes: 10 additions & 0 deletions
10
test/cases/parsing/issue-8874/moduleExportedFunctionExpressionDefaultParameter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
import someFunction from './someFunction'; | ||
|
||
export default (function someFunction (recurse = true, recurseFunction = someFunction) { | ||
if (recurse) { | ||
return 1 + recurseFunction(false); | ||
} | ||
|
||
return 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function someFunction () { | ||
return -1; | ||
} |