brighterscript 0.72.1 → 0.72.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/LanguageServer.d.ts +2 -1
- package/dist/LanguageServer.js +12 -0
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +5 -1
- package/dist/Program.js +20 -0
- package/dist/Program.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +2 -1
- package/dist/bscPlugin/BscPlugin.js +4 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/inlayHints/InlayHintProcessor.d.ts +23 -0
- package/dist/bscPlugin/inlayHints/InlayHintProcessor.js +183 -0
- package/dist/bscPlugin/inlayHints/InlayHintProcessor.js.map +1 -0
- package/dist/interfaces.d.ts +34 -1
- package/dist/lsp/LspProject.d.ts +8 -1
- package/dist/lsp/Project.d.ts +5 -1
- package/dist/lsp/Project.js +6 -0
- package/dist/lsp/Project.js.map +1 -1
- package/dist/lsp/ProjectManager.d.ts +5 -1
- package/dist/lsp/ProjectManager.js +12 -0
- package/dist/lsp/ProjectManager.js.map +1 -1
- package/dist/lsp/worker/WorkerThreadProject.d.ts +5 -1
- package/dist/lsp/worker/WorkerThreadProject.js +3 -0
- package/dist/lsp/worker/WorkerThreadProject.js.map +1 -1
- package/package.json +18 -14
- package/dist/astUtils/AstEditor.spec.d.ts +0 -1
- package/dist/astUtils/AstEditor.spec.js +0 -254
- package/dist/astUtils/AstEditor.spec.js.map +0 -1
- package/dist/astUtils/creators.spec.d.ts +0 -1
- package/dist/astUtils/creators.spec.js +0 -21
- package/dist/astUtils/creators.spec.js.map +0 -1
- package/dist/astUtils/reflection.spec.d.ts +0 -1
- package/dist/astUtils/reflection.spec.js +0 -308
- package/dist/astUtils/reflection.spec.js.map +0 -1
- package/dist/astUtils/stackedVisitor.spec.d.ts +0 -1
- package/dist/astUtils/stackedVisitor.spec.js +0 -79
- package/dist/astUtils/stackedVisitor.spec.js.map +0 -1
- package/dist/astUtils/visitors.spec.d.ts +0 -1
- package/dist/astUtils/visitors.spec.js +0 -1197
- package/dist/astUtils/visitors.spec.js.map +0 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +0 -1237
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +0 -1
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js +0 -171
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +0 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +0 -201
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +0 -1
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +0 -51
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +0 -1
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.spec.js +0 -298
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +0 -399
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +0 -290
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +0 -245
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -46
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +0 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +0 -702
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +0 -1
- package/dist/common/Sequencer.spec.d.ts +0 -1
- package/dist/common/Sequencer.spec.js +0 -75
- package/dist/common/Sequencer.spec.js.map +0 -1
- package/dist/files/BrsFile.Class.spec.d.ts +0 -1
- package/dist/files/BrsFile.Class.spec.js +0 -1805
- package/dist/files/BrsFile.Class.spec.js.map +0 -1
- package/dist/files/BrsFile.spec.d.ts +0 -1
- package/dist/files/BrsFile.spec.js +0 -4611
- package/dist/files/BrsFile.spec.js.map +0 -1
- package/dist/files/XmlFile.spec.d.ts +0 -1
- package/dist/files/XmlFile.spec.js +0 -1219
- package/dist/files/XmlFile.spec.js.map +0 -1
- package/dist/files/tests/imports.spec.d.ts +0 -1
- package/dist/files/tests/imports.spec.js +0 -241
- package/dist/files/tests/imports.spec.js.map +0 -1
- package/dist/files/tests/optionalChaning.spec.d.ts +0 -1
- package/dist/files/tests/optionalChaning.spec.js +0 -152
- package/dist/files/tests/optionalChaning.spec.js.map +0 -1
- package/dist/lexer/Character.spec.d.ts +0 -1
- package/dist/lexer/Character.spec.js +0 -27
- package/dist/lexer/Character.spec.js.map +0 -1
- package/dist/lexer/Lexer.spec.d.ts +0 -1
- package/dist/lexer/Lexer.spec.js +0 -1300
- package/dist/lexer/Lexer.spec.js.map +0 -1
- package/dist/lsp/ActionQueue.spec.d.ts +0 -1
- package/dist/lsp/ActionQueue.spec.js +0 -80
- package/dist/lsp/ActionQueue.spec.js.map +0 -1
- package/dist/lsp/DocumentManager.spec.d.ts +0 -1
- package/dist/lsp/DocumentManager.spec.js +0 -103
- package/dist/lsp/DocumentManager.spec.js.map +0 -1
- package/dist/lsp/PathFilterer.spec.d.ts +0 -1
- package/dist/lsp/PathFilterer.spec.js +0 -182
- package/dist/lsp/PathFilterer.spec.js.map +0 -1
- package/dist/lsp/Project.spec.d.ts +0 -1
- package/dist/lsp/Project.spec.js +0 -400
- package/dist/lsp/Project.spec.js.map +0 -1
- package/dist/lsp/ProjectManager.spec.d.ts +0 -1
- package/dist/lsp/ProjectManager.spec.js +0 -1183
- package/dist/lsp/ProjectManager.spec.js.map +0 -1
- package/dist/lsp/worker/MessageHandler.spec.d.ts +0 -1
- package/dist/lsp/worker/MessageHandler.spec.js +0 -64
- package/dist/lsp/worker/MessageHandler.spec.js.map +0 -1
- package/dist/lsp/worker/WorkerPool.spec.d.ts +0 -1
- package/dist/lsp/worker/WorkerPool.spec.js +0 -59
- package/dist/lsp/worker/WorkerPool.spec.js.map +0 -1
- package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +0 -2
- package/dist/lsp/worker/WorkerThreadProject.spec.js +0 -72
- package/dist/lsp/worker/WorkerThreadProject.spec.js.map +0 -1
- package/dist/parser/AstNode.spec.d.ts +0 -1
- package/dist/parser/AstNode.spec.js +0 -1452
- package/dist/parser/AstNode.spec.js.map +0 -1
- package/dist/parser/Expression.spec.d.ts +0 -1
- package/dist/parser/Expression.spec.js +0 -40
- package/dist/parser/Expression.spec.js.map +0 -1
- package/dist/parser/Parser.Class.spec.d.ts +0 -1
- package/dist/parser/Parser.Class.spec.js +0 -495
- package/dist/parser/Parser.Class.spec.js.map +0 -1
- package/dist/parser/Parser.spec.d.ts +0 -4
- package/dist/parser/Parser.spec.js +0 -1985
- package/dist/parser/Parser.spec.js.map +0 -1
- package/dist/parser/SGParser.spec.d.ts +0 -1
- package/dist/parser/SGParser.spec.js +0 -131
- package/dist/parser/SGParser.spec.js.map +0 -1
- package/dist/parser/Statement.spec.d.ts +0 -1
- package/dist/parser/Statement.spec.js +0 -118
- package/dist/parser/Statement.spec.js.map +0 -1
- package/dist/parser/tests/Parser.spec.d.ts +0 -19
- package/dist/parser/tests/Parser.spec.js +0 -38
- package/dist/parser/tests/Parser.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/For.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/For.spec.js +0 -208
- package/dist/parser/tests/controlFlow/For.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +0 -143
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/If.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/If.spec.js +0 -570
- package/dist/parser/tests/controlFlow/If.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/While.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/While.spec.js +0 -156
- package/dist/parser/tests/controlFlow/While.spec.js.map +0 -1
- package/dist/parser/tests/expression/Additive.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Additive.spec.js +0 -99
- package/dist/parser/tests/expression/Additive.spec.js.map +0 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.d.ts +0 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +0 -291
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +0 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.d.ts +0 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +0 -401
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +0 -1
- package/dist/parser/tests/expression/Boolean.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Boolean.spec.js +0 -83
- package/dist/parser/tests/expression/Boolean.spec.js.map +0 -1
- package/dist/parser/tests/expression/Call.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Call.spec.js +0 -242
- package/dist/parser/tests/expression/Call.spec.js.map +0 -1
- package/dist/parser/tests/expression/Exponential.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Exponential.spec.js +0 -37
- package/dist/parser/tests/expression/Exponential.spec.js.map +0 -1
- package/dist/parser/tests/expression/Function.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Function.spec.js +0 -403
- package/dist/parser/tests/expression/Function.spec.js.map +0 -1
- package/dist/parser/tests/expression/Indexing.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Indexing.spec.js +0 -289
- package/dist/parser/tests/expression/Indexing.spec.js.map +0 -1
- package/dist/parser/tests/expression/Multiplicative.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +0 -67
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +0 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +0 -346
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.d.ts +0 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +0 -105
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +0 -1
- package/dist/parser/tests/expression/Primary.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Primary.spec.js +0 -149
- package/dist/parser/tests/expression/Primary.spec.js.map +0 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +0 -171
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/Relational.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Relational.spec.js +0 -83
- package/dist/parser/tests/expression/Relational.spec.js.map +0 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +0 -201
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +0 -389
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +0 -876
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.js +0 -52
- package/dist/parser/tests/expression/UnaryExpression.spec.js.map +0 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.d.ts +0 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.js +0 -79
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +0 -1
- package/dist/parser/tests/statement/ConstStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +0 -708
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Continue.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Continue.spec.js +0 -119
- package/dist/parser/tests/statement/Continue.spec.js.map +0 -1
- package/dist/parser/tests/statement/Declaration.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Declaration.spec.js +0 -108
- package/dist/parser/tests/statement/Declaration.spec.js.map +0 -1
- package/dist/parser/tests/statement/Dim.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Dim.spec.js +0 -73
- package/dist/parser/tests/statement/Dim.spec.js.map +0 -1
- package/dist/parser/tests/statement/Enum.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Enum.spec.js +0 -1307
- package/dist/parser/tests/statement/Enum.spec.js.map +0 -1
- package/dist/parser/tests/statement/For.spec.d.ts +0 -1
- package/dist/parser/tests/statement/For.spec.js +0 -45
- package/dist/parser/tests/statement/For.spec.js.map +0 -1
- package/dist/parser/tests/statement/ForEach.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ForEach.spec.js +0 -36
- package/dist/parser/tests/statement/ForEach.spec.js.map +0 -1
- package/dist/parser/tests/statement/Function.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Function.spec.js +0 -342
- package/dist/parser/tests/statement/Function.spec.js.map +0 -1
- package/dist/parser/tests/statement/Goto.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Goto.spec.js +0 -51
- package/dist/parser/tests/statement/Goto.spec.js.map +0 -1
- package/dist/parser/tests/statement/Increment.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Increment.spec.js +0 -117
- package/dist/parser/tests/statement/Increment.spec.js.map +0 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +0 -102
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.js +0 -74
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Misc.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Misc.spec.js +0 -335
- package/dist/parser/tests/statement/Misc.spec.js.map +0 -1
- package/dist/parser/tests/statement/PrintStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +0 -195
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +0 -94
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Set.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Set.spec.js +0 -218
- package/dist/parser/tests/statement/Set.spec.js.map +0 -1
- package/dist/parser/tests/statement/Stop.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Stop.spec.js +0 -38
- package/dist/parser/tests/statement/Stop.spec.js.map +0 -1
- package/dist/parser/tests/statement/Throw.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Throw.spec.js +0 -35
- package/dist/parser/tests/statement/Throw.spec.js.map +0 -1
- package/dist/parser/tests/statement/TryCatch.spec.d.ts +0 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +0 -142
- package/dist/parser/tests/statement/TryCatch.spec.js.map +0 -1
- package/dist/preprocessor/Manifest.spec.d.ts +0 -1
- package/dist/preprocessor/Manifest.spec.js +0 -80
- package/dist/preprocessor/Manifest.spec.js.map +0 -1
- package/dist/preprocessor/Preprocessor.spec.d.ts +0 -1
- package/dist/preprocessor/Preprocessor.spec.js +0 -152
- package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
- package/dist/preprocessor/PreprocessorParser.spec.d.ts +0 -1
- package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
- package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
- package/dist/types/ArrayType.spec.d.ts +0 -1
- package/dist/types/ArrayType.spec.js +0 -30
- package/dist/types/ArrayType.spec.js.map +0 -1
- package/dist/types/BooleanType.spec.d.ts +0 -1
- package/dist/types/BooleanType.spec.js +0 -12
- package/dist/types/BooleanType.spec.js.map +0 -1
- package/dist/types/DoubleType.spec.d.ts +0 -1
- package/dist/types/DoubleType.spec.js +0 -12
- package/dist/types/DoubleType.spec.js.map +0 -1
- package/dist/types/DynamicType.spec.d.ts +0 -1
- package/dist/types/DynamicType.spec.js +0 -12
- package/dist/types/DynamicType.spec.js.map +0 -1
- package/dist/types/FloatType.spec.d.ts +0 -1
- package/dist/types/FloatType.spec.js +0 -12
- package/dist/types/FloatType.spec.js.map +0 -1
- package/dist/types/FunctionType.spec.d.ts +0 -1
- package/dist/types/FunctionType.spec.js +0 -23
- package/dist/types/FunctionType.spec.js.map +0 -1
- package/dist/types/IntegerType.spec.d.ts +0 -1
- package/dist/types/IntegerType.spec.js +0 -12
- package/dist/types/IntegerType.spec.js.map +0 -1
- package/dist/types/InterfaceType.spec.d.ts +0 -1
- package/dist/types/InterfaceType.spec.js +0 -175
- package/dist/types/InterfaceType.spec.js.map +0 -1
- package/dist/types/InvalidType.spec.d.ts +0 -1
- package/dist/types/InvalidType.spec.js +0 -12
- package/dist/types/InvalidType.spec.js.map +0 -1
- package/dist/types/LongIntegerType.spec.d.ts +0 -1
- package/dist/types/LongIntegerType.spec.js +0 -12
- package/dist/types/LongIntegerType.spec.js.map +0 -1
- package/dist/types/ObjectType.spec.d.ts +0 -1
- package/dist/types/ObjectType.spec.js +0 -12
- package/dist/types/ObjectType.spec.js.map +0 -1
- package/dist/types/StringType.spec.d.ts +0 -1
- package/dist/types/StringType.spec.js +0 -12
- package/dist/types/StringType.spec.js.map +0 -1
- package/dist/types/VoidType.spec.d.ts +0 -1
- package/dist/types/VoidType.spec.js +0 -12
- package/dist/types/VoidType.spec.js.map +0 -1
|
@@ -1,702 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const chai_config_spec_1 = require("../../chai-config.spec");
|
|
4
|
-
const DiagnosticMessages_1 = require("../../DiagnosticMessages");
|
|
5
|
-
const testHelpers_spec_1 = require("../../testHelpers.spec");
|
|
6
|
-
const Program_1 = require("../../Program");
|
|
7
|
-
const reflection_1 = require("../../astUtils/reflection");
|
|
8
|
-
const util_1 = require("../../util");
|
|
9
|
-
describe('BrsFileValidator', () => {
|
|
10
|
-
let program;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
program = new Program_1.Program({});
|
|
13
|
-
});
|
|
14
|
-
it('links dotted get expression parents', () => {
|
|
15
|
-
const file = program.setFile('source/main.bs', `
|
|
16
|
-
sub main()
|
|
17
|
-
print {}.beta.charlie
|
|
18
|
-
end sub
|
|
19
|
-
`);
|
|
20
|
-
program.validate();
|
|
21
|
-
const func = file.parser.ast.statements[0];
|
|
22
|
-
const print = func.func.body.statements[0];
|
|
23
|
-
(0, chai_config_spec_1.expect)(print.parent).to.equal(func.func.body);
|
|
24
|
-
const charlie = print.expressions[0];
|
|
25
|
-
(0, chai_config_spec_1.expect)(charlie.parent).to.equal(print);
|
|
26
|
-
const beta = charlie.obj;
|
|
27
|
-
(0, chai_config_spec_1.expect)(beta.parent).to.equal(charlie);
|
|
28
|
-
const aaLiteral = beta.obj;
|
|
29
|
-
(0, chai_config_spec_1.expect)(aaLiteral.parent).to.equal(beta);
|
|
30
|
-
});
|
|
31
|
-
it('links NamespacedVariableNameExpression dotted get parents', () => {
|
|
32
|
-
const { ast } = program.setFile('source/main.bs', `
|
|
33
|
-
namespace alpha.bravo
|
|
34
|
-
class Delta extends alpha.bravo.Charlie
|
|
35
|
-
end class
|
|
36
|
-
class Charlie
|
|
37
|
-
end class
|
|
38
|
-
end namespace
|
|
39
|
-
`);
|
|
40
|
-
const namespace = ast.findChild(reflection_1.isNamespaceStatement);
|
|
41
|
-
const deltaClass = namespace.findChild(reflection_1.isClassStatement);
|
|
42
|
-
(0, chai_config_spec_1.expect)(deltaClass.parent).to.equal(namespace.body);
|
|
43
|
-
const charlie = deltaClass.parentClassName.expression;
|
|
44
|
-
(0, chai_config_spec_1.expect)(charlie.parent).to.equal(deltaClass.parentClassName);
|
|
45
|
-
const bravo = charlie.obj;
|
|
46
|
-
(0, chai_config_spec_1.expect)(bravo.parent).to.equal(charlie);
|
|
47
|
-
const alpha = bravo.obj;
|
|
48
|
-
(0, chai_config_spec_1.expect)(alpha.parent).to.equal(bravo);
|
|
49
|
-
});
|
|
50
|
-
describe('namespace validation', () => {
|
|
51
|
-
it('succeeds if namespaces are defined inside other namespaces', () => {
|
|
52
|
-
program.setFile('source/main.bs', `
|
|
53
|
-
namespace alpha
|
|
54
|
-
' random comment
|
|
55
|
-
namespace bravo
|
|
56
|
-
' random comment
|
|
57
|
-
sub main()
|
|
58
|
-
end sub
|
|
59
|
-
end namespace
|
|
60
|
-
end namespace
|
|
61
|
-
`);
|
|
62
|
-
program.validate();
|
|
63
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
64
|
-
});
|
|
65
|
-
it('fails if namespaces are defined inside a function', () => {
|
|
66
|
-
program.setFile('source/main.bs', `
|
|
67
|
-
function f()
|
|
68
|
-
namespace alpha
|
|
69
|
-
end namespace
|
|
70
|
-
end function
|
|
71
|
-
`);
|
|
72
|
-
program.validate();
|
|
73
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
74
|
-
DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('namespace')
|
|
75
|
-
]);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
it('allows classes in correct locations', () => {
|
|
79
|
-
program.setFile('source/main.bs', `
|
|
80
|
-
class Alpha
|
|
81
|
-
end class
|
|
82
|
-
namespace Beta
|
|
83
|
-
class Charlie
|
|
84
|
-
end class
|
|
85
|
-
namespace Delta
|
|
86
|
-
class Echo
|
|
87
|
-
end class
|
|
88
|
-
end namespace
|
|
89
|
-
end namespace
|
|
90
|
-
`);
|
|
91
|
-
program.validate();
|
|
92
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
93
|
-
});
|
|
94
|
-
it('flags classes in wrong locations', () => {
|
|
95
|
-
program.setFile('source/main.bs', `
|
|
96
|
-
function test()
|
|
97
|
-
class Alpha
|
|
98
|
-
end class
|
|
99
|
-
if true then
|
|
100
|
-
class Beta
|
|
101
|
-
end class
|
|
102
|
-
end if
|
|
103
|
-
end function
|
|
104
|
-
`);
|
|
105
|
-
program.validate();
|
|
106
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('class')), { range: util_1.default.createRange(2, 16, 2, 27) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('class')), { range: util_1.default.createRange(5, 20, 5, 30) })]);
|
|
107
|
-
});
|
|
108
|
-
it('allows enums in correct locations', () => {
|
|
109
|
-
program.setFile('source/main.bs', `
|
|
110
|
-
enum Alpha
|
|
111
|
-
value1
|
|
112
|
-
end enum
|
|
113
|
-
namespace Beta
|
|
114
|
-
enum Charlie
|
|
115
|
-
value1
|
|
116
|
-
end enum
|
|
117
|
-
namespace Delta
|
|
118
|
-
enum Echo
|
|
119
|
-
value1
|
|
120
|
-
end enum
|
|
121
|
-
end namespace
|
|
122
|
-
end namespace
|
|
123
|
-
`);
|
|
124
|
-
program.validate();
|
|
125
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
126
|
-
});
|
|
127
|
-
it('flags enums in wrong locations', () => {
|
|
128
|
-
program.setFile('source/main.bs', `
|
|
129
|
-
function test()
|
|
130
|
-
enum Alpha
|
|
131
|
-
value1
|
|
132
|
-
end enum
|
|
133
|
-
if true then
|
|
134
|
-
enum Beta
|
|
135
|
-
value1
|
|
136
|
-
end enum
|
|
137
|
-
end if
|
|
138
|
-
end function
|
|
139
|
-
`);
|
|
140
|
-
program.validate();
|
|
141
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('enum')), { range: util_1.default.createRange(2, 16, 2, 26) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('enum')), { range: util_1.default.createRange(6, 20, 6, 29) })]);
|
|
142
|
-
});
|
|
143
|
-
it('allows functions in correct locations', () => {
|
|
144
|
-
program.setFile('source/main.bs', `
|
|
145
|
-
function Alpha()
|
|
146
|
-
end function
|
|
147
|
-
namespace Beta
|
|
148
|
-
function Charlie()
|
|
149
|
-
end function
|
|
150
|
-
namespace Delta
|
|
151
|
-
function Echo()
|
|
152
|
-
end function
|
|
153
|
-
end namespace
|
|
154
|
-
end namespace
|
|
155
|
-
`);
|
|
156
|
-
program.validate();
|
|
157
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
158
|
-
});
|
|
159
|
-
it('flags functions in wrong locations', () => {
|
|
160
|
-
program.setFile('source/main.bs', `
|
|
161
|
-
function test()
|
|
162
|
-
function Alpha()
|
|
163
|
-
end function
|
|
164
|
-
if true then
|
|
165
|
-
function Beta()
|
|
166
|
-
end function
|
|
167
|
-
end if
|
|
168
|
-
end function
|
|
169
|
-
`);
|
|
170
|
-
program.validate();
|
|
171
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('function')), { range: util_1.default.createRange(2, 16, 2, 30) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('function')), { range: util_1.default.createRange(5, 20, 5, 33) })]);
|
|
172
|
-
});
|
|
173
|
-
it('allows namespaces in correct locations', () => {
|
|
174
|
-
program.setFile('source/main.bs', `
|
|
175
|
-
namespace Alpha
|
|
176
|
-
end namespace
|
|
177
|
-
namespace Beta
|
|
178
|
-
namespace Charlie
|
|
179
|
-
end namespace
|
|
180
|
-
namespace Delta
|
|
181
|
-
namespace Echo
|
|
182
|
-
end namespace
|
|
183
|
-
end namespace
|
|
184
|
-
end namespace
|
|
185
|
-
`);
|
|
186
|
-
program.validate();
|
|
187
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
188
|
-
});
|
|
189
|
-
it('flags classes in wrong locations', () => {
|
|
190
|
-
program.setFile('source/main.bs', `
|
|
191
|
-
function test()
|
|
192
|
-
namespace Alpha
|
|
193
|
-
end namespace
|
|
194
|
-
if true then
|
|
195
|
-
namespace Beta
|
|
196
|
-
end namespace
|
|
197
|
-
end if
|
|
198
|
-
end function
|
|
199
|
-
`);
|
|
200
|
-
program.validate();
|
|
201
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('namespace')), { range: util_1.default.createRange(2, 16, 2, 31) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('namespace')), { range: util_1.default.createRange(5, 20, 5, 34) })]);
|
|
202
|
-
});
|
|
203
|
-
it('allows interfaces in correct locations', () => {
|
|
204
|
-
program.setFile('source/main.bs', `
|
|
205
|
-
interface Alpha
|
|
206
|
-
prop as string
|
|
207
|
-
end interface
|
|
208
|
-
namespace Beta
|
|
209
|
-
interface Charlie
|
|
210
|
-
prop as string
|
|
211
|
-
end interface
|
|
212
|
-
namespace Delta
|
|
213
|
-
interface Echo
|
|
214
|
-
prop as string
|
|
215
|
-
end interface
|
|
216
|
-
end namespace
|
|
217
|
-
end namespace
|
|
218
|
-
`);
|
|
219
|
-
program.validate();
|
|
220
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
221
|
-
});
|
|
222
|
-
it('flags interfaces in wrong locations', () => {
|
|
223
|
-
program.setFile('source/main.bs', `
|
|
224
|
-
function test()
|
|
225
|
-
interface Alpha
|
|
226
|
-
prop as string
|
|
227
|
-
end interface
|
|
228
|
-
if true then
|
|
229
|
-
interface Beta
|
|
230
|
-
prop as string
|
|
231
|
-
end interface
|
|
232
|
-
end if
|
|
233
|
-
end function
|
|
234
|
-
`);
|
|
235
|
-
program.validate();
|
|
236
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('interface')), { range: util_1.default.createRange(2, 16, 2, 31) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('interface')), { range: util_1.default.createRange(6, 20, 6, 34) })]);
|
|
237
|
-
});
|
|
238
|
-
it('allows consts in correct locations', () => {
|
|
239
|
-
program.setFile('source/main.bs', `
|
|
240
|
-
const Alpha = 1
|
|
241
|
-
namespace Beta
|
|
242
|
-
const Charlie = 2
|
|
243
|
-
namespace Delta
|
|
244
|
-
const Echo = 3
|
|
245
|
-
end namespace
|
|
246
|
-
end namespace
|
|
247
|
-
`);
|
|
248
|
-
program.validate();
|
|
249
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
250
|
-
});
|
|
251
|
-
it('flags consts in wrong locations', () => {
|
|
252
|
-
program.setFile('source/main.bs', `
|
|
253
|
-
function test()
|
|
254
|
-
const Alpha = 1
|
|
255
|
-
if true then
|
|
256
|
-
const Beta = 2
|
|
257
|
-
end if
|
|
258
|
-
end function
|
|
259
|
-
`);
|
|
260
|
-
program.validate();
|
|
261
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('const')), { range: util_1.default.createRange(2, 16, 2, 27) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.keywordMustBeDeclaredAtNamespaceLevel('const')), { range: util_1.default.createRange(4, 20, 4, 30) })]);
|
|
262
|
-
});
|
|
263
|
-
describe('function return values', () => {
|
|
264
|
-
it('catches sub with return value', () => {
|
|
265
|
-
program.setFile('source/main.brs', `
|
|
266
|
-
sub test()
|
|
267
|
-
return true
|
|
268
|
-
end sub
|
|
269
|
-
`);
|
|
270
|
-
program.validate();
|
|
271
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.voidFunctionMayNotReturnValue('sub')), { range: util_1.default.createRange(2, 20, 2, 31) })]);
|
|
272
|
-
});
|
|
273
|
-
it('catches sub as void with return value', () => {
|
|
274
|
-
program.setFile('source/main.brs', `
|
|
275
|
-
sub test() as void
|
|
276
|
-
return true
|
|
277
|
-
end sub
|
|
278
|
-
`);
|
|
279
|
-
program.validate();
|
|
280
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.voidFunctionMayNotReturnValue('sub')), { range: util_1.default.createRange(2, 20, 2, 31) })]);
|
|
281
|
-
});
|
|
282
|
-
it('catches function as void with return value', () => {
|
|
283
|
-
program.setFile('source/main.brs', `
|
|
284
|
-
function test() as void
|
|
285
|
-
return true
|
|
286
|
-
end function
|
|
287
|
-
`);
|
|
288
|
-
program.validate();
|
|
289
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.voidFunctionMayNotReturnValue('function')), { range: util_1.default.createRange(2, 20, 2, 31) })]);
|
|
290
|
-
});
|
|
291
|
-
it('catches sub as <type> without return value', () => {
|
|
292
|
-
program.setFile('source/main.brs', `
|
|
293
|
-
sub test() as integer
|
|
294
|
-
return
|
|
295
|
-
end sub
|
|
296
|
-
`);
|
|
297
|
-
program.validate();
|
|
298
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nonVoidFunctionMustReturnValue('sub')), { range: util_1.default.createRange(2, 20, 2, 26) })]);
|
|
299
|
-
});
|
|
300
|
-
it('catches function without return value', () => {
|
|
301
|
-
program.setFile('source/main.brs', `
|
|
302
|
-
function test()
|
|
303
|
-
return
|
|
304
|
-
end function
|
|
305
|
-
`);
|
|
306
|
-
program.validate();
|
|
307
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nonVoidFunctionMustReturnValue('function')), { range: util_1.default.createRange(2, 20, 2, 26) })]);
|
|
308
|
-
});
|
|
309
|
-
it('catches function as <type> without return value', () => {
|
|
310
|
-
program.setFile('source/main.brs', `
|
|
311
|
-
function test() as integer
|
|
312
|
-
return
|
|
313
|
-
end function
|
|
314
|
-
`);
|
|
315
|
-
program.validate();
|
|
316
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nonVoidFunctionMustReturnValue('function')), { range: util_1.default.createRange(2, 20, 2, 26) })]);
|
|
317
|
-
});
|
|
318
|
-
it('catches anon sub with return value', () => {
|
|
319
|
-
program.setFile('source/main.brs', `
|
|
320
|
-
sub main()
|
|
321
|
-
test = sub()
|
|
322
|
-
return true
|
|
323
|
-
end sub
|
|
324
|
-
end sub
|
|
325
|
-
`);
|
|
326
|
-
program.validate();
|
|
327
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.voidFunctionMayNotReturnValue('sub')), { range: util_1.default.createRange(3, 24, 3, 35) })]);
|
|
328
|
-
});
|
|
329
|
-
it('catches sub as void with return value', () => {
|
|
330
|
-
program.setFile('source/main.brs', `
|
|
331
|
-
sub main()
|
|
332
|
-
test = sub() as void
|
|
333
|
-
return true
|
|
334
|
-
end sub
|
|
335
|
-
end sub
|
|
336
|
-
`);
|
|
337
|
-
program.validate();
|
|
338
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.voidFunctionMayNotReturnValue('sub')), { range: util_1.default.createRange(3, 24, 3, 35) })]);
|
|
339
|
-
});
|
|
340
|
-
it('catches function as void with return value', () => {
|
|
341
|
-
program.setFile('source/main.brs', `
|
|
342
|
-
sub main()
|
|
343
|
-
test = function() as void
|
|
344
|
-
return true
|
|
345
|
-
end function
|
|
346
|
-
end sub
|
|
347
|
-
`);
|
|
348
|
-
program.validate();
|
|
349
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.voidFunctionMayNotReturnValue('function')), { range: util_1.default.createRange(3, 24, 3, 35) })]);
|
|
350
|
-
});
|
|
351
|
-
it('catches sub as <type> without return value', () => {
|
|
352
|
-
program.setFile('source/main.brs', `
|
|
353
|
-
sub main()
|
|
354
|
-
test = sub() as integer
|
|
355
|
-
return
|
|
356
|
-
end sub
|
|
357
|
-
end sub
|
|
358
|
-
`);
|
|
359
|
-
program.validate();
|
|
360
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nonVoidFunctionMustReturnValue('sub')), { range: util_1.default.createRange(3, 24, 3, 30) })]);
|
|
361
|
-
});
|
|
362
|
-
it('catches function without return value', () => {
|
|
363
|
-
program.setFile('source/main.brs', `
|
|
364
|
-
sub main()
|
|
365
|
-
test = function()
|
|
366
|
-
return
|
|
367
|
-
end function
|
|
368
|
-
end sub
|
|
369
|
-
`);
|
|
370
|
-
program.validate();
|
|
371
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nonVoidFunctionMustReturnValue('function')), { range: util_1.default.createRange(3, 24, 3, 30) })]);
|
|
372
|
-
});
|
|
373
|
-
it('catches function as <type> without return value', () => {
|
|
374
|
-
program.setFile('source/main.brs', `
|
|
375
|
-
sub main()
|
|
376
|
-
test = function() as integer
|
|
377
|
-
return
|
|
378
|
-
end function
|
|
379
|
-
end sub
|
|
380
|
-
`);
|
|
381
|
-
program.validate();
|
|
382
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.nonVoidFunctionMustReturnValue('function')), { range: util_1.default.createRange(3, 24, 3, 30) })]);
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
describe('minFirmwareVersion', () => {
|
|
386
|
-
describe('optional chaining', () => {
|
|
387
|
-
it('allows optional chaining in .brs files when minFirmwareVersion is not set', () => {
|
|
388
|
-
program.setFile('source/main.brs', `
|
|
389
|
-
sub main()
|
|
390
|
-
obj = {}
|
|
391
|
-
value = obj?.name
|
|
392
|
-
end sub
|
|
393
|
-
`);
|
|
394
|
-
program.validate();
|
|
395
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
396
|
-
});
|
|
397
|
-
it('allows optional chaining in .bs files when minFirmwareVersion is not set', () => {
|
|
398
|
-
program.setFile('source/main.bs', `
|
|
399
|
-
sub main()
|
|
400
|
-
obj = {}
|
|
401
|
-
value = obj?.name
|
|
402
|
-
end sub
|
|
403
|
-
`);
|
|
404
|
-
program.validate();
|
|
405
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
406
|
-
});
|
|
407
|
-
it('allows optional chaining in .brs files when minFirmwareVersion is 11.0.0', () => {
|
|
408
|
-
program = new Program_1.Program({ minFirmwareVersion: '11.0.0' });
|
|
409
|
-
program.setFile('source/main.brs', `
|
|
410
|
-
sub main()
|
|
411
|
-
obj = {}
|
|
412
|
-
value = obj?.name
|
|
413
|
-
end sub
|
|
414
|
-
`);
|
|
415
|
-
program.validate();
|
|
416
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
417
|
-
});
|
|
418
|
-
it('allows optional chaining in .bs files when minFirmwareVersion is 11.0.0', () => {
|
|
419
|
-
program = new Program_1.Program({ minFirmwareVersion: '11.0.0' });
|
|
420
|
-
program.setFile('source/main.bs', `
|
|
421
|
-
sub main()
|
|
422
|
-
obj = {}
|
|
423
|
-
value = obj?.name
|
|
424
|
-
end sub
|
|
425
|
-
`);
|
|
426
|
-
program.validate();
|
|
427
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
428
|
-
});
|
|
429
|
-
it('allows optional chaining in .brs files when minFirmwareVersion is above 11.0.0', () => {
|
|
430
|
-
program = new Program_1.Program({ minFirmwareVersion: '12.0.0' });
|
|
431
|
-
program.setFile('source/main.brs', `
|
|
432
|
-
sub main()
|
|
433
|
-
obj = {}
|
|
434
|
-
value = obj?.name
|
|
435
|
-
end sub
|
|
436
|
-
`);
|
|
437
|
-
program.validate();
|
|
438
|
-
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
439
|
-
});
|
|
440
|
-
it('flags optional chaining (dotted get) in .brs files when minFirmwareVersion is below 11.0.0', () => {
|
|
441
|
-
program = new Program_1.Program({ minFirmwareVersion: '10.0.0' });
|
|
442
|
-
program.setFile('source/main.brs', `
|
|
443
|
-
sub main()
|
|
444
|
-
obj = {}
|
|
445
|
-
value = obj?.name
|
|
446
|
-
end sub
|
|
447
|
-
`);
|
|
448
|
-
program.validate();
|
|
449
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.featureRequiresMinFirmwareVersion('optional chaining', '11.0.0', '10.0.0'))]);
|
|
450
|
-
});
|
|
451
|
-
it('flags optional chaining (dotted get) in .bs files when minFirmwareVersion is below 11.0.0', () => {
|
|
452
|
-
program = new Program_1.Program({ minFirmwareVersion: '10.0.0' });
|
|
453
|
-
program.setFile('source/main.bs', `
|
|
454
|
-
sub main()
|
|
455
|
-
obj = {}
|
|
456
|
-
value = obj?.name
|
|
457
|
-
end sub
|
|
458
|
-
`);
|
|
459
|
-
program.validate();
|
|
460
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.featureRequiresMinFirmwareVersion('optional chaining', '11.0.0', '10.0.0'))]);
|
|
461
|
-
});
|
|
462
|
-
it('flags optional chaining (indexed get) in .brs files when minFirmwareVersion is below 11.0.0', () => {
|
|
463
|
-
program = new Program_1.Program({ minFirmwareVersion: '10.0.0' });
|
|
464
|
-
program.setFile('source/main.brs', `
|
|
465
|
-
sub main()
|
|
466
|
-
arr = []
|
|
467
|
-
value = arr?[0]
|
|
468
|
-
end sub
|
|
469
|
-
`);
|
|
470
|
-
program.validate();
|
|
471
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.featureRequiresMinFirmwareVersion('optional chaining', '11.0.0', '10.0.0'))]);
|
|
472
|
-
});
|
|
473
|
-
it('flags optional chaining (call expression) in .brs files when minFirmwareVersion is below 11.0.0', () => {
|
|
474
|
-
program = new Program_1.Program({ minFirmwareVersion: '10.0.0' });
|
|
475
|
-
program.setFile('source/main.brs', `
|
|
476
|
-
sub main()
|
|
477
|
-
obj = {}
|
|
478
|
-
obj.doSomething?()
|
|
479
|
-
end sub
|
|
480
|
-
`);
|
|
481
|
-
program.validate();
|
|
482
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.featureRequiresMinFirmwareVersion('optional chaining', '11.0.0', '10.0.0'))]);
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
describe('unreferencable builtins', () => {
|
|
487
|
-
const reservedBuiltinCode = DiagnosticMessages_1.DiagnosticMessages.reservedBuiltinUsedAsValue('').code;
|
|
488
|
-
function reservedBuiltinDiagnostics() {
|
|
489
|
-
return program.getDiagnostics().filter(diagnostic => diagnostic.code === reservedBuiltinCode);
|
|
490
|
-
}
|
|
491
|
-
function expectFlagged(names) {
|
|
492
|
-
(0, chai_config_spec_1.expect)(reservedBuiltinDiagnostics().map(diagnostic => diagnostic.message)).to.eql(names.map(name => DiagnosticMessages_1.DiagnosticMessages.reservedBuiltinUsedAsValue(name).message));
|
|
493
|
-
}
|
|
494
|
-
function expectNotFlagged() {
|
|
495
|
-
(0, chai_config_spec_1.expect)(reservedBuiltinDiagnostics()).to.eql([]);
|
|
496
|
-
}
|
|
497
|
-
it('flags `x = ObjFun` (RHS value read)', () => {
|
|
498
|
-
program.setFile('source/main.brs', `
|
|
499
|
-
sub a()
|
|
500
|
-
x = ObjFun
|
|
501
|
-
print x
|
|
502
|
-
end sub
|
|
503
|
-
`);
|
|
504
|
-
program.validate();
|
|
505
|
-
expectFlagged(['ObjFun']);
|
|
506
|
-
});
|
|
507
|
-
it('flags `print type(ObjFun)` (passed as argument)', () => {
|
|
508
|
-
program.setFile('source/main.brs', `
|
|
509
|
-
sub a()
|
|
510
|
-
print type(ObjFun)
|
|
511
|
-
end sub
|
|
512
|
-
`);
|
|
513
|
-
program.validate();
|
|
514
|
-
expectFlagged(['ObjFun']);
|
|
515
|
-
});
|
|
516
|
-
it('flags `f(ObjFun, 2)` (passed by value)', () => {
|
|
517
|
-
program.setFile('source/main.brs', `
|
|
518
|
-
sub a()
|
|
519
|
-
f(ObjFun, 2)
|
|
520
|
-
end sub
|
|
521
|
-
sub f(arg1, arg2)
|
|
522
|
-
end sub
|
|
523
|
-
`);
|
|
524
|
-
program.validate();
|
|
525
|
-
expectFlagged(['ObjFun']);
|
|
526
|
-
});
|
|
527
|
-
it('flags `x = type` (RHS value read)', () => {
|
|
528
|
-
program.setFile('source/main.brs', `
|
|
529
|
-
sub a()
|
|
530
|
-
x = type
|
|
531
|
-
print x
|
|
532
|
-
end sub
|
|
533
|
-
`);
|
|
534
|
-
program.validate();
|
|
535
|
-
expectFlagged(['type']);
|
|
536
|
-
});
|
|
537
|
-
it('does not flag `ObjFun(m)` (canonical call)', () => {
|
|
538
|
-
program.setFile('source/main.brs', `
|
|
539
|
-
sub a()
|
|
540
|
-
ObjFun(m, "")
|
|
541
|
-
end sub
|
|
542
|
-
`);
|
|
543
|
-
program.validate();
|
|
544
|
-
expectNotFlagged();
|
|
545
|
-
});
|
|
546
|
-
it('does not flag `type(123)` (canonical call)', () => {
|
|
547
|
-
program.setFile('source/main.brs', `
|
|
548
|
-
sub a()
|
|
549
|
-
print type(123)
|
|
550
|
-
end sub
|
|
551
|
-
`);
|
|
552
|
-
program.validate();
|
|
553
|
-
expectNotFlagged();
|
|
554
|
-
});
|
|
555
|
-
it('does not flag `m.ObjFun = 1` (property assignment)', () => {
|
|
556
|
-
program.setFile('source/main.brs', `
|
|
557
|
-
sub a()
|
|
558
|
-
m.ObjFun = 1
|
|
559
|
-
end sub
|
|
560
|
-
`);
|
|
561
|
-
program.validate();
|
|
562
|
-
expectNotFlagged();
|
|
563
|
-
});
|
|
564
|
-
it('does not flag `m.type = 1` (property assignment)', () => {
|
|
565
|
-
program.setFile('source/main.brs', `
|
|
566
|
-
sub a()
|
|
567
|
-
m.type = 1
|
|
568
|
-
end sub
|
|
569
|
-
`);
|
|
570
|
-
program.validate();
|
|
571
|
-
expectNotFlagged();
|
|
572
|
-
});
|
|
573
|
-
it('does not flag `{ ObjFun: 1 }` (AA literal key)', () => {
|
|
574
|
-
program.setFile('source/main.brs', `
|
|
575
|
-
sub a()
|
|
576
|
-
aa = { ObjFun: 1 }
|
|
577
|
-
end sub
|
|
578
|
-
`);
|
|
579
|
-
program.validate();
|
|
580
|
-
expectNotFlagged();
|
|
581
|
-
});
|
|
582
|
-
it('does not flag `{ type: 1 }` (AA literal key)', () => {
|
|
583
|
-
program.setFile('source/main.brs', `
|
|
584
|
-
sub a()
|
|
585
|
-
aa = { type: 1 }
|
|
586
|
-
end sub
|
|
587
|
-
`);
|
|
588
|
-
program.validate();
|
|
589
|
-
expectNotFlagged();
|
|
590
|
-
});
|
|
591
|
-
it('does not flag a BrighterScript `type Name = ...` statement', () => {
|
|
592
|
-
program.setFile('source/main.bs', `
|
|
593
|
-
type MyAlias = string or integer
|
|
594
|
-
`);
|
|
595
|
-
program.validate();
|
|
596
|
-
expectNotFlagged();
|
|
597
|
-
});
|
|
598
|
-
it('case-insensitive match for OBJFUN, ObjFun, objfun', () => {
|
|
599
|
-
program.setFile('source/main.brs', `
|
|
600
|
-
sub a()
|
|
601
|
-
x = OBJFUN
|
|
602
|
-
y = objfun
|
|
603
|
-
end sub
|
|
604
|
-
`);
|
|
605
|
-
program.validate();
|
|
606
|
-
expectFlagged(['OBJFUN', 'objfun']);
|
|
607
|
-
});
|
|
608
|
-
//per-builtin coverage for each device-verified entry in UnreferencableBuiltins.
|
|
609
|
-
//each pair: (1) bare value read flags, (2) canonical call form does not flag.
|
|
610
|
-
it('flags `x = Box` (RHS value read)', () => {
|
|
611
|
-
program.setFile('source/main.brs', `sub a()\nx = Box\nend sub`);
|
|
612
|
-
program.validate();
|
|
613
|
-
expectFlagged(['Box']);
|
|
614
|
-
});
|
|
615
|
-
it('does not flag `Box(1)` (canonical call)', () => {
|
|
616
|
-
program.setFile('source/main.brs', `sub a()\nx = Box(1)\nend sub`);
|
|
617
|
-
program.validate();
|
|
618
|
-
expectNotFlagged();
|
|
619
|
-
});
|
|
620
|
-
it('flags `x = CreateObject` (RHS value read)', () => {
|
|
621
|
-
program.setFile('source/main.brs', `sub a()\nx = CreateObject\nend sub`);
|
|
622
|
-
program.validate();
|
|
623
|
-
expectFlagged(['CreateObject']);
|
|
624
|
-
});
|
|
625
|
-
it('does not flag `CreateObject("roSGNode", "Node")` (canonical call)', () => {
|
|
626
|
-
program.setFile('source/main.brs', `sub a()\nx = CreateObject("roSGNode", "Node")\nend sub`);
|
|
627
|
-
program.validate();
|
|
628
|
-
expectNotFlagged();
|
|
629
|
-
});
|
|
630
|
-
it('flags `x = GetGlobalAA` (RHS value read)', () => {
|
|
631
|
-
program.setFile('source/main.brs', `sub a()\nx = GetGlobalAA\nend sub`);
|
|
632
|
-
program.validate();
|
|
633
|
-
expectFlagged(['GetGlobalAA']);
|
|
634
|
-
});
|
|
635
|
-
it('does not flag `GetGlobalAA()` (canonical call)', () => {
|
|
636
|
-
program.setFile('source/main.brs', `sub a()\nx = GetGlobalAA()\nend sub`);
|
|
637
|
-
program.validate();
|
|
638
|
-
expectNotFlagged();
|
|
639
|
-
});
|
|
640
|
-
it('flags `x = GetLastRunCompileError` (RHS value read)', () => {
|
|
641
|
-
program.setFile('source/main.brs', `sub a()\nx = GetLastRunCompileError\nend sub`);
|
|
642
|
-
program.validate();
|
|
643
|
-
expectFlagged(['GetLastRunCompileError']);
|
|
644
|
-
});
|
|
645
|
-
it('does not flag `GetLastRunCompileError()` (canonical call)', () => {
|
|
646
|
-
program.setFile('source/main.brs', `sub a()\nx = GetLastRunCompileError()\nend sub`);
|
|
647
|
-
program.validate();
|
|
648
|
-
expectNotFlagged();
|
|
649
|
-
});
|
|
650
|
-
it('flags `x = GetLastRunRunTimeError` (RHS value read)', () => {
|
|
651
|
-
program.setFile('source/main.brs', `sub a()\nx = GetLastRunRunTimeError\nend sub`);
|
|
652
|
-
program.validate();
|
|
653
|
-
expectFlagged(['GetLastRunRunTimeError']);
|
|
654
|
-
});
|
|
655
|
-
it('does not flag `GetLastRunRunTimeError()` (canonical call)', () => {
|
|
656
|
-
program.setFile('source/main.brs', `sub a()\nx = GetLastRunRunTimeError()\nend sub`);
|
|
657
|
-
program.validate();
|
|
658
|
-
expectNotFlagged();
|
|
659
|
-
});
|
|
660
|
-
it('flags `x = Pos` (RHS value read)', () => {
|
|
661
|
-
program.setFile('source/main.brs', `sub a()\nx = Pos\nend sub`);
|
|
662
|
-
program.validate();
|
|
663
|
-
expectFlagged(['Pos']);
|
|
664
|
-
});
|
|
665
|
-
it('does not flag `Pos(0)` (canonical call)', () => {
|
|
666
|
-
program.setFile('source/main.brs', `sub a()\nx = Pos(0)\nend sub`);
|
|
667
|
-
program.validate();
|
|
668
|
-
expectNotFlagged();
|
|
669
|
-
});
|
|
670
|
-
it('flags `x = Run` (RHS value read)', () => {
|
|
671
|
-
program.setFile('source/main.brs', `sub a()\nx = Run\nend sub`);
|
|
672
|
-
program.validate();
|
|
673
|
-
expectFlagged(['Run']);
|
|
674
|
-
});
|
|
675
|
-
it('does not flag `Run("pkg:/source/foo.brs")` (canonical call)', () => {
|
|
676
|
-
program.setFile('source/main.brs', `sub a()\nx = Run("pkg:/source/foo.brs")\nend sub`);
|
|
677
|
-
program.validate();
|
|
678
|
-
expectNotFlagged();
|
|
679
|
-
});
|
|
680
|
-
it('flags `x = Tab` (RHS value read)', () => {
|
|
681
|
-
program.setFile('source/main.brs', `sub a()\nx = Tab\nend sub`);
|
|
682
|
-
program.validate();
|
|
683
|
-
expectFlagged(['Tab']);
|
|
684
|
-
});
|
|
685
|
-
it('does not flag `Tab(5)` (canonical call)', () => {
|
|
686
|
-
program.setFile('source/main.brs', `sub a()\nx = Tab(5)\nend sub`);
|
|
687
|
-
program.validate();
|
|
688
|
-
expectNotFlagged();
|
|
689
|
-
});
|
|
690
|
-
it('flags `x = eval` (RHS value read)', () => {
|
|
691
|
-
program.setFile('source/main.brs', `sub a()\nx = eval\nend sub`);
|
|
692
|
-
program.validate();
|
|
693
|
-
expectFlagged(['eval']);
|
|
694
|
-
});
|
|
695
|
-
it('does not flag `eval("print 1")` (canonical call)', () => {
|
|
696
|
-
program.setFile('source/main.brs', `sub a()\neval("print 1")\nend sub`);
|
|
697
|
-
program.validate();
|
|
698
|
-
expectNotFlagged();
|
|
699
|
-
});
|
|
700
|
-
});
|
|
701
|
-
});
|
|
702
|
-
//# sourceMappingURL=BrsFileValidator.spec.js.map
|