-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(template-compiler): template expressions
- Loading branch information
Showing
111 changed files
with
1,154 additions
and
1 deletion.
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
5 changes: 5 additions & 0 deletions
5
...plate-compiler/src/__tests__/fixtures/expression-complex/arrow-function-async/actual.html
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,5 @@ | ||
<template> | ||
<section> | ||
<button onclick={async () => doSomething()}></button> | ||
</section> | ||
</template> |
1 change: 1 addition & 0 deletions
1
...template-compiler/src/__tests__/fixtures/expression-complex/arrow-function-async/ast.json
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 changes: 3 additions & 0 deletions
3
...plate-compiler/src/__tests__/fixtures/expression-complex/arrow-function-async/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
Empty file.
15 changes: 15 additions & 0 deletions
15
...ate-compiler/src/__tests__/fixtures/expression-complex/arrow-function-async/metadata.json
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 @@ | ||
{ | ||
"warnings": [ | ||
{ | ||
"code": 1194, | ||
"message": "Invalid expression {async () => doSomething()} - LWC1194: Arrow functions in template expressions cannot be async.", | ||
"level": 1, | ||
"location": { | ||
"line": 3, | ||
"column": 17, | ||
"start": 41, | ||
"length": 35 | ||
} | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...-compiler/src/__tests__/fixtures/expression-complex/arrow-function-block-body/actual.html
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,5 @@ | ||
<template> | ||
<section> | ||
<button onblick={() => { doSomething(); }}></button> | ||
</section> | ||
</template> |
1 change: 1 addition & 0 deletions
1
...ate-compiler/src/__tests__/fixtures/expression-complex/arrow-function-block-body/ast.json
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 changes: 3 additions & 0 deletions
3
...-compiler/src/__tests__/fixtures/expression-complex/arrow-function-block-body/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
Empty file.
15 changes: 15 additions & 0 deletions
15
...ompiler/src/__tests__/fixtures/expression-complex/arrow-function-block-body/metadata.json
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 @@ | ||
{ | ||
"warnings": [ | ||
{ | ||
"code": 1193, | ||
"message": "Invalid expression {() => { doSomething(); }} - LWC1193: The body of arrow functions in template expressions must be an expression.", | ||
"level": 1, | ||
"location": { | ||
"line": 3, | ||
"column": 17, | ||
"start": 41, | ||
"length": 34 | ||
} | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...te-compiler/src/__tests__/fixtures/expression-complex/assignment-inside-arrow/actual.html
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,5 @@ | ||
<template> | ||
<section> | ||
<button onclick={() => myField = 'foo'}></button> | ||
</section> | ||
</template> |
160 changes: 160 additions & 0 deletions
160
...plate-compiler/src/__tests__/fixtures/expression-complex/assignment-inside-arrow/ast.json
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,160 @@ | ||
{ | ||
"root": { | ||
"type": "Root", | ||
"location": { | ||
"startLine": 1, | ||
"startColumn": 1, | ||
"endLine": 5, | ||
"endColumn": 12, | ||
"start": 0, | ||
"end": 109, | ||
"startTag": { | ||
"startLine": 1, | ||
"startColumn": 1, | ||
"endLine": 1, | ||
"endColumn": 11, | ||
"start": 0, | ||
"end": 10 | ||
}, | ||
"endTag": { | ||
"startLine": 5, | ||
"startColumn": 1, | ||
"endLine": 5, | ||
"endColumn": 12, | ||
"start": 98, | ||
"end": 109 | ||
} | ||
}, | ||
"directives": [], | ||
"children": [ | ||
{ | ||
"type": "Element", | ||
"name": "section", | ||
"namespace": "http://www.w3.org/1999/xhtml", | ||
"location": { | ||
"startLine": 2, | ||
"startColumn": 5, | ||
"endLine": 4, | ||
"endColumn": 15, | ||
"start": 15, | ||
"end": 97, | ||
"startTag": { | ||
"startLine": 2, | ||
"startColumn": 5, | ||
"endLine": 2, | ||
"endColumn": 14, | ||
"start": 15, | ||
"end": 24 | ||
}, | ||
"endTag": { | ||
"startLine": 4, | ||
"startColumn": 5, | ||
"endLine": 4, | ||
"endColumn": 15, | ||
"start": 87, | ||
"end": 97 | ||
} | ||
}, | ||
"attributes": [], | ||
"properties": [], | ||
"directives": [], | ||
"listeners": [], | ||
"children": [ | ||
{ | ||
"type": "Element", | ||
"name": "button", | ||
"namespace": "http://www.w3.org/1999/xhtml", | ||
"location": { | ||
"startLine": 3, | ||
"startColumn": 9, | ||
"endLine": 3, | ||
"endColumn": 58, | ||
"start": 33, | ||
"end": 82, | ||
"startTag": { | ||
"startLine": 3, | ||
"startColumn": 9, | ||
"endLine": 3, | ||
"endColumn": 49, | ||
"start": 33, | ||
"end": 73 | ||
}, | ||
"endTag": { | ||
"startLine": 3, | ||
"startColumn": 49, | ||
"endLine": 3, | ||
"endColumn": 58, | ||
"start": 73, | ||
"end": 82 | ||
} | ||
}, | ||
"attributes": [], | ||
"properties": [], | ||
"directives": [], | ||
"listeners": [ | ||
{ | ||
"type": "EventListener", | ||
"name": "click", | ||
"handler": { | ||
"type": "ArrowFunctionExpression", | ||
"start": 1, | ||
"end": 22, | ||
"id": null, | ||
"expression": true, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "AssignmentExpression", | ||
"start": 7, | ||
"end": 22, | ||
"operator": "=", | ||
"left": { | ||
"type": "MemberExpression", | ||
"object": { | ||
"type": "Identifier", | ||
"name": "$cmp" | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start": 7, | ||
"end": 14, | ||
"name": "myField" | ||
}, | ||
"computed": false, | ||
"optional": false | ||
}, | ||
"right": { | ||
"type": "Literal", | ||
"start": 17, | ||
"end": 22, | ||
"value": "foo", | ||
"raw": "'foo'" | ||
} | ||
}, | ||
"location": { | ||
"startLine": 3, | ||
"startColumn": 17, | ||
"endLine": 3, | ||
"endColumn": 48, | ||
"start": 41, | ||
"end": 72 | ||
} | ||
}, | ||
"location": { | ||
"startLine": 3, | ||
"startColumn": 17, | ||
"endLine": 3, | ||
"endColumn": 48, | ||
"start": 41, | ||
"end": 72 | ||
} | ||
} | ||
], | ||
"children": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...te-compiler/src/__tests__/fixtures/expression-complex/assignment-inside-arrow/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
21 changes: 21 additions & 0 deletions
21
...te-compiler/src/__tests__/fixtures/expression-complex/assignment-inside-arrow/expected.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,21 @@ | ||
import { registerTemplate } from "lwc"; | ||
const stc0 = { | ||
key: 0, | ||
}; | ||
function tmpl($api, $cmp, $slotset, $ctx) { | ||
const { b: api_bind, h: api_element } = $api; | ||
const { _m0 } = $ctx; | ||
return [ | ||
api_element("section", stc0, [ | ||
api_element("button", { | ||
key: 1, | ||
on: { | ||
click: _m0 || ($ctx._m0 = api_bind(() => ($cmp.myField = "foo"))), | ||
}, | ||
}), | ||
]), | ||
]; | ||
/*LWC compiler vX.X.X*/ | ||
} | ||
export default registerTemplate(tmpl); | ||
tmpl.stylesheets = []; |
3 changes: 3 additions & 0 deletions
3
...-compiler/src/__tests__/fixtures/expression-complex/assignment-inside-arrow/metadata.json
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 @@ | ||
{ | ||
"warnings": [] | ||
} |
5 changes: 5 additions & 0 deletions
5
...e-compiler/src/__tests__/fixtures/expression-complex/assignment-outside-arrow/actual.html
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,5 @@ | ||
<template> | ||
<section> | ||
<button onclick={myField = 'foo'}></button> | ||
</section> | ||
</template> |
1 change: 1 addition & 0 deletions
1
...late-compiler/src/__tests__/fixtures/expression-complex/assignment-outside-arrow/ast.json
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 changes: 3 additions & 0 deletions
3
...e-compiler/src/__tests__/fixtures/expression-complex/assignment-outside-arrow/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
Empty file.
15 changes: 15 additions & 0 deletions
15
...compiler/src/__tests__/fixtures/expression-complex/assignment-outside-arrow/metadata.json
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 @@ | ||
{ | ||
"warnings": [ | ||
{ | ||
"code": 1191, | ||
"message": "Invalid expression {myField = 'foo'} - LWC1191: Field mutations are only permitted within arrow functions.", | ||
"level": 1, | ||
"location": { | ||
"line": 3, | ||
"column": 17, | ||
"start": 41, | ||
"length": 25 | ||
} | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/await/actual.html
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,5 @@ | ||
<template> | ||
<section> | ||
<button onclick={ await something() }></button> | ||
</section> | ||
</template> |
1 change: 1 addition & 0 deletions
1
packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/await/ast.json
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 changes: 3 additions & 0 deletions
3
packages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/await/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
Empty file.
9 changes: 9 additions & 0 deletions
9
...ages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/await/metadata.json
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 @@ | ||
{ | ||
"warnings": [ | ||
{ | ||
"code": 1083, | ||
"message": "Unexpected compilation error: LWC1083: Error parsing template expression: expression must end with curly brace.", | ||
"level": 1 | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...wc/template-compiler/src/__tests__/fixtures/expression-complex/bigint-literal/actual.html
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,5 @@ | ||
<template> | ||
<section> | ||
<x-child foo={transformBigInt(1n)}></x-child> | ||
</section> | ||
</template> |
1 change: 1 addition & 0 deletions
1
.../@lwc/template-compiler/src/__tests__/fixtures/expression-complex/bigint-literal/ast.json
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 changes: 3 additions & 0 deletions
3
...wc/template-compiler/src/__tests__/fixtures/expression-complex/bigint-literal/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
Empty file.
15 changes: 15 additions & 0 deletions
15
.../template-compiler/src/__tests__/fixtures/expression-complex/bigint-literal/metadata.json
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 @@ | ||
{ | ||
"warnings": [ | ||
{ | ||
"code": 1196, | ||
"message": "Invalid expression {transformBigInt(1n)} - LWC1196: Use of BigInts is disallowed within template expressions.", | ||
"level": 1, | ||
"location": { | ||
"line": 3, | ||
"column": 18, | ||
"start": 42, | ||
"length": 25 | ||
} | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
...s/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/class-expr/actual.html
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 @@ | ||
<template> | ||
<section> | ||
<x-foo jsclass={ | ||
class Bar { | ||
method() {} | ||
} | ||
}></x-foo> | ||
</section> | ||
</template> |
1 change: 1 addition & 0 deletions
1
...ages/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/class-expr/ast.json
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 changes: 3 additions & 0 deletions
3
...s/@lwc/template-compiler/src/__tests__/fixtures/expression-complex/class-expr/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
Empty file.
15 changes: 15 additions & 0 deletions
15
...@lwc/template-compiler/src/__tests__/fixtures/expression-complex/class-expr/metadata.json
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 @@ | ||
{ | ||
"warnings": [ | ||
{ | ||
"code": 1196, | ||
"message": "Invalid expression {\n class Bar {\n method() {}\n }\n } - LWC1196: Use of classes is disallowed within template expressions.", | ||
"level": 1, | ||
"location": { | ||
"line": 3, | ||
"column": 16, | ||
"start": 40, | ||
"length": 85 | ||
} | ||
} | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...wc/template-compiler/src/__tests__/fixtures/expression-complex/comma-operator/actual.html
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,5 @@ | ||
<template> | ||
<section> | ||
<button onclick={(one(), two(), three(), iAmTheCount())}></button> | ||
</section> | ||
</template> |
1 change: 1 addition & 0 deletions
1
.../@lwc/template-compiler/src/__tests__/fixtures/expression-complex/comma-operator/ast.json
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 changes: 3 additions & 0 deletions
3
...wc/template-compiler/src/__tests__/fixtures/expression-complex/comma-operator/config.json
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 @@ | ||
{ | ||
"experimentalComplexExpressions": true | ||
} |
Empty file.
Oops, something went wrong.