Rename "Deconstruction" to "Destructuring" throughout JSC
[WebKit-https.git] / LayoutTests / js / script-tests / destructuring-parameters-should-be-locals.js
1 description("This tests to ensure that destructuring parameters behave like regular locals")
2
3 var value="outer"
4 function readDestructuredParameter([value]) {
5     return value;
6 }
7
8 function overwriteDestructuredParameter([value]) {
9         value = "inner"
10 }
11
12 function readCapturedDestructuredParameter([value]) {
13         return (function () {
14             return value;
15         })()
16 }
17
18 function overwriteCapturedDestructuredParameter([value]) {
19         (function () {
20             value = "innermost";
21         })()
22         return value
23 }
24
25 shouldBe("readDestructuredParameter(['inner'])", "'inner'")
26 overwriteDestructuredParameter(['inner'])
27
28 shouldBe("overwriteDestructuredParameter(['unused']); value;", "'outer'")
29
30 shouldBe("readCapturedDestructuredParameter(['inner'])", "'inner'")
31 overwriteDestructuredParameter(['inner'])
32
33 shouldBe("overwriteCapturedDestructuredParameter(['unused']);", "'innermost'")
34 shouldBe("value", "'outer'")
35