fix: expression and string literal parser, #186

This commit is contained in:
harttle
2020-02-08 03:15:55 +08:00
parent 46b69db87a
commit fc0cf6fe7b
8 changed files with 222 additions and 50 deletions
+11 -1
View File
@@ -65,8 +65,18 @@ describe('tags/if', function () {
const html = await liquid.parseAndRender(src)
return expect(html).to.equal('')
})
it('should allow no spaces around operator for literal', async function () {
const src = `{% if true==true %}success{%else%}fail{% endif %}`
const html = await liquid.parseAndRender(src)
return expect(html).to.equal('success')
})
it('should allow no spaces around operator for variables', async function () {
const src = `{%assign var = 1%}{%if var ==1%}success{%else%}fail{%endif%}`
const html = await liquid.parseAndRender(src)
return expect(html).to.equal('success')
})
})
describe('comparasion to null', function () {
describe('compare to null', function () {
it('should evaluate false for null < 10', async function () {
const src = '{% if null < 10 %}yes{% else %}no{% endif %}'
const html = await liquid.parseAndRender(src, scope)