-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
langium generate: fixed a hidden bug in 'node-processor.ts' of Langium's 'generate' facility #1814
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -832,9 +832,47 @@ describe('Multiple nested substitution templates', () => { | |
generated text! | ||
`); | ||
}); | ||
|
||
test('Nested substitution of with indented nested template starting with an _undefined_ line', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case reflects the critical case, nice! |
||
expect( | ||
toString(n` | ||
begin: | ||
${n` | ||
${undefined} | ||
${nestedNode} | ||
`} | ||
`) | ||
).toBe( | ||
s` | ||
begin: | ||
More | ||
generated text! | ||
` | ||
); | ||
}); | ||
|
||
test('Nested substitution of with indented nested template starting with an _empty string_ line', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This case already worked before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. It's good to have it still, especially in contrast to the above one. |
||
expect( | ||
toString(n` | ||
begin: | ||
${n` | ||
${''} | ||
${nestedNode} | ||
`} | ||
`) | ||
).toBe( | ||
s` | ||
begin: | ||
${/* 's' automatically trims the empty lines completely, so insert */'<DUMMY>'} | ||
More | ||
generated text! | ||
`.replace('<DUMMY>', '') | ||
); | ||
}); | ||
|
||
}); | ||
|
||
describe('Embedded forEach loops', () => { | ||
describe('Joining lists', () => { | ||
test('ForEach loop with empty iterable', () => { | ||
const node = n` | ||
Data: | ||
|
@@ -1083,6 +1121,18 @@ describe('Embedded forEach loops', () => { | |
b | ||
`); | ||
}); | ||
|
||
test('Nested ForEach loop with empty iterable followed by an indented line', () => { | ||
const node = n` | ||
${joinToNode([], { appendNewLineIfNotEmpty: true})} | ||
a | ||
`; | ||
const text = toString(node); | ||
expect(text).toBe(s` | ||
a | ||
`); | ||
}); | ||
|
||
}); | ||
|
||
describe('Appending templates to existing nodes', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case targets the critical bug, thanks!