Add test for multiple interpolations
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
67b9c418ac
commit
e158450d18
5 changed files with 176 additions and 0 deletions
69
tests/cases/1-parsed@multiple.snap
Normal file
69
tests/cases/1-parsed@multiple.snap
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
---
|
||||||
|
source: tests/file_tests.rs
|
||||||
|
expression: parsed
|
||||||
|
input_file: tests/cases/multiple.temple
|
||||||
|
---
|
||||||
|
ParsedTemplate {
|
||||||
|
tokens: [
|
||||||
|
TemplateToken {
|
||||||
|
kind: Content,
|
||||||
|
source: "Hi there! My name is",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: LeftDelim,
|
||||||
|
source: "{{",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: WantsOutput,
|
||||||
|
source: "=",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Ident,
|
||||||
|
source: "name",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: RightDelim,
|
||||||
|
source: "}}",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: LeftDelim,
|
||||||
|
source: "{{",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: WantsOutput,
|
||||||
|
source: "=",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Ident,
|
||||||
|
source: "lastname",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
TemplateToken {
|
||||||
|
kind: RightDelim,
|
||||||
|
source: "}}",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
57
tests/cases/2-ast@multiple.snap
Normal file
57
tests/cases/2-ast@multiple.snap
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
---
|
||||||
|
source: tests/file_tests.rs
|
||||||
|
expression: ast
|
||||||
|
input_file: tests/cases/multiple.temple
|
||||||
|
---
|
||||||
|
TemplateAst {
|
||||||
|
root: [
|
||||||
|
StaticContent(
|
||||||
|
TemplateToken {
|
||||||
|
kind: Content,
|
||||||
|
source: "Hi there! My name is",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Interpolation {
|
||||||
|
prev_whitespace: Some(
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
wants_output: Some(
|
||||||
|
TemplateToken {
|
||||||
|
kind: WantsOutput,
|
||||||
|
source: "=",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
expression: VariableAccess(
|
||||||
|
TemplateToken {
|
||||||
|
kind: Ident,
|
||||||
|
source: "name",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
post_whitespace: Some(
|
||||||
|
TemplateToken {
|
||||||
|
kind: Whitespace,
|
||||||
|
source: " ",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Interpolation {
|
||||||
|
prev_whitespace: None,
|
||||||
|
wants_output: Some(
|
||||||
|
TemplateToken {
|
||||||
|
kind: WantsOutput,
|
||||||
|
source: "=",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
expression: VariableAccess(
|
||||||
|
TemplateToken {
|
||||||
|
kind: Ident,
|
||||||
|
source: "lastname",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
post_whitespace: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
38
tests/cases/3-instructions@multiple.snap
Normal file
38
tests/cases/3-instructions@multiple.snap
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
source: tests/file_tests.rs
|
||||||
|
expression: emit
|
||||||
|
input_file: tests/cases/multiple.temple
|
||||||
|
---
|
||||||
|
[
|
||||||
|
AppendContent {
|
||||||
|
content: "Hi there! My name is",
|
||||||
|
},
|
||||||
|
AppendContent {
|
||||||
|
content: " ",
|
||||||
|
},
|
||||||
|
LoadFromContextToSlot {
|
||||||
|
name: "name",
|
||||||
|
slot: VariableSlot {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
EmitFromSlot {
|
||||||
|
slot: VariableSlot {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
AppendContent {
|
||||||
|
content: " ",
|
||||||
|
},
|
||||||
|
LoadFromContextToSlot {
|
||||||
|
name: "lastname",
|
||||||
|
slot: VariableSlot {
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
EmitFromSlot {
|
||||||
|
slot: VariableSlot {
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
6
tests/cases/4-output@multiple.snap
Normal file
6
tests/cases/4-output@multiple.snap
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
source: tests/file_tests.rs
|
||||||
|
expression: output
|
||||||
|
input_file: tests/cases/multiple.temple
|
||||||
|
---
|
||||||
|
"Hi there! My name is Hemera Green"
|
||||||
6
tests/cases/multiple.temple
Normal file
6
tests/cases/multiple.temple
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "Hemera",
|
||||||
|
"lastname": "Green"
|
||||||
|
}
|
||||||
|
---
|
||||||
|
Hi there! My name is {{= name }} {{= lastname }}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue