feat: nil/null/empty/blank literals, resolves #102

This commit is contained in:
harttle
2019-02-24 21:50:01 +08:00
parent 54b2adce12
commit 88c9e96392
19 changed files with 355 additions and 52 deletions
+8 -2
View File
@@ -2,7 +2,7 @@ import Scope from 'src/scope/scope'
import { expect } from 'chai'
import { evalExp, evalValue, isTruthy } from 'src/render/syntax'
describe('expression', function () {
describe('render/syntax', function () {
let scope: Scope
beforeEach(function () {
@@ -29,10 +29,16 @@ describe('expression', function () {
expect(evalValue('-23.', scope)).to.equal(-23)
expect(evalValue('23', scope)).to.equal(23)
})
it('should eval literal', function () {
it('should eval string literal', function () {
expect(evalValue('"ab\'c"', scope)).to.equal("ab'c")
expect(evalValue("'ab\"c'", scope)).to.equal('ab"c')
})
it('should eval nil literal', function () {
expect(evalValue('nil', scope)).to.be.null
})
it('should eval null literal', function () {
expect(evalValue('null', scope)).to.be.null
})
it('should eval scope variables', function () {
expect(evalValue('one', scope)).to.equal(1)
expect(evalValue('has_value?', scope)).to.equal(true)