Skip to content

Commit 2a849a0

Browse files
committed
?toUpperCase and ?string tests
1 parent 3be9b03 commit 2a849a0

File tree

2 files changed

+62
-9
lines changed

2 files changed

+62
-9
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,26 @@ console.log(data.tokens)
7070
- `#stop`
7171
- `#setting`
7272
- comments `<#-- -->`
73-
74-
## TODO:
7573
- built-ins:
7674
- `?toUpperCase`
7775
- `?toLowerCase`
7876
- `?capitalize`
7977
- `?length`
8078
- `?string("yes", "no")`
81-
- size builtin for arrays
79+
80+
## TODO:
8281
- support default values, i.e. `${user!"Anonymous"}`
83-
- null resistance in above expressions if in parenthesis
84-
- alternative syntax if starts with `[#ftl]`
82+
- alternative syntax `[` or `<`
8583
- directives:
8684
- `#escape`
8785
- `#noescape`
8886
- `#fallback`
8987
- `#flush`
90-
- `#lt`
9188
- `#nested`
92-
- `#nt`
9389
- `#recurse`
94-
- `#rt`
95-
- `#t`
9690
- `#visit`
91+
92+
- `#lt`
93+
- `#t`
94+
- `#nt`
95+
- `#rt`

test/params.spec.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,58 @@ describe('params parser', () => {
8181
}
8282
assert.deepStrictEqual(result, expected, 'value is not matching')
8383
})
84+
it('toUpperCase', () => {
85+
const result = parser.parse('foo?toUpperCase')
86+
const expected = {
87+
type: ParamNames.Compound,
88+
body: [
89+
{
90+
type: ParamNames.Identifier,
91+
name: 'foo',
92+
},
93+
{
94+
type: ParamNames.UnaryExpression,
95+
operator: '?',
96+
prefix: true,
97+
argument: {
98+
type: ParamNames.Identifier,
99+
name: 'toUpperCase',
100+
},
101+
},
102+
],
103+
}
104+
assert.deepStrictEqual(result, expected, 'value is not matching')
105+
})
106+
it('to string', () => {
107+
const result = parser.parse('foo?string("yes")')
108+
const expected = {
109+
type: ParamNames.Compound,
110+
body: [
111+
{
112+
type: ParamNames.Identifier,
113+
name: 'foo',
114+
},
115+
{
116+
type: ParamNames.UnaryExpression,
117+
operator: '?',
118+
prefix: true,
119+
argument: {
120+
type: ParamNames.CallExpression,
121+
arguments: [
122+
{
123+
type: ParamNames.Literal,
124+
raw: '"yes"',
125+
value: 'yes',
126+
},
127+
],
128+
callee: {
129+
name: 'string',
130+
type: ParamNames.Identifier,
131+
},
132+
},
133+
},
134+
],
135+
}
136+
assert.deepStrictEqual(result, expected, 'value is not matching')
137+
})
84138
})

0 commit comments

Comments
 (0)