-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] adds tests for the new parameter types
- Loading branch information
1 parent
f3dbb31
commit 1d31162
Showing
3 changed files
with
108 additions
and
0 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,54 @@ | ||
function functionSimple(paramA) { | ||
console.log("paramA:", paramA); | ||
} | ||
|
||
function functionNoParam() { | ||
console.log("No parameters here ..."); | ||
} | ||
|
||
function functionWithObjectPattern(argPrimary, { keyA, keyB }) { | ||
console.log("keyB:", keyB); | ||
console.log("argPrimary:", argPrimary); | ||
console.log("keyA:", keyA); | ||
} | ||
|
||
function functionWithArrayPattern(firstElem, [secondElem, thirdElem]) { | ||
console.log("secondElem:", secondElem); | ||
console.log("thirdElem:", thirdElem); | ||
console.log("firstElem:", firstElem); | ||
} | ||
|
||
function functionWithNestedObjectPattern(mainArg, { nestedKey1, nestedKey2: { subKeyX, subKeyY } }) { | ||
console.log("mainArg:", mainArg); | ||
console.log("subKeyY:", subKeyY); | ||
console.log("nestedKey1:", nestedKey1); | ||
console.log("subKeyX:", subKeyX); | ||
} | ||
|
||
function functionWithNestedArrayPattern(primaryElem, [secondaryElem, [nestedElemX, nestedElemY]]) { | ||
console.log("primaryElem:", primaryElem); | ||
console.log("nestedElemY:", nestedElemY); | ||
console.log("secondaryElem:", secondaryElem); | ||
console.log("nestedElemX:", nestedElemX); | ||
} | ||
|
||
function functionWithMixedPattern( | ||
[arrayElem1, { objKey1, objKey2 }], | ||
{ arrKey1, arrKey2: [nestedArrElem1, nestedArrElem2] } | ||
) { | ||
console.log("objKey2:", objKey2); | ||
console.log("arrKey1:", arrKey1); | ||
console.log("nestedArrElem1:", nestedArrElem1); | ||
console.log("objKey1:", objKey1); | ||
console.log("arrayElem1:", arrayElem1); | ||
console.log("nestedArrElem2:", nestedArrElem2); | ||
} | ||
|
||
functionWithObjectPattern("foo", { keyA: 23, keyB: 42 }); | ||
functionWithArrayPattern("bar", [9000, 9001]); | ||
functionWithNestedObjectPattern("foo", { nestedKey1: 23, nestedKey2: { subKeyX: 100, subKeyY: 200 } }); | ||
functionWithNestedArrayPattern("bar", [9000, [9001, 9002]]); | ||
functionWithMixedPattern( | ||
["alpha", { objKey1: 300, objKey2: 400 }], | ||
{ arrKey1: 500, arrKey2: [8000, 8001] } | ||
); |
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