From bef4e8067946b85395b02dc8935446dae5d629d0 Mon Sep 17 00:00:00 2001 From: heeba Date: Mon, 5 Jun 2017 11:45:34 -0700 Subject: [PATCH] Renaming tests for readability. Part of ES6 compatibility for Inline Type Aliases (full functionality + tests not yet complete). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=158041095 --- .../javascript/jscomp/InlineAliasesTest.java | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/test/com/google/javascript/jscomp/InlineAliasesTest.java b/test/com/google/javascript/jscomp/InlineAliasesTest.java index da84f6efbbe..1f3ba9db356 100644 --- a/test/com/google/javascript/jscomp/InlineAliasesTest.java +++ b/test/com/google/javascript/jscomp/InlineAliasesTest.java @@ -273,15 +273,15 @@ public void testNoInlineAliasesInsideClassConstructor() { "}")); } - public void testArrayDestructuringSwapDoesntCrash() { + public void testArrayDestructuringSwap() { testSame("var a = 1; var b = 3; [a, b] = [b, a];"); } - public void testArrayDestructuringVarAssignDoesntCrash() { + public void testArrayDestructuringVarAssign() { testSame("var foo = [1, 2, 3]; var [one, two, three] = foo;"); } - public void testArrayDestructuringFromFunctionDoesntCrash() { + public void testArrayDestructuringFromFunction() { testSame( LINE_JOINER.join( "function f() {", @@ -291,19 +291,56 @@ public void testArrayDestructuringFromFunctionDoesntCrash() { "[a, b] = f();")); } - public void testObjectDestructuringBasicAssignDoesntCrash() { + public void testObjectDestructuringBasicAssign() { testSame("var o = {p: 42, q: true}; var {p, q} = o;"); } - public void testObjectDestructuringAssignWithoutDeclarationDoesntCrash() { + public void testObjectDestructuringAssignWithoutDeclaration() { testSame("var a, b; ({a, b} = {a: 1, b: 2});"); } - public void testObjectDestructuringAssignNewVarNamesDoesntCrash() { + public void testObjectDestructuringAssignNewVarNames() { testSame("var o = {p: 42, q: true}; var {p: foo, q: bar} = o;"); } - public void testObjectDestructuringDefaultValsDoesntCrash() { + public void testObjectDestructuringDefaultVals() { testSame("var {a = 10, b = 5} = {a: 3};"); } + + public void testArrayDestructuringWithParameter() { + testSame( + LINE_JOINER.join( + "function f([name, val]) {", + " console.log(name, val);", + "}", + "f(['bar', 42]);")); + } + + public void testObjectDestructuringWithParameters() { + testSame( + LINE_JOINER.join( + "function g({", + " name: n,", + " val: v", + "}) {", + " console.log(n, v);", + "}", + "g({", + " name: 'foo',", + " val: 7", + "});")); + } + + public void testObjectDestructuringWithParametersAndStyleShortcut() { + testSame( + LINE_JOINER.join( + "function h({", + " name,", + " val", + "}) {", + " console.log(name, val);", + "}", + "f({name: 'bar', val: 42});")); + } + }