UNPKG

meld-spec

Version:

Specification for the Meld scripting language

154 lines (153 loc) 4.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.importInvalidTests = void 0; /** * Invalid test cases for the @import 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.importInvalidTests = [ // Empty path { name: 'empty-path', input: '@import []', expected: { type: 'Error', error: 'Empty path in @import directive' }, description: 'Path cannot be empty' }, { name: 'whitespace-path', input: '@import [ ]', expected: { type: 'Error', error: 'Empty path in @import directive' }, description: 'Path cannot be only whitespace' }, // Invalid variable usage { name: 'data-var-in-path', input: '@import [#{data}]', expected: { type: 'Error', error: 'Data variables not allowed in import path' }, description: 'Cannot use data variables in path' }, { name: 'invalid-path-var', input: '@import [$HOMEPATH file]', expected: { type: 'Error', error: 'Special path variables must be followed by /' }, description: 'Special path variables must be followed by /' }, { name: 'invalid-project-var', input: '@import [$.file]', expected: { type: 'Error', error: 'Special path variables must be followed by /' }, description: 'Project path alias must be followed by /' }, // Syntax errors { name: 'missing-closing-bracket', input: '@import [file.md', expected: { type: 'Error', error: 'Unclosed [ in @import directive' }, description: 'Must close brackets' }, { name: 'missing-opening-bracket', input: '@import file.md]', expected: { type: 'Error', error: 'Missing [ in @import directive' }, description: 'Must open brackets' }, { name: 'unclosed-nested-bracket', input: '@import [file[.md]', expected: { type: 'Error', error: 'Unclosed [ in nested path' }, description: 'Must close nested brackets' }, // Indentation errors { name: 'indented-directive', input: ' @import [file.md]', expected: { type: 'Error', error: 'Directives must appear at the start of a line' }, description: 'Directives cannot be indented' }, // Variable errors { name: 'nested-text-var', input: '@import [${var${inner}}]', expected: { type: 'Error', error: 'Nested variable interpolation not allowed' }, description: 'Cannot nest variable references' }, { name: 'invalid-var-format', input: '@import [${var>>(upper)}]', expected: { type: 'Error', error: 'Format operator not allowed in import path' }, description: 'Cannot use format operator in path' }, // Path validation { name: 'absolute-path', input: '@import [/absolute/path.md]', expected: { type: 'Error', error: 'Absolute paths not allowed in @import' }, description: 'Cannot use absolute paths' }, { name: 'parent-dir-path', input: '@import [../../outside.md]', expected: { type: 'Error', error: 'Path attempts to access parent directory' }, description: 'Cannot access parent directories' }, // Extra arguments { name: 'extra-arguments', input: '@import [file.md] extra', expected: { type: 'Error', error: '@import directive takes only a path argument' }, description: 'Cannot have extra arguments' }, { name: 'under-header', input: '@import [file.md] under Header', expected: { type: 'Error', error: '@import directive does not support under header' }, description: 'Cannot use under header' } ];