UNPKG

ion

Version:

ion language ========================

938 lines (937 loc) 184 kB
void (function(){var _ion_test_reactiveTemplates_ = function(module,exports,require){'use strict'; var ion = require('../'); var _ref4 = []; { _ref4.push('this'); var object = { x: 1, y: 2 }; _ref4.push(object); _ref4.push(ion.template(function () { return ion.createRuntime({ type: 'Template', id: null, body: [{ type: 'ReturnStatement', argument: { type: 'BinaryExpression', operator: '+', left: { type: 'MemberExpression', computed: false, object: { type: 'ThisExpression' }, property: { type: 'Identifier', name: 'x', loc: { start: { line: 99, column: 25, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 99, column: 26, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, loc: { start: { line: 99, column: 20, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 99, column: 26, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, right: { type: 'MemberExpression', computed: false, object: { type: 'ThisExpression' }, property: { type: 'Identifier', name: 'y', loc: { start: { line: 99, column: 34, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 99, column: 35, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, loc: { start: { line: 99, column: 29, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 99, column: 35, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } } }, order: '0' }], bound: false }, { this: this, object: object, ion: ion, _ref4: _ref4, templates: templates, _ref5: _ref5 }, null); })); _ref4.push(object); _ref4.push({ x: 10 }); _ref4.push(12); } var templates = [ [ 'regular expression', {}, ion.template(function (properties) { return ion.createRuntime({ type: 'Template', id: null, body: [{ type: 'ReturnStatement', argument: { type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: 'properties', loc: { start: { line: 8, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 8, column: 29, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, property: { type: 'Identifier', name: 'name', loc: { start: { line: 8, column: 30, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 8, column: 34, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, loc: { start: { line: 8, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 8, column: 34, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, property: { type: 'Identifier', name: 'replace', loc: { start: { line: 8, column: 35, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 8, column: 42, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, loc: { start: { line: 8, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 8, column: 42, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, arguments: [ { type: 'Literal', value: /a/g }, { type: 'Literal', value: 'b' } ], loc: { start: { line: 8, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 8, column: 53, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, order: '0' }], bound: false }, { this: this, properties: properties, ion: ion, _ref4: _ref4, templates: templates, _ref5: _ref5 }, null); }), { name: 'alpha' }, {}, 'blphb' ], [ 'array comprehension for of', {}, ion.template(function (properties) { return ion.createRuntime({ type: 'Template', id: null, body: [{ type: 'ReturnStatement', argument: { type: 'ObjectExpression', objectType: { type: 'ArrayExpression', elements: [] }, properties: [{ type: 'ForInStatement', left: { type: 'VariableDeclaration', declarations: [{ type: 'VariableDeclarator', id: { type: 'Identifier', name: 'key', loc: { start: { line: 16, column: 28, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 16, column: 31, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: null }], kind: 'let' }, right: { type: 'Identifier', name: 'properties', loc: { start: { line: 16, column: 35, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 16, column: 45, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, body: { type: 'ExpressionStatement', expression: { type: 'Identifier', name: 'key', loc: { start: { line: 16, column: 20, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 16, column: 23, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } } }, order: '0' }] }, order: '0' }], bound: false }, { this: this, properties: properties, ion: ion, _ref4: _ref4, templates: templates, _ref5: _ref5 }, null); }), { a: 1, b: 2 }, { b: void 0, c: 3 }, [ 'a', 'c' ] ], [ 'imperative functions', {}, ion.template(function (properties) { return ion.createRuntime({ type: 'Template', id: null, body: [ { type: 'VariableDeclaration', declarations: [{ type: 'VariableDeclarator', id: { type: 'Identifier', name: 'double', loc: { start: { line: 24, column: 18, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 24, column: 24, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: { type: 'Function', context: false, value: function double(a) { return a * 2; } } }], kind: 'const', order: '0' }, { type: 'ReturnStatement', argument: { type: 'ObjectExpression', objectType: { type: 'ObjectExpression', properties: [] }, properties: [{ type: 'ForInStatement', left: { type: 'VariableDeclaration', declarations: [ { type: 'VariableDeclarator', id: { type: 'Identifier', name: 'key', loc: { start: { line: 26, column: 20, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 26, column: 23, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: null }, { type: 'VariableDeclarator', id: { type: 'Identifier', name: 'value', loc: { start: { line: 26, column: 25, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 26, column: 30, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: null } ], kind: 'let' }, right: { type: 'Identifier', name: 'properties', loc: { start: { line: 26, column: 34, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 26, column: 44, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, body: { type: 'BlockStatement', body: [{ type: 'Property', key: { type: 'Identifier', name: 'key', loc: { start: { line: 27, column: 21, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 27, column: 24, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, value: { type: 'CallExpression', callee: { type: 'Identifier', name: 'double', loc: { start: { line: 27, column: 27, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 27, column: 33, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, arguments: [{ type: 'Identifier', name: 'value', loc: { start: { line: 27, column: 34, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 27, column: 39, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }], loc: { start: { line: 27, column: 27, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 27, column: 40, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, kind: 'init', computed: true, order: '0' }] }, remove: null, order: '0' }] }, order: '1' } ], bound: false }, { this: this, properties: properties, ion: ion, _ref4: _ref4, templates: templates, _ref5: _ref5 }, null); }), { x: 1, y: 2 }, { x: 4, z: 3, y: void 0 }, { x: 8, z: 6 } ], [ 'reactive destructured parameters', {}, ion.template(function (_ref) { return ion.createRuntime({ type: 'Template', id: null, body: [ { type: 'VariableDeclaration', declarations: [{ type: 'VariableDeclarator', id: { type: 'Identifier', name: 'a', loc: { start: { line: 46, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 46, column: 20, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: { type: 'MemberExpression', object: { type: 'Identifier', name: '_ref' }, property: { type: 'Identifier', name: 'a', loc: { start: { line: 46, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 46, column: 20, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, computed: false } }], kind: 'let', order: '0' }, { type: 'VariableDeclaration', declarations: [{ type: 'VariableDeclarator', id: { type: 'Identifier', name: 'b', loc: { start: { line: 46, column: 21, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 46, column: 22, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: { type: 'MemberExpression', object: { type: 'Identifier', name: '_ref' }, property: { type: 'Identifier', name: 'b', loc: { start: { line: 46, column: 21, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 46, column: 22, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, computed: false } }], kind: 'let', order: '1' }, { type: 'ReturnStatement', argument: { type: 'BinaryExpression', operator: '+', left: { type: 'Identifier', name: 'a', loc: { start: { line: 46, column: 28, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 46, column: 29, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, right: { type: 'Identifier', name: 'b', loc: { start: { line: 46, column: 32, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 46, column: 33, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } } }, order: '2' } ], bound: false }, { this: this, _ref: _ref, ion: ion, _ref4: _ref4, templates: templates, _ref5: _ref5 }, null); }), { a: 1, b: 2 }, { a: 5 }, 7 ], [ 'array comprehension for in', {}, ion.template(function (_ref2) { return ion.createRuntime({ type: 'Template', id: null, body: [ { type: 'VariableDeclaration', declarations: [{ type: 'VariableDeclarator', id: { type: 'Identifier', name: 'items', loc: { start: { line: 53, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 53, column: 24, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: { type: 'MemberExpression', object: { type: 'Identifier', name: '_ref2' }, property: { type: 'Identifier', name: 'items', loc: { start: { line: 53, column: 19, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 53, column: 24, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, computed: false } }], kind: 'let', order: '0' }, { type: 'ReturnStatement', argument: { type: 'ObjectExpression', objectType: { type: 'ArrayExpression', elements: [] }, properties: [{ type: 'ForOfStatement', left: { type: 'VariableDeclaration', declarations: [ { type: 'VariableDeclarator', id: { type: 'Identifier', name: 'x', loc: { start: { line: 53, column: 41, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 53, column: 42, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: null }, { type: 'VariableDeclarator', id: { type: 'Identifier', name: 'i', loc: { start: { line: 53, column: 44, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 53, column: 45, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, init: null } ], kind: 'let' }, right: { type: 'Identifier', name: 'items', loc: { start: { line: 53, column: 49, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 53, column: 54, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, body: { type: 'ExpressionStatement', expression: { type: 'BinaryExpression', operator: '+', left: { type: 'Identifier', name: 'x', loc: { start: { line: 53, column: 31, fixed: true, source: 'ion/test/reactiveTemplates.ion' }, end: { line: 53, column: 32, fixed: true, source: 'ion/test/reactiveTemplates.ion' } } }, right: { type: 'Identifier', name: 'i', loc: { start: { line: 53, column: 35, fixed: true, source: 'ion/test/reactiveTemplates.ion'