UNPKG

meld-spec

Version:

Specification for the Meld scripting language

172 lines (171 loc) 5.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runInvalidTests = void 0; /** * Invalid test cases for the @run 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.runInvalidTests = [ // Empty command { name: 'empty-command', input: '@run []', expected: { type: 'Error', error: 'Empty command in @run directive' }, description: 'Command cannot be empty' }, { name: 'whitespace-command', input: '@run [ ]', expected: { type: 'Error', error: 'Empty command in @run directive' }, description: 'Command cannot be only whitespace' }, // Invalid variable usage { name: 'data-var-in-command', input: '@run [echo #{data}]', expected: { type: 'Error', error: 'Data variables not allowed in command arguments' }, description: 'Cannot use data variables in commands' }, { name: 'invalid-path-var', input: '@run [ls $HOMEPATH folder]', expected: { type: 'Error', error: 'Special path variables must be followed by /' }, description: 'Special path variables must be followed by /' }, { name: 'invalid-project-var', input: '@run [ls $.folder]', expected: { type: 'Error', error: 'Special path variables must be followed by /' }, description: 'Project path alias must be followed by /' }, // Command reference errors { name: 'reference-without-params', input: '@run [$command]', expected: { type: 'Error', error: 'Command reference must include parameters' }, description: 'Command references require parameters' }, { name: 'reference-empty-params', input: '@run [$command()]', expected: { type: 'Error', error: 'Empty parameter list in command reference' }, description: 'Command reference parameters cannot be empty' }, { name: 'reference-invalid-param', input: '@run [$command(invalid)]', expected: { type: 'Error', error: 'Command parameters must be text variables' }, description: 'Command parameters must use ${var} syntax' }, { name: 'reference-data-param', input: '@run [$command(#{data})]', expected: { type: 'Error', error: 'Command parameters must be text variables' }, description: 'Cannot use data variables as parameters' }, // Syntax errors { name: 'missing-closing-bracket', input: '@run [echo "hello"', expected: { type: 'Error', error: 'Unclosed [ in @run directive' }, description: 'Must close brackets' }, { name: 'missing-opening-bracket', input: '@run echo "hello"]', expected: { type: 'Error', error: 'Missing [ in @run directive' }, description: 'Must open brackets' }, { name: 'missing-closing-paren', input: '@run [$cmd(${var}]', expected: { type: 'Error', error: 'Unclosed ( in command reference' }, description: 'Must close parentheses in references' }, // Indentation errors { name: 'indented-directive', input: ' @run [echo "hello"]', expected: { type: 'Error', error: 'Directives must appear at the start of a line' }, description: 'Directives cannot be indented' }, // Invalid combinations { name: 'nested-command-ref', input: '@run [$outer($inner(${var}))]', expected: { type: 'Error', error: 'Nested command references not allowed' }, description: 'Cannot nest command references' }, { name: 'mixed-command-types', input: '@run [echo $command(${var})]', expected: { type: 'Error', error: 'Cannot mix literal commands with command references' }, description: 'Must use either literal command or reference, not both' }, // Variable errors { name: 'nested-text-var', input: '@run [echo ${var${inner}}]', expected: { type: 'Error', error: 'Nested variable interpolation not allowed' }, description: 'Cannot nest variable references' }, { name: 'invalid-var-format', input: '@run [echo ${var >> (upper)}]', expected: { type: 'Error', error: 'Format operator not allowed in command variables' }, description: 'Cannot use format operator in commands' } ];