const test = require('tape') const helpers = require('./helpers') const AST = require('../src/ast/index') const tt = require('../src/tokenTypes') test('parses token stream into a tree', t => { t.plan(1) const tree = helpers.parse(` (div :class "foobar" (p :class (cond #t "primary" "secondary"))) `) t.deepEqual(tree, [ new AST.Application({ functionName: new AST.Identifier({ name: 'div' }), args: [ new AST.Attribute({ name: 'class', value: new AST.String({ value: 'foobar' }), }), new AST.Application({ functionName: new AST.Identifier({ name: 'p' }), args: [ new AST.Attribute({ name: 'class', value: new AST.Application({ functionName: new AST.Identifier({ name: 'cond' }), args: [ new AST.Boolean({ value: true }), new AST.String({ value: 'primary' }), new AST.String({ value: 'secondary' }), ], }), }), ], }), ], }), ]) }) test('allow empty strings', t => { t.plan(1) const tree = helpers.parse('(p "")') t.deepEqual(tree, [ new AST.Application({ functionName: new AST.Identifier({ name: 'p' }), args: [new AST.String({ value: '' })], }), ]) })