UNPKG

meld-spec

Version:

Specification for the Meld scripting language

184 lines (183 loc) 5.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.textTests = void 0; /** * Test cases for the @text directive that all implementations must pass */ exports.textTests = [ // String literal assignment { name: 'string-literal', input: '@text message = "Hello, world!"', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'message', value: 'Hello, world!', source: 'literal' } }, description: 'Basic string literal assignment' }, { name: 'string-with-quotes', input: '@text message = "Contains \'mixed\' and `quotes`"', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'message', value: 'Contains \'mixed\' and `quotes`', source: 'literal' } }, description: 'String literal with different quote types' }, // @embed source { name: 'embed-source', input: '@text content = @embed [file.md]', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'content', source: 'embed', embed: { kind: 'embed', path: { raw: 'file.md', normalized: './file.md', structured: { base: '.', segments: ['file.md'], variables: {} } } } } }, description: 'Text from embed directive' }, { name: 'embed-with-section', input: '@text intro = @embed [doc.md # Introduction]', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'intro', source: 'embed', embed: { kind: 'embed', path: { raw: 'doc.md', normalized: './doc.md', structured: { base: '.', segments: ['doc.md'], variables: {} } }, section: 'Introduction' } } }, description: 'Text from embed with section' }, // @run source { name: 'run-source', input: '@text output = @run [echo "hello"]', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'output', source: 'run', run: { kind: 'run', command: 'echo "hello"' } } }, description: 'Text from run directive' }, { name: 'run-with-vars', input: '@text result = @run [$command(${param1}, ${param2})]', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'result', source: 'run', run: { kind: 'run', command: '$command(${param1}, ${param2})', isReference: true } } }, description: 'Text from run with command reference' }, // @call source // TODO: REVISIT THIS TEST AFTER THE DESIGN IS REVISED // { // name: 'call-source', // input: '@text response = @call api.get [/endpoint]', // expected: { // type: 'Directive', // directive: { // kind: 'text', // identifier: 'response', // source: 'call', // call: { // kind: 'call', // api: 'api', // method: 'get', // path: '/endpoint' // } // } // } as DirectiveNode, // description: 'Text from API call' // }, { name: 'call-with-payload', input: '@text response = @call api.post [/users] {{ name: ${name} }}', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'response', source: 'call', call: { kind: 'call', api: 'api', method: 'post', path: '/users', payload: { name: '${name}' } } } }, description: 'Text from API call with payload' }, // Variable interpolation { name: 'text-interpolation', input: '@text greeting = "Hello ${name}!"', expected: { type: 'Directive', directive: { kind: 'text', identifier: 'greeting', value: 'Hello ${name}!', source: 'literal' } }, description: 'String literal with text variable' } ];