Skip to content

Commit

Permalink
Added more unit tests for namespace as variable (#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
markwpearce authored Jan 1, 2025
1 parent 5c1b414 commit 09cd0ef
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/bscPlugin/validation/ScopeValidator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,42 @@ describe('ScopeValidator', () => {
]);
});

it('validates when trying to print a namespace', () => {
program.setFile('source/main.bs', `
namespace Alpha
const Name = "Alpha"
end namespace
sub main()
print alpha
end sub
`);
program.validate();
expectDiagnostics(program, [
DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')
]);
});

it('validates when trying to pass a namespace as an arg', () => {
program.setFile('source/main.bs', `
namespace Alpha
const Name = "Alpha"
end namespace
sub main()
someFunc(alpha)
end sub
sub someFunc(arg)
print sub
end sub
`);
program.validate();
expectDiagnosticsIncludes(program, [
DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')
]);
});

it('detects assigning to a member of a namespace inside the namespace', () => {
program.setFile('source/main.bs', `
namespace Alpha
Expand Down

0 comments on commit 09cd0ef

Please sign in to comment.