Fix to not filter out empty modules from the Feature Tree (#6224)
This commit is contained in:
@ -27,12 +27,31 @@ function userCall(name: string): Operation {
|
||||
sourceRange: defaultSourceRange(),
|
||||
}
|
||||
}
|
||||
|
||||
function userReturn(): Operation {
|
||||
return {
|
||||
type: 'GroupEnd',
|
||||
}
|
||||
}
|
||||
|
||||
function moduleBegin(name: string): Operation {
|
||||
return {
|
||||
type: 'GroupBegin',
|
||||
group: {
|
||||
type: 'ModuleInstance',
|
||||
name,
|
||||
moduleId: 0,
|
||||
},
|
||||
sourceRange: defaultSourceRange(),
|
||||
}
|
||||
}
|
||||
|
||||
function moduleEnd(): Operation {
|
||||
return {
|
||||
type: 'GroupEnd',
|
||||
}
|
||||
}
|
||||
|
||||
describe('operations filtering', () => {
|
||||
it('drops stdlib operations inside a user-defined function call', async () => {
|
||||
const operations = [
|
||||
@ -65,6 +84,25 @@ describe('operations filtering', () => {
|
||||
const actual = filterOperations(operations)
|
||||
expect(actual).toEqual([stdlib('std1'), stdlib('std2'), stdlib('std3')])
|
||||
})
|
||||
it('does not drop module instances that contain no operations', async () => {
|
||||
const operations = [
|
||||
stdlib('std1'),
|
||||
moduleBegin('foo'),
|
||||
moduleEnd(),
|
||||
stdlib('std2'),
|
||||
moduleBegin('bar'),
|
||||
moduleEnd(),
|
||||
stdlib('std3'),
|
||||
]
|
||||
const actual = filterOperations(operations)
|
||||
expect(actual).toEqual([
|
||||
stdlib('std1'),
|
||||
moduleBegin('foo'),
|
||||
stdlib('std2'),
|
||||
moduleBegin('bar'),
|
||||
stdlib('std3'),
|
||||
])
|
||||
})
|
||||
it('preserves user-defined function calls at the end of the list', async () => {
|
||||
const operations = [stdlib('std1'), userCall('foo')]
|
||||
const actual = filterOperations(operations)
|
||||
|
Reference in New Issue
Block a user