Skip to content

Commit 41bcae3

Browse files
committed
test for function passed by reference as an argument to another function
1 parent 45a03cf commit 41bcae3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/bscPlugin/treeShaker/TreeShaker.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,25 @@ describe('TreeShaker', () => {
455455
expect(code).not.to.include('sub unused()');
456456
});
457457

458+
it('preserves a function passed by reference as an argument to another function', async () => {
459+
program.setFile('source/main.bs', `
460+
sub init()
461+
setHandler(mySub1)
462+
end sub
463+
464+
sub mySub1()
465+
print "hey"
466+
end sub
467+
468+
sub unused()
469+
end sub
470+
`);
471+
472+
const code = await getTranspiled('source/main.bs');
473+
expect(code).to.include('sub mySub1()');
474+
expect(code).not.to.include('sub unused()');
475+
});
476+
458477
it('preserves functions called via @. callfunc shorthand', async () => {
459478
program.setFile('source/main.bs', `
460479
sub init()

0 commit comments

Comments
 (0)