UNPKG

meld-spec

Version:

Specification for the Meld scripting language

186 lines (185 loc) 5.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defineTests = void 0; /** * Test cases for the @define directive that all implementations must pass */ exports.defineTests = [ // Basic command definition { name: 'basic-command', input: '@define greet = @run [echo "hello"]', expected: { type: 'Directive', directive: { kind: 'define', name: 'greet', command: { kind: 'run', command: 'echo "hello"' } } }, description: 'Basic command definition' }, // Command with parameters { name: 'command-with-params', input: '@define greet(name, message) = @run [echo "Hello ${name}, ${message}"]', expected: { type: 'Directive', directive: { kind: 'define', name: 'greet', parameters: ['name', 'message'], command: { kind: 'run', command: 'echo "Hello ${name}, ${message}"' } } }, description: 'Command with parameters' }, // Command with single parameter { name: 'single-param', input: '@define echo(message) = @run [echo ${message}]', expected: { type: 'Directive', directive: { kind: 'define', name: 'echo', parameters: ['message'], command: { kind: 'run', command: 'echo ${message}' } } }, description: 'Command with single parameter' }, // Command with risk metadata { name: 'risk-metadata', input: '@define cmd.risk = "low"', expected: { type: 'Directive', directive: { kind: 'define', name: 'cmd', field: 'risk', value: 'low' } }, description: 'Command with risk level' }, // Command with specific risk levels { name: 'risk-high', input: '@define cmd.risk.high = "Destructive operation"', expected: { type: 'Directive', directive: { kind: 'define', name: 'cmd', field: 'risk.high', value: 'Destructive operation' } }, description: 'Command with high risk' }, { name: 'risk-med', input: '@define cmd.risk.med = "Use with caution"', expected: { type: 'Directive', directive: { kind: 'define', name: 'cmd', field: 'risk.med', value: 'Use with caution' } }, description: 'Command with medium risk' }, { name: 'risk-low', input: '@define cmd.risk.low = "Safe operation"', expected: { type: 'Directive', directive: { kind: 'define', name: 'cmd', field: 'risk.low', value: 'Safe operation' } }, description: 'Command with low risk' }, // Command with about metadata { name: 'about-metadata', input: '@define cmd.about = "Description of the command"', expected: { type: 'Directive', directive: { kind: 'define', name: 'cmd', field: 'about', value: 'Description of the command' } }, description: 'Command with about information' }, // Command with meta metadata { name: 'meta-metadata', input: '@define cmd.meta = "Additional metadata"', expected: { type: 'Directive', directive: { kind: 'define', name: 'cmd', field: 'meta', value: 'Additional metadata' } }, description: 'Command with meta information' }, // Complex command with multiple parameters { name: 'complex-command', input: '@define deploy(env, version) = @run [echo "Deploying ${version} to ${env}" && deploy --env=${env} --version=${version}]', expected: { type: 'Directive', directive: { kind: 'define', name: 'deploy', parameters: ['env', 'version'], command: { kind: 'run', command: 'echo "Deploying ${version} to ${env}" && deploy --env=${env} --version=${version}' } } }, description: 'Complex command with multiple parameters' }, // Command with special path variables { name: 'path-variables', input: '@define backup(name) = @run [cp $PROJECTPATH/src/${name} $HOMEPATH/backups/]', expected: { type: 'Directive', directive: { kind: 'define', name: 'backup', parameters: ['name'], command: { kind: 'run', command: 'cp $PROJECTPATH/src/${name} $HOMEPATH/backups/' } } }, description: 'Command using special path variables' } ];