mirror of
https://github.com/sasjs/lint.git
synced 2025-12-11 01:44:36 +00:00
fix(parseMacro): updated to have macros with parameters + options
This commit is contained in:
@@ -25,6 +25,76 @@ describe('parseMacros', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an array with a single macro having parameters', () => {
|
||||
const text = `%macro test(var,sum);
|
||||
%put 'hello';
|
||||
%mend`
|
||||
|
||||
const macros = parseMacros(text, new LintConfig())
|
||||
|
||||
expect(macros.length).toEqual(1)
|
||||
expect(macros).toContainEqual({
|
||||
name: 'test',
|
||||
declarationLine: '%macro test(var,sum);',
|
||||
terminationLine: '%mend',
|
||||
declaration: '%macro test(var,sum)',
|
||||
termination: '%mend',
|
||||
startLineNumber: 1,
|
||||
endLineNumber: 3,
|
||||
parentMacro: '',
|
||||
hasMacroNameInMend: false,
|
||||
hasParentheses: false,
|
||||
mismatchedMendMacroName: ''
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an array with a single macro having PARMBUFF option', () => {
|
||||
const text = `%macro test/parmbuff;
|
||||
%put 'hello';
|
||||
%mend`
|
||||
|
||||
const macros = parseMacros(text, new LintConfig())
|
||||
|
||||
expect(macros.length).toEqual(1)
|
||||
expect(macros).toContainEqual({
|
||||
name: 'test',
|
||||
declarationLine: '%macro test/parmbuff;',
|
||||
terminationLine: '%mend',
|
||||
declaration: '%macro test/parmbuff',
|
||||
termination: '%mend',
|
||||
startLineNumber: 1,
|
||||
endLineNumber: 3,
|
||||
parentMacro: '',
|
||||
hasMacroNameInMend: false,
|
||||
hasParentheses: false,
|
||||
mismatchedMendMacroName: ''
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an array with a single macro having paramerter & SOURCE option', () => {
|
||||
const text = `/* commentary */ %macro foobar(arg) /store source
|
||||
des="This macro does not do much";
|
||||
%put 'hello';
|
||||
%mend`
|
||||
|
||||
const macros = parseMacros(text, new LintConfig())
|
||||
|
||||
expect(macros.length).toEqual(1)
|
||||
expect(macros).toContainEqual({
|
||||
name: 'foobar',
|
||||
declarationLine: '/* commentary */ %macro foobar(arg) /store source',
|
||||
terminationLine: '%mend',
|
||||
declaration: '%macro foobar(arg) /store source',
|
||||
termination: '%mend',
|
||||
startLineNumber: 1,
|
||||
endLineNumber: 4,
|
||||
parentMacro: '',
|
||||
hasMacroNameInMend: false,
|
||||
hasParentheses: false,
|
||||
mismatchedMendMacroName: ''
|
||||
})
|
||||
})
|
||||
|
||||
it('should return an array with multiple macros', () => {
|
||||
const text = `%macro foo;
|
||||
%put 'foo';
|
||||
|
||||
@@ -43,6 +43,7 @@ export const parseMacros = (text: string, config?: LintConfig): Macro[] => {
|
||||
const name = trimmedStatement
|
||||
.slice(7, trimmedStatement.length)
|
||||
.trim()
|
||||
.split('/')[0]
|
||||
.split('(')[0]
|
||||
macroStack.push({
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user