UNPKG

meld-spec

Version:

Specification for the Meld scripting language

155 lines (154 loc) 4.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.textInvalidTests = void 0; /** * Invalid test cases for the @text directive that implementations must handle correctly. * These cases should either: * 1. Throw an error with a helpful message * 2. Return a partial AST marking the error */ exports.textInvalidTests = [ // Invalid identifiers { name: 'empty-identifier', input: '@text = "value"', expected: { type: 'Error', error: 'Text identifier cannot be empty' }, description: 'Text identifier is required' }, { name: 'invalid-identifier', input: '@text 123name = "value"', expected: { type: 'Error', error: 'Invalid identifier: must start with letter or underscore' }, description: 'Text identifier must be valid' }, // Invalid string literals { name: 'unclosed-string', input: '@text message = "unclosed', expected: { type: 'Error', error: 'Unclosed string literal' }, description: 'String literals must be closed' }, { name: 'mixed-quotes', input: '@text message = "mixed\'quotes"', expected: { type: 'Error', error: 'Cannot mix quote types in string literal' }, description: 'String literals must use consistent quotes' }, // Invalid embed source { name: 'invalid-embed', input: '@text content = @embed file.md', expected: { type: 'Error', error: 'Invalid embed syntax: missing []' }, description: 'Embed source must use proper syntax' }, { name: 'empty-embed-path', input: '@text content = @embed []', expected: { type: 'Error', error: 'Empty path in embed source' }, description: 'Embed path cannot be empty' }, // Invalid run source { name: 'invalid-run', input: '@text output = @run echo "hello"', expected: { type: 'Error', error: 'Invalid run syntax: missing []' }, description: 'Run source must use proper syntax' }, { name: 'empty-run-command', input: '@text output = @run []', expected: { type: 'Error', error: 'Empty command in run source' }, description: 'Run command cannot be empty' }, // Invalid call source { name: 'invalid-call', input: '@text response = @call api', expected: { type: 'Error', error: 'Invalid call syntax: missing method and path' }, description: 'Call source must specify method and path' }, { name: 'invalid-call-method', input: '@text response = @call api.invalid [/path]', expected: { type: 'Error', error: 'Invalid HTTP method in call source' }, description: 'Call method must be valid HTTP method' }, // Invalid variable usage { name: 'nested-variable', input: '@text message = "Hello ${name${inner}}!"', expected: { type: 'Error', error: 'Nested variable interpolation not allowed' }, description: 'Cannot nest variable references' }, { name: 'invalid-format', input: '@text message = "${var>>(invalid)}"', expected: { type: 'Error', error: 'Invalid format operator in text' }, description: 'Format operator not allowed in text directive' }, // Indentation errors { name: 'indented-directive', input: ' @text message = "value"', expected: { type: 'Error', error: 'Directives must appear at start of line' }, description: 'Directives cannot be indented' }, // Syntax errors { name: 'missing-equals', input: '@text message "value"', expected: { type: 'Error', error: 'Missing = in text assignment' }, description: 'Text assignment requires equals sign' }, { name: 'extra-tokens', input: '@text message = "value" extra', expected: { type: 'Error', error: 'Unexpected tokens after text value' }, description: 'No extra tokens allowed after value' } ];