Skip to content

Commit

Permalink
Added test to verify validating correct function
Browse files Browse the repository at this point in the history
  • Loading branch information
markwpearce committed Oct 8, 2024
1 parent 9c3238f commit 8692f60
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/bscPlugin/validation/ScopeValidator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,30 @@ describe('ScopeValidator', () => {
//should have an error
expectZeroDiagnostics(program);
});

it('validates against scope-defined func in inner namespace, when outer namespace has same named func', () => {
program.setFile('source/main.bs', `
namespace alpha
sub foo()
end sub
namespace beta
sub bar()
foo()
end sub
end namespace
end namespace
function foo(x as integer) as integer
return x
end function
`);

program.validate();
expectDiagnostics(program, [
DiagnosticMessages.mismatchArgumentCount(1, 0).message
]);
});
});

describe('argumentTypeMismatch', () => {
Expand Down Expand Up @@ -1877,6 +1901,28 @@ describe('ScopeValidator', () => {
program.validate();
expectZeroDiagnostics(program);
});

it('allows referencing scope-defined func in inner namespace, when outer namespace has same named func', () => {
program.setFile('source/main.bs', `
namespace alpha
sub foo()
end sub
namespace beta
sub bar()
foo(1)
end sub
end namespace
end namespace
function foo(x as integer) as integer
return x
end function
`);

program.validate();
expectZeroDiagnostics(program);
});
});

describe('itemCannotBeUsedAsVariable', () => {
Expand Down

0 comments on commit 8692f60

Please sign in to comment.