Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repro for failing object destructuring #307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/NUglify.Tests/JavaScript/ES2015.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public void DestructuringAssignment()
TestHelper.Instance.RunTest();
}

[Test]
public void ObjectDestructuringAssignment()
{
TestHelper.Instance.RunTest();
}

//[Test]
public void Modules()
{
Expand Down
6 changes: 6 additions & 0 deletions src/NUglify.Tests/NUglify.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@
<Content Include="TestData\JS\Expected\ES2015\ConciseProperties.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Expected\ES2015\ObjectDestructuringAssignment.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Expected\ES2019\OptionalCatchBinding.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2977,6 +2980,9 @@
<None Include="TestData\JS\Input\CommandLine\Expression.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="TestData\JS\Input\ES2015\ObjectDestructuringAssignment.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Input\Literals\TemplateLiteralsEscaped.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
2 changes: 1 addition & 1 deletion src/NUglify.Tests/TestData/JS/Expected/Bugs/Bug290.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let foo,bar;({foo,bar}={foo:42,bar:!0})
let foo,bar;({foo,bar}={foo:42,bar:!0});({foo,bar}=fooBar)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let{op,lhs,rhs}=getASTNode(),{foo,bar}=fooBar;({op,lhs,rhs}=getASTNode());({foo,bar}=fooBar)
4 changes: 3 additions & 1 deletion src/NUglify.Tests/TestData/JS/Input/Bugs/Bug290.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
let foo, bar;
({ foo, bar } = { foo: 42, bar: true });
({ foo, bar } = { foo: 42, bar: true });
// similar but with variable being destructured
({ foo, bar } = fooBar);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// http://es6-features.org/#ObjectMatchingShorthandNotation
let { op, lhs, rhs } = getASTNode();
let { foo, bar } = fooBar;

// similar but assigning without declaring variables (parenthesis are required in these cases)
({ op, lhs, rhs } = getASTNode());
({ foo, bar } = fooBar);