Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
wartab committed Nov 18, 2024
1 parent 7954fb8 commit 265020e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@
}
]
},
{
"description": "should generate code for switch blocks containing a case with multiple guards",
"inputFiles": ["switch_with_multi_case.ts"],
"expectations": [
{
"files": [
{
"expected": "switch_with_multi_case_template.js",
"generated": "empty_switch.js"
}
],
"failureMessage": "Incorrect template"
}
]
},
{
"description": "should generate a basic if block",
"inputFiles": ["basic_if.ts"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Component} from '@angular/core';

@Component({
template: `
<div>
{{message}}
@switch (value()) {
@case (0; 1; 2) {
case 0, 1, or 2
}
@case (3) {
case 3
}
@case (4) {
case 4
}
}
</div>
`,
standalone: false
})
export class MyApp {
message = 'hello';
value = () => 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function MyApp_Case_2_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtext(0, " case 0, 1, or 2 ");
}
}

function MyApp_Case_3_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtext(0, " case 3 ");
}
}

function MyApp_Case_4_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtext(0, " case 4 ");
}
}
function MyApp_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
$r3$.ɵɵtext(1);
$r3$.ɵɵtemplate(2, MyApp_Case_2_Template, 1, 0)(3, MyApp_Case_3_Template, 1, 0)(4, MyApp_Case_4_Template, 1, 0);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
let $MyApp_contFlowTmp$;
$r3$.ɵɵadvance();
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " ");
$r3$.ɵɵadvance();
$r3$.ɵɵconditional(($MyApp_contFlowTmp$ = ctx.value()) === 0 ? 2 : $MyApp_contFlowTmp$ === 1 ? 3 : $MyApp_contFlowTmp$ === 2 ? 4 : -1);
}
}

0 comments on commit 265020e

Please sign in to comment.