UNPKG

meld-spec

Version:

Specification for the Meld scripting language

215 lines (214 loc) 6.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pathTests = void 0; /** * Test cases for the @path directive that all implementations must pass */ exports.pathTests = [ // Basic path assignment { name: 'basic-path', input: '@path docs = [documents/files]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'docs', path: { raw: 'documents/files', structured: { base: '.', segments: ['documents', 'files'], variables: {} } } } }, description: 'Basic path assignment' }, // HOMEPATH variable { name: 'home-path', input: '@path docs = [$HOMEPATH/documents]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'docs', path: { raw: '$HOMEPATH/documents', structured: { base: '$HOMEPATH', segments: ['documents'], variables: { special: ['HOMEPATH'] } } } } }, description: 'Path with HOMEPATH variable' }, // Home alias { name: 'home-alias', input: '@path docs = [$~/documents]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'docs', path: { raw: '$~/documents', structured: { base: '$~', segments: ['documents'], variables: { special: ['HOMEPATH'] } } } } }, description: 'Path with ~ alias for HOMEPATH' }, // PROJECTPATH variable { name: 'project-path', input: '@path src = [$PROJECTPATH/src]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'src', path: { raw: '$PROJECTPATH/src', structured: { base: '$PROJECTPATH', segments: ['src'], variables: { special: ['PROJECTPATH'] } } } } }, description: 'Path with PROJECTPATH variable' }, // Project alias { name: 'project-alias', input: '@path src = [$./src]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'src', path: { raw: '$./src', structured: { base: '$.', segments: ['src'], variables: { special: ['PROJECTPATH'] } } } } }, description: 'Path with . alias for PROJECTPATH' }, // Nested paths { name: 'nested-path', input: '@path deep = [$PROJECTPATH/src/lib/utils]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'deep', path: { raw: '$PROJECTPATH/src/lib/utils', structured: { base: '$PROJECTPATH', segments: ['src', 'lib', 'utils'], variables: { special: ['PROJECTPATH'] } } } } }, description: 'Deeply nested path' }, // Path with text variables { name: 'path-with-var', input: '@path user_docs = [$HOMEPATH/${username}/docs]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'user_docs', path: { raw: '$HOMEPATH/${username}/docs', structured: { base: '$HOMEPATH', segments: ['${username}', 'docs'], variables: { special: ['HOMEPATH'], text: ['username'] } } } } }, description: 'Path with text variable interpolation' }, // Path with brackets { name: 'path-with-brackets', input: '@path special = [$PROJECTPATH/data/[version]/config]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'special', path: { raw: '$PROJECTPATH/data/[version]/config', structured: { base: '$PROJECTPATH', segments: ['data', '[version]', 'config'], variables: { special: ['PROJECTPATH'] } } } } }, description: 'Path containing brackets' }, // Multiple path variables { name: 'multiple-vars', input: '@path backup = [$HOMEPATH/backups/$PROJECTPATH/latest]', expected: { type: 'Directive', directive: { kind: 'path', identifier: 'backup', path: { raw: '$HOMEPATH/backups/$PROJECTPATH/latest', structured: { base: '$HOMEPATH', segments: ['backups', '$PROJECTPATH', 'latest'], variables: { special: ['HOMEPATH', 'PROJECTPATH'] } } } } }, description: 'Path with multiple special variables' } ];