brighterscript 1.0.0-alpha.26 → 1.0.0-alpha.28
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/CHANGELOG.md +82 -5
- package/README.md +1 -1
- package/dist/AstValidationSegmenter.d.ts +1 -1
- package/dist/AstValidationSegmenter.js +4 -5
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +7 -4
- package/dist/DiagnosticFilterer.js +67 -37
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +1 -3
- package/dist/DiagnosticMessages.js +5 -8
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/PluginInterface.js +1 -1
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +1 -1
- package/dist/Program.js +34 -31
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +7 -34
- package/dist/Scope.js +45 -305
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +1 -8
- package/dist/SymbolTable.js +1 -10
- package/dist/SymbolTable.js.map +1 -1
- package/dist/SymbolTypeFlag.d.ts +8 -0
- package/dist/SymbolTypeFlag.js +13 -0
- package/dist/SymbolTypeFlag.js.map +1 -0
- package/dist/XmlScope.d.ts +0 -8
- package/dist/XmlScope.js +6 -84
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.d.ts +1 -2
- package/dist/astUtils/CachedLookups.js +4 -19
- package/dist/astUtils/CachedLookups.js.map +1 -1
- package/dist/astUtils/creators.d.ts +1 -0
- package/dist/astUtils/creators.js +48 -8
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +0 -10
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +3 -2
- package/dist/astUtils/reflection.js +11 -7
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +11 -16
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +1 -2
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +1 -5
- package/dist/astUtils/visitors.spec.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/SignatureHelpUtil.js +4 -3
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +46 -29
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +39 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +30 -10
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +125 -7
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
- package/dist/bscPlugin/references/ReferencesProvider.js +56 -0
- package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +2 -3
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +25 -31
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +34 -1
- package/dist/bscPlugin/validation/ScopeValidator.js +435 -27
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +178 -10
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +1 -1
- package/dist/files/BrsFile.Class.spec.js +15 -7
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +14 -5
- package/dist/files/BrsFile.js +83 -150
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +429 -162
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +2 -3
- package/dist/files/XmlFile.js +1 -3
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +117 -85
- package/dist/interfaces.js +9 -9
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +9 -3
- package/dist/lexer/Lexer.js +36 -15
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +76 -38
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.js +1 -1
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +1 -0
- package/dist/lexer/TokenKind.js +4 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/AstNode.d.ts +1 -2
- package/dist/parser/AstNode.js +0 -1
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +1 -1
- package/dist/parser/Expression.d.ts +153 -135
- package/dist/parser/Expression.js +204 -114
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +15 -16
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +8 -4
- package/dist/parser/Parser.js +108 -149
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +48 -72
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.js +49 -35
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +36 -24
- package/dist/parser/SGTypes.js +31 -60
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +214 -207
- package/dist/parser/Statement.js +248 -169
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +0 -13
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +17 -8
- package/dist/parser/TranspileState.js +64 -6
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +1 -1
- package/dist/parser/tests/Parser.spec.js +1 -2
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +1 -3
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +44 -0
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +6 -6
- package/dist/parser/tests/expression/TernaryExpression.spec.js +47 -0
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TypeExpression.spec.js +8 -9
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +2 -2
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +8 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +25 -5
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +9 -2
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Chunk.js +1 -2
- package/dist/preprocessor/Chunk.js.map +1 -1
- package/dist/preprocessor/PreprocessorParser.js +2 -1
- package/dist/preprocessor/PreprocessorParser.js.map +1 -1
- package/dist/roku-types/data.json +70 -52
- package/dist/roku-types/index.d.ts +43 -21
- package/dist/types/ArrayType.js +1 -2
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +7 -8
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +3 -0
- package/dist/types/AssociativeArrayType.js +10 -2
- package/dist/types/AssociativeArrayType.js.map +1 -1
- package/dist/types/BscType.d.ts +1 -1
- package/dist/types/BscType.js +3 -3
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.js +7 -8
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +31 -32
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -1
- package/dist/types/ClassType.spec.js +10 -11
- package/dist/types/ClassType.spec.js.map +1 -1
- package/dist/types/ComponentType.d.ts +2 -1
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/EnumType.js +2 -3
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/InheritableType.js +3 -4
- package/dist/types/InheritableType.js.map +1 -1
- package/dist/types/InterfaceType.js +2 -3
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +3 -4
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/ObjectType.js +1 -2
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +1 -1
- package/dist/types/ReferenceType.spec.js +21 -22
- package/dist/types/ReferenceType.spec.js.map +1 -1
- package/dist/types/UnionType.js +3 -3
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/UnionType.spec.js +37 -38
- package/dist/types/UnionType.spec.js.map +1 -1
- package/dist/types/helper.spec.js +4 -5
- package/dist/types/helper.spec.js.map +1 -1
- package/dist/util.d.ts +21 -11
- package/dist/util.js +116 -37
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +0 -9
- package/dist/validators/ClassValidator.js +3 -46
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +6 -3
|
@@ -4,7 +4,6 @@ const chai_config_spec_1 = require("../chai-config.spec");
|
|
|
4
4
|
const sinonImport = require("sinon");
|
|
5
5
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
6
6
|
const Program_1 = require("../Program");
|
|
7
|
-
const BooleanType_1 = require("../types/BooleanType");
|
|
8
7
|
const DynamicType_1 = require("../types/DynamicType");
|
|
9
8
|
const TypedFunctionType_1 = require("../types/TypedFunctionType");
|
|
10
9
|
const IntegerType_1 = require("../types/IntegerType");
|
|
@@ -23,8 +22,8 @@ const fsExtra = require("fs-extra");
|
|
|
23
22
|
const vscode_uri_1 = require("vscode-uri");
|
|
24
23
|
const undent_1 = require("undent");
|
|
25
24
|
const testHelpers_spec_2 = require("../testHelpers.spec");
|
|
26
|
-
const SymbolTable_1 = require("../SymbolTable");
|
|
27
25
|
const types_1 = require("../types");
|
|
26
|
+
const fileUrl = require("file-url");
|
|
28
27
|
let sinon = sinonImport.createSandbox();
|
|
29
28
|
describe('BrsFile', () => {
|
|
30
29
|
let program;
|
|
@@ -187,7 +186,7 @@ describe('BrsFile', () => {
|
|
|
187
186
|
(0, chai_config_spec_1.expect)(file.ownScriptImports).to.be.empty;
|
|
188
187
|
file.parser.ast.statements.push(new Statement_1.ImportStatement({
|
|
189
188
|
import: (0, creators_1.createToken)(TokenKind_1.TokenKind.Import),
|
|
190
|
-
|
|
189
|
+
path: (0, creators_1.createToken)(TokenKind_1.TokenKind.StringLiteral, 'pkg:/source/lib.brs')
|
|
191
190
|
}));
|
|
192
191
|
(0, chai_config_spec_1.expect)(file.ownScriptImports).to.be.empty;
|
|
193
192
|
file['_cachedLookups'].invalidate();
|
|
@@ -507,6 +506,27 @@ describe('BrsFile', () => {
|
|
|
507
506
|
(0, testHelpers_spec_1.expectZeroDiagnostics)(file);
|
|
508
507
|
});
|
|
509
508
|
describe('conditional compile', () => {
|
|
509
|
+
it('supports whitespace-separated directives', async () => {
|
|
510
|
+
const file = program.setFile('source/main.bs', `
|
|
511
|
+
sub main()
|
|
512
|
+
#\t const thing=true
|
|
513
|
+
#\t if thing
|
|
514
|
+
print "if"
|
|
515
|
+
#\t elseif false
|
|
516
|
+
print "elseif"
|
|
517
|
+
#\t error crash
|
|
518
|
+
#\t else
|
|
519
|
+
print "else"
|
|
520
|
+
#\t endif
|
|
521
|
+
end sub
|
|
522
|
+
`);
|
|
523
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
524
|
+
await testTranspile(file.fileContents, `
|
|
525
|
+
sub main()
|
|
526
|
+
print "if"
|
|
527
|
+
end sub
|
|
528
|
+
`);
|
|
529
|
+
});
|
|
510
530
|
it('supports case-insensitive bs_const variables', () => {
|
|
511
531
|
fsExtra.outputFileSync(`${testHelpers_spec_2.rootDir}/manifest`, (0, undent_1.default) `
|
|
512
532
|
bs_const=SomeKey=true
|
|
@@ -1105,26 +1125,6 @@ describe('BrsFile', () => {
|
|
|
1105
1125
|
(0, chai_config_spec_1.expect)(file.callables[1].name).to.equal('DoA');
|
|
1106
1126
|
(0, chai_config_spec_1.expect)(file.callables[1].nameRange.start.line).to.equal(5);
|
|
1107
1127
|
});
|
|
1108
|
-
it('finds function call line and column numbers', () => {
|
|
1109
|
-
let file = new BrsFile_1.BrsFile({
|
|
1110
|
-
srcPath: 'absolute_path/file.brs',
|
|
1111
|
-
destPath: 'relative_path/file.brs',
|
|
1112
|
-
program: program
|
|
1113
|
-
});
|
|
1114
|
-
file.parse(`
|
|
1115
|
-
function DoA()
|
|
1116
|
-
DoB("a")
|
|
1117
|
-
end function
|
|
1118
|
-
function DoB(a as string)
|
|
1119
|
-
DoC()
|
|
1120
|
-
end function
|
|
1121
|
-
`);
|
|
1122
|
-
(0, chai_config_spec_1.expect)(file.functionCalls.length).to.equal(2);
|
|
1123
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[0].range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 28));
|
|
1124
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[0].nameRange).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 23));
|
|
1125
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[1].range).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 25));
|
|
1126
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 23));
|
|
1127
|
-
});
|
|
1128
1128
|
it('finds function calls that are unfinished', () => {
|
|
1129
1129
|
let file = new BrsFile_1.BrsFile({
|
|
1130
1130
|
srcPath: 'absolute_path/file.brs',
|
|
@@ -1146,11 +1146,6 @@ describe('BrsFile', () => {
|
|
|
1146
1146
|
DiagnosticMessages_1.DiagnosticMessages.expectedRightParenAfterFunctionCallArguments(),
|
|
1147
1147
|
DiagnosticMessages_1.DiagnosticMessages.expectedNewlineOrColon()
|
|
1148
1148
|
]);
|
|
1149
|
-
(0, chai_config_spec_1.expect)(file.functionCalls.length).to.equal(2);
|
|
1150
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[0].range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 27));
|
|
1151
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[0].nameRange).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 23));
|
|
1152
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[1].range).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 24));
|
|
1153
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[1].nameRange).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 23));
|
|
1154
1149
|
});
|
|
1155
1150
|
it('sanitizes brs errors', () => {
|
|
1156
1151
|
let file = new BrsFile_1.BrsFile({
|
|
@@ -1327,79 +1322,6 @@ describe('BrsFile', () => {
|
|
|
1327
1322
|
(0, chai_config_spec_1.expect)(callable.params[2].type).instanceof(StringType_1.StringType);
|
|
1328
1323
|
});
|
|
1329
1324
|
});
|
|
1330
|
-
describe('findCallableInvocations', () => {
|
|
1331
|
-
it('finds arguments with literal values', () => {
|
|
1332
|
-
let file = new BrsFile_1.BrsFile({
|
|
1333
|
-
srcPath: 'absolute_path/file.brs',
|
|
1334
|
-
destPath: 'relative_path/file.brs',
|
|
1335
|
-
program: program
|
|
1336
|
-
});
|
|
1337
|
-
file.parse(`
|
|
1338
|
-
function Sum()
|
|
1339
|
-
DoSomething("name", 12, true)
|
|
1340
|
-
end function
|
|
1341
|
-
`);
|
|
1342
|
-
(0, chai_config_spec_1.expect)(file.functionCalls.length).to.equal(1);
|
|
1343
|
-
const argsMap = file.functionCalls[0].args.map(arg => {
|
|
1344
|
-
// disregard arg.expression, etc.
|
|
1345
|
-
return { type: arg.type, range: arg.range, text: arg.text };
|
|
1346
|
-
});
|
|
1347
|
-
(0, chai_config_spec_1.expect)(argsMap).to.eql([{
|
|
1348
|
-
type: StringType_1.StringType.instance,
|
|
1349
|
-
range: util_1.default.createRange(2, 32, 2, 38),
|
|
1350
|
-
text: '"name"'
|
|
1351
|
-
}, {
|
|
1352
|
-
type: IntegerType_1.IntegerType.instance,
|
|
1353
|
-
range: util_1.default.createRange(2, 40, 2, 42),
|
|
1354
|
-
text: '12'
|
|
1355
|
-
}, {
|
|
1356
|
-
type: BooleanType_1.BooleanType.instance,
|
|
1357
|
-
range: util_1.default.createRange(2, 44, 2, 48),
|
|
1358
|
-
text: 'true'
|
|
1359
|
-
}]);
|
|
1360
|
-
});
|
|
1361
|
-
it('finds function calls nested inside statements', () => {
|
|
1362
|
-
program.setFile(`source/main.brs`, `
|
|
1363
|
-
sub main()
|
|
1364
|
-
if true then
|
|
1365
|
-
DoesNotExist(1, 2)
|
|
1366
|
-
end if
|
|
1367
|
-
end sub
|
|
1368
|
-
`);
|
|
1369
|
-
program.validate();
|
|
1370
|
-
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
1371
|
-
DiagnosticMessages_1.DiagnosticMessages.cannotFindName('DoesNotExist')
|
|
1372
|
-
]);
|
|
1373
|
-
});
|
|
1374
|
-
it('finds arguments with variable values', () => {
|
|
1375
|
-
let file = new BrsFile_1.BrsFile({
|
|
1376
|
-
srcPath: 'absolute_path/file.brs',
|
|
1377
|
-
destPath: 'relative_path/file.brs',
|
|
1378
|
-
program: program
|
|
1379
|
-
});
|
|
1380
|
-
file.parse(`
|
|
1381
|
-
function Sum()
|
|
1382
|
-
count = 1
|
|
1383
|
-
name = "John"
|
|
1384
|
-
isAlive = true
|
|
1385
|
-
DoSomething(count, name, isAlive)
|
|
1386
|
-
end function
|
|
1387
|
-
`);
|
|
1388
|
-
(0, chai_config_spec_1.expect)(file.functionCalls.length).to.equal(1);
|
|
1389
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[0].args[0]).deep.include({
|
|
1390
|
-
type: new DynamicType_1.DynamicType(),
|
|
1391
|
-
text: 'count'
|
|
1392
|
-
});
|
|
1393
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[0].args[1]).deep.include({
|
|
1394
|
-
type: new DynamicType_1.DynamicType(),
|
|
1395
|
-
text: 'name'
|
|
1396
|
-
});
|
|
1397
|
-
(0, chai_config_spec_1.expect)(file.functionCalls[0].args[2]).deep.include({
|
|
1398
|
-
type: new DynamicType_1.DynamicType(),
|
|
1399
|
-
text: 'isAlive'
|
|
1400
|
-
});
|
|
1401
|
-
});
|
|
1402
|
-
});
|
|
1403
1325
|
describe('findCallables', () => {
|
|
1404
1326
|
//this test is to help with code coverage
|
|
1405
1327
|
it('skips top-level statements', () => {
|
|
@@ -1590,6 +1512,230 @@ describe('BrsFile', () => {
|
|
|
1590
1512
|
//this test will throw an exception if something went wrong
|
|
1591
1513
|
});
|
|
1592
1514
|
describe('transpile', () => {
|
|
1515
|
+
describe('null tokens', () => {
|
|
1516
|
+
it('succeeds when token locations are omitted', () => {
|
|
1517
|
+
doTest(`
|
|
1518
|
+
library "something" 'comment before func
|
|
1519
|
+
sub main(arg0, arg1 as string, arg2 = invalid)
|
|
1520
|
+
'comment
|
|
1521
|
+
aa = {
|
|
1522
|
+
'comment
|
|
1523
|
+
one: 1
|
|
1524
|
+
"two": 2
|
|
1525
|
+
}
|
|
1526
|
+
arr = [
|
|
1527
|
+
'comment
|
|
1528
|
+
1
|
|
1529
|
+
'comment
|
|
1530
|
+
2
|
|
1531
|
+
]
|
|
1532
|
+
val = + m.val
|
|
1533
|
+
print "hello"
|
|
1534
|
+
'comment after print
|
|
1535
|
+
num = 1
|
|
1536
|
+
num++
|
|
1537
|
+
num += 2
|
|
1538
|
+
num = +num
|
|
1539
|
+
test(num)
|
|
1540
|
+
for i = 0 to 10 step 1
|
|
1541
|
+
exit for
|
|
1542
|
+
end for
|
|
1543
|
+
while true
|
|
1544
|
+
exit while
|
|
1545
|
+
end while
|
|
1546
|
+
if true then
|
|
1547
|
+
print 1
|
|
1548
|
+
else if true
|
|
1549
|
+
print 1
|
|
1550
|
+
else
|
|
1551
|
+
print 1
|
|
1552
|
+
end if
|
|
1553
|
+
dim thing[1, 2]
|
|
1554
|
+
label1:
|
|
1555
|
+
goto label1
|
|
1556
|
+
end
|
|
1557
|
+
stop
|
|
1558
|
+
stuff = [
|
|
1559
|
+
1
|
|
1560
|
+
2
|
|
1561
|
+
3
|
|
1562
|
+
]
|
|
1563
|
+
for each item in stuff
|
|
1564
|
+
print item
|
|
1565
|
+
end for
|
|
1566
|
+
m.thing = 1
|
|
1567
|
+
m.thing += 1
|
|
1568
|
+
m[1] = 1
|
|
1569
|
+
m[1] += 1
|
|
1570
|
+
m[1, 2] = 2
|
|
1571
|
+
try
|
|
1572
|
+
print m.b.c
|
|
1573
|
+
catch e
|
|
1574
|
+
print e
|
|
1575
|
+
end try
|
|
1576
|
+
throw "crash"
|
|
1577
|
+
for i = 0 to 10
|
|
1578
|
+
continue
|
|
1579
|
+
end for
|
|
1580
|
+
print m@name
|
|
1581
|
+
print (1 + 2)
|
|
1582
|
+
end sub
|
|
1583
|
+
|
|
1584
|
+
sub test(p1)
|
|
1585
|
+
return p1
|
|
1586
|
+
end sub
|
|
1587
|
+
`);
|
|
1588
|
+
});
|
|
1589
|
+
it('works for bs content', () => {
|
|
1590
|
+
program.setFile('source/lib.bs', ``);
|
|
1591
|
+
doTest(`
|
|
1592
|
+
import "pkg:/source/lib.bs"
|
|
1593
|
+
@annotation()
|
|
1594
|
+
sub test()
|
|
1595
|
+
two = 2
|
|
1596
|
+
print \`1\${two}\${3}\n\`
|
|
1597
|
+
print (1 as integer)
|
|
1598
|
+
print SOURCE_LINE_NUM
|
|
1599
|
+
print FUNCTION_NAME
|
|
1600
|
+
print SOURCE_FUNCTION_NAME
|
|
1601
|
+
print PKG_LOCATION
|
|
1602
|
+
print PKG_PATH
|
|
1603
|
+
print LINE_NUM
|
|
1604
|
+
print new Person()
|
|
1605
|
+
m@.someCallfunc()
|
|
1606
|
+
m@.someCallfunc(1, 2)
|
|
1607
|
+
print tag\`stuff\${LINE_NUM}\${LINE_NUM}\`
|
|
1608
|
+
print 1 = 1 ? 1 : 2
|
|
1609
|
+
print 1 = 1 ? m.one : m.two
|
|
1610
|
+
print 1 ?? 2
|
|
1611
|
+
print m.one ?? m.two
|
|
1612
|
+
print /123/gi
|
|
1613
|
+
end sub
|
|
1614
|
+
function tag(param1, param2)
|
|
1615
|
+
end function
|
|
1616
|
+
const a = 1
|
|
1617
|
+
namespace alpha
|
|
1618
|
+
function beta()
|
|
1619
|
+
throw "An error has occurred"
|
|
1620
|
+
end function
|
|
1621
|
+
function charlie()
|
|
1622
|
+
end function
|
|
1623
|
+
end namespace
|
|
1624
|
+
sub test2()
|
|
1625
|
+
' alpha.charlie()
|
|
1626
|
+
end sub
|
|
1627
|
+
|
|
1628
|
+
enum Direction
|
|
1629
|
+
up = "up"
|
|
1630
|
+
end enum
|
|
1631
|
+
|
|
1632
|
+
class Person
|
|
1633
|
+
name as string
|
|
1634
|
+
sub new()
|
|
1635
|
+
print m.name
|
|
1636
|
+
end sub
|
|
1637
|
+
|
|
1638
|
+
sub test()
|
|
1639
|
+
end sub
|
|
1640
|
+
end class
|
|
1641
|
+
|
|
1642
|
+
interface Beta
|
|
1643
|
+
name as string
|
|
1644
|
+
end interface
|
|
1645
|
+
`, `
|
|
1646
|
+
'import "pkg:/source/lib.bs"
|
|
1647
|
+
|
|
1648
|
+
sub test()
|
|
1649
|
+
two = 2
|
|
1650
|
+
print ("1" + bslib_toString(two) + bslib_toString(3) + chr(10))
|
|
1651
|
+
print 1
|
|
1652
|
+
print -1
|
|
1653
|
+
print "test"
|
|
1654
|
+
print "test"
|
|
1655
|
+
print "pkg:/source/main.brs:" + str(LINE_NUM)
|
|
1656
|
+
print "pkg:/source/main.brs"
|
|
1657
|
+
print LINE_NUM
|
|
1658
|
+
print Person()
|
|
1659
|
+
m.callfunc("someCallfunc")
|
|
1660
|
+
m.callfunc("someCallfunc", 1, 2)
|
|
1661
|
+
print tag(["stuff", "", ""], [LINE_NUM, LINE_NUM])
|
|
1662
|
+
print bslib_ternary(1 = 1, 1, 2)
|
|
1663
|
+
print (function(__bsCondition, m)
|
|
1664
|
+
if __bsCondition then
|
|
1665
|
+
return m.one
|
|
1666
|
+
else
|
|
1667
|
+
return m.two
|
|
1668
|
+
end if
|
|
1669
|
+
end function)(1 = 1, m)
|
|
1670
|
+
print bslib_coalesce(1, 2)
|
|
1671
|
+
print (function(m)
|
|
1672
|
+
__bsConsequent = m.one
|
|
1673
|
+
if __bsConsequent <> invalid then
|
|
1674
|
+
return __bsConsequent
|
|
1675
|
+
else
|
|
1676
|
+
return m.two
|
|
1677
|
+
end if
|
|
1678
|
+
end function)(m)
|
|
1679
|
+
print CreateObject("roRegex", "123", "gi")
|
|
1680
|
+
end sub
|
|
1681
|
+
|
|
1682
|
+
function tag(param1, param2)
|
|
1683
|
+
end function
|
|
1684
|
+
|
|
1685
|
+
function alpha_beta()
|
|
1686
|
+
throw "An error has occurred"
|
|
1687
|
+
end function
|
|
1688
|
+
|
|
1689
|
+
function alpha_charlie()
|
|
1690
|
+
end function
|
|
1691
|
+
|
|
1692
|
+
sub test2()
|
|
1693
|
+
' alpha.charlie()
|
|
1694
|
+
end sub
|
|
1695
|
+
|
|
1696
|
+
function __Person_builder()
|
|
1697
|
+
instance = {}
|
|
1698
|
+
instance.new = sub()
|
|
1699
|
+
m.name = invalid
|
|
1700
|
+
print m.name
|
|
1701
|
+
end sub
|
|
1702
|
+
instance.test = sub()
|
|
1703
|
+
end sub
|
|
1704
|
+
return instance
|
|
1705
|
+
end function
|
|
1706
|
+
function Person()
|
|
1707
|
+
instance = __Person_builder()
|
|
1708
|
+
instance.new()
|
|
1709
|
+
return instance
|
|
1710
|
+
end function
|
|
1711
|
+
`);
|
|
1712
|
+
});
|
|
1713
|
+
it('handles source literals properly', () => {
|
|
1714
|
+
const pathUrl = fileUrl(testHelpers_spec_2.rootDir);
|
|
1715
|
+
let text = `"${pathUrl.substring(0, 4)}" + "${pathUrl.substring(4)}`;
|
|
1716
|
+
doTest(`
|
|
1717
|
+
sub test()
|
|
1718
|
+
print SOURCE_FILE_PATH
|
|
1719
|
+
print SOURCE_LOCATION
|
|
1720
|
+
end sub
|
|
1721
|
+
`, `
|
|
1722
|
+
sub test()
|
|
1723
|
+
print ${text}/source/main.bs"
|
|
1724
|
+
print ${text}/source/main.bs:-1"
|
|
1725
|
+
end sub
|
|
1726
|
+
`);
|
|
1727
|
+
});
|
|
1728
|
+
function doTest(source, expected = source) {
|
|
1729
|
+
const file = program.setFile('source/main.bs', '');
|
|
1730
|
+
//override the parser with our locationless parser
|
|
1731
|
+
file['_parser'] = Parser_1.Parser.parse(source, { mode: Parser_1.ParseMode.BrighterScript, trackLocations: false });
|
|
1732
|
+
program.getScopesForFile(file).forEach(x => x['cache'].clear());
|
|
1733
|
+
program.validate();
|
|
1734
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
1735
|
+
const result = file.transpile();
|
|
1736
|
+
(0, chai_config_spec_1.expect)((0, testHelpers_spec_1.trimMap)((0, undent_1.default)(result.code))).to.eql((0, undent_1.default)(expected));
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1593
1739
|
it('transpilies libpkg:/ paths when encountered', async () => {
|
|
1594
1740
|
program.setFile('source/lib.bs', `
|
|
1595
1741
|
import "libpkg:/source/numbers.bs"
|
|
@@ -1757,6 +1903,24 @@ describe('BrsFile', () => {
|
|
|
1757
1903
|
end sub
|
|
1758
1904
|
`);
|
|
1759
1905
|
});
|
|
1906
|
+
it('transpiles empty throw with "User-specified exception"', async () => {
|
|
1907
|
+
await testTranspile(`
|
|
1908
|
+
sub main()
|
|
1909
|
+
try
|
|
1910
|
+
throw 'bs:disable-line
|
|
1911
|
+
catch e
|
|
1912
|
+
end try
|
|
1913
|
+
end sub
|
|
1914
|
+
`, `
|
|
1915
|
+
sub main()
|
|
1916
|
+
try
|
|
1917
|
+
throw "User-specified exception"
|
|
1918
|
+
'bs:disable-line
|
|
1919
|
+
catch e
|
|
1920
|
+
end try
|
|
1921
|
+
end sub
|
|
1922
|
+
`);
|
|
1923
|
+
});
|
|
1760
1924
|
});
|
|
1761
1925
|
describe('try/catch', () => {
|
|
1762
1926
|
it('transpiles properly', async () => {
|
|
@@ -2046,6 +2210,7 @@ describe('BrsFile', () => {
|
|
|
2046
2210
|
function DoSomething()
|
|
2047
2211
|
'lots of empty white space
|
|
2048
2212
|
'that will be removed during transpile
|
|
2213
|
+
'since there are newlines below this comment one newline will be preserved
|
|
2049
2214
|
|
|
2050
2215
|
|
|
2051
2216
|
|
|
@@ -2054,6 +2219,8 @@ describe('BrsFile', () => {
|
|
|
2054
2219
|
function DoSomething()
|
|
2055
2220
|
'lots of empty white space
|
|
2056
2221
|
'that will be removed during transpile
|
|
2222
|
+
'since there are newlines below this comment one newline will be preserved
|
|
2223
|
+
|
|
2057
2224
|
end function
|
|
2058
2225
|
`);
|
|
2059
2226
|
});
|
|
@@ -2068,6 +2235,26 @@ describe('BrsFile', () => {
|
|
|
2068
2235
|
it('does not add leading or trailing newlines', async () => {
|
|
2069
2236
|
await testTranspile(`function abc()\nend function`, undefined, 'none');
|
|
2070
2237
|
});
|
|
2238
|
+
it('generates proper sourcemap comment', () => {
|
|
2239
|
+
program.options.sourceMap = true;
|
|
2240
|
+
const file = program.setFile('source/main.bs', `
|
|
2241
|
+
sub main()
|
|
2242
|
+
end sub
|
|
2243
|
+
`);
|
|
2244
|
+
(0, chai_config_spec_1.expect)(file.transpile().code).to.eql((0, undent_1.default) `
|
|
2245
|
+
sub main()
|
|
2246
|
+
end sub
|
|
2247
|
+
'//# sourceMappingURL=./main.brs.map
|
|
2248
|
+
`);
|
|
2249
|
+
});
|
|
2250
|
+
it('includes sourcemap.name property', () => {
|
|
2251
|
+
program.options.sourceMap = true;
|
|
2252
|
+
const file = program.setFile('source/main.bs', `
|
|
2253
|
+
sub main()
|
|
2254
|
+
end sub
|
|
2255
|
+
`);
|
|
2256
|
+
(0, chai_config_spec_1.expect)(file.transpile().map.toJSON().file).to.eql('main.brs');
|
|
2257
|
+
});
|
|
2071
2258
|
it('handles sourcemap edge case', async () => {
|
|
2072
2259
|
let source = 'sub main()\n' +
|
|
2073
2260
|
'\n' +
|
|
@@ -2239,6 +2426,25 @@ describe('BrsFile', () => {
|
|
|
2239
2426
|
end sub
|
|
2240
2427
|
`);
|
|
2241
2428
|
});
|
|
2429
|
+
it('keeps spaces in between comments when a statement ends in a comment ', async () => {
|
|
2430
|
+
await testTranspile(`
|
|
2431
|
+
sub foo()
|
|
2432
|
+
end sub 'comment
|
|
2433
|
+
|
|
2434
|
+
'a function that does something
|
|
2435
|
+
sub foo2()
|
|
2436
|
+
end sub
|
|
2437
|
+
`);
|
|
2438
|
+
});
|
|
2439
|
+
it('keeps comment in correct place in empty function', async () => {
|
|
2440
|
+
await testTranspile(`
|
|
2441
|
+
sub noop1()
|
|
2442
|
+
end sub
|
|
2443
|
+
|
|
2444
|
+
sub noop2() 'comment in empty function
|
|
2445
|
+
end sub
|
|
2446
|
+
`);
|
|
2447
|
+
});
|
|
2242
2448
|
it('works for a complex function with comments all over the place', async () => {
|
|
2243
2449
|
await testTranspile(`
|
|
2244
2450
|
'import some library
|
|
@@ -2430,7 +2636,7 @@ describe('BrsFile', () => {
|
|
|
2430
2636
|
program.setFile('source/main.bs', `
|
|
2431
2637
|
sub test()
|
|
2432
2638
|
someNode = createObject("roSGNode", "Rectangle")
|
|
2433
|
-
someNode@.someFunction(test
|
|
2639
|
+
someNode@.someFunction({test: "value"})
|
|
2434
2640
|
end sub
|
|
2435
2641
|
`);
|
|
2436
2642
|
program.validate();
|
|
@@ -3188,6 +3394,30 @@ describe('BrsFile', () => {
|
|
|
3188
3394
|
'TwoType', 'OneType'
|
|
3189
3395
|
]);
|
|
3190
3396
|
});
|
|
3397
|
+
it('allows built-in types for interface members', () => {
|
|
3398
|
+
program.setFile('source/main.bs', `
|
|
3399
|
+
interface MyBase
|
|
3400
|
+
regex as roRegex
|
|
3401
|
+
node as roSGNodeLabel
|
|
3402
|
+
sub outputMatches(textInput as string)
|
|
3403
|
+
function getLabelParent() as roSGNode
|
|
3404
|
+
end interface
|
|
3405
|
+
`);
|
|
3406
|
+
program.validate();
|
|
3407
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
3408
|
+
});
|
|
3409
|
+
it('allows extends on interfaces', async () => {
|
|
3410
|
+
await testTranspile(`
|
|
3411
|
+
interface MyBase
|
|
3412
|
+
url as string
|
|
3413
|
+
end interface
|
|
3414
|
+
|
|
3415
|
+
interface MyExtends extends MyBase
|
|
3416
|
+
method as string
|
|
3417
|
+
end interface
|
|
3418
|
+
`, `
|
|
3419
|
+
`);
|
|
3420
|
+
});
|
|
3191
3421
|
it('should include unknown param and return types on class methods', () => {
|
|
3192
3422
|
const mainFile = program.setFile('source/main.bs', `
|
|
3193
3423
|
class Klass
|
|
@@ -3265,7 +3495,7 @@ describe('BrsFile', () => {
|
|
|
3265
3495
|
]);
|
|
3266
3496
|
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3267
3497
|
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3268
|
-
|
|
3498
|
+
2 /* SymbolTypeFlag.typetime */, 2 /* SymbolTypeFlag.typetime */, 1 /* SymbolTypeFlag.runtime */
|
|
3269
3499
|
]);
|
|
3270
3500
|
});
|
|
3271
3501
|
it('should include enums and consts that are not in the file', () => {
|
|
@@ -3292,7 +3522,7 @@ describe('BrsFile', () => {
|
|
|
3292
3522
|
]);
|
|
3293
3523
|
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3294
3524
|
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3295
|
-
|
|
3525
|
+
2 /* SymbolTypeFlag.typetime */, 1 /* SymbolTypeFlag.runtime */, 1 /* SymbolTypeFlag.runtime */, 1 /* SymbolTypeFlag.runtime */
|
|
3296
3526
|
]);
|
|
3297
3527
|
});
|
|
3298
3528
|
it('should include types not defined in the file', () => {
|
|
@@ -3322,7 +3552,7 @@ describe('BrsFile', () => {
|
|
|
3322
3552
|
]);
|
|
3323
3553
|
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3324
3554
|
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3325
|
-
|
|
3555
|
+
2 /* SymbolTypeFlag.typetime */, 2 /* SymbolTypeFlag.typetime */, 2 /* SymbolTypeFlag.typetime */, 2 /* SymbolTypeFlag.typetime */, 2 /* SymbolTypeFlag.typetime */
|
|
3326
3556
|
]);
|
|
3327
3557
|
});
|
|
3328
3558
|
it('includes namespace details', () => {
|
|
@@ -3379,7 +3609,7 @@ describe('BrsFile', () => {
|
|
|
3379
3609
|
`);
|
|
3380
3610
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3381
3611
|
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(1);
|
|
3382
|
-
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].flags).to.eq(
|
|
3612
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].flags).to.eq(2 /* SymbolTypeFlag.typetime */);
|
|
3383
3613
|
});
|
|
3384
3614
|
});
|
|
3385
3615
|
describe('providedSymbols', () => {
|
|
@@ -3398,7 +3628,7 @@ describe('BrsFile', () => {
|
|
|
3398
3628
|
file: mainFile
|
|
3399
3629
|
};
|
|
3400
3630
|
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3401
|
-
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3631
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3402
3632
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3403
3633
|
const someFuncType = runtimeSymbols.get('somefunc').type;
|
|
3404
3634
|
(0, testHelpers_spec_1.expectTypeToBe)(someFuncType, TypedFunctionType_1.TypedFunctionType);
|
|
@@ -3416,14 +3646,14 @@ describe('BrsFile', () => {
|
|
|
3416
3646
|
file: mainFile
|
|
3417
3647
|
};
|
|
3418
3648
|
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3419
|
-
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3649
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3420
3650
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3421
3651
|
const someFuncType = runtimeSymbols.get('somefunc').type;
|
|
3422
3652
|
(0, testHelpers_spec_1.expectTypeToBe)(someFuncType, TypedFunctionType_1.TypedFunctionType);
|
|
3423
3653
|
const requiredSymbols = mainFile.requiredSymbols.map(x => x.typeChain[0].name);
|
|
3424
3654
|
(0, chai_config_spec_1.expect)(requiredSymbols).to.have.same.members(['OtherFileType', 'OtherFileType']);
|
|
3425
3655
|
const requiredSymbolTypes = mainFile.requiredSymbols.map(x => x.flags);
|
|
3426
|
-
(0, chai_config_spec_1.expect)(requiredSymbolTypes).to.have.same.members([
|
|
3656
|
+
(0, chai_config_spec_1.expect)(requiredSymbolTypes).to.have.same.members([1 /* SymbolTypeFlag.runtime */, 2 /* SymbolTypeFlag.typetime */]);
|
|
3427
3657
|
});
|
|
3428
3658
|
it('includes classes defined in the file', () => {
|
|
3429
3659
|
const mainFile = program.setFile('source/main.bs', `
|
|
@@ -3448,12 +3678,12 @@ describe('BrsFile', () => {
|
|
|
3448
3678
|
file: mainFile
|
|
3449
3679
|
};
|
|
3450
3680
|
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3451
|
-
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3681
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3452
3682
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3453
3683
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass').type, types_1.ClassType);
|
|
3454
3684
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass2').type, types_1.ClassType);
|
|
3455
3685
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass3').type, types_1.ClassType);
|
|
3456
|
-
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3686
|
+
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(2 /* SymbolTypeFlag.typetime */);
|
|
3457
3687
|
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(3);
|
|
3458
3688
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass').type, types_1.ClassType);
|
|
3459
3689
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass2').type, types_1.ClassType);
|
|
@@ -3479,11 +3709,11 @@ describe('BrsFile', () => {
|
|
|
3479
3709
|
file: mainFile
|
|
3480
3710
|
};
|
|
3481
3711
|
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3482
|
-
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3712
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3483
3713
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3484
3714
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('myenum').type, types_1.EnumType);
|
|
3485
3715
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('mynamespace.myconst').type, types_1.FloatType);
|
|
3486
|
-
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3716
|
+
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(2 /* SymbolTypeFlag.typetime */);
|
|
3487
3717
|
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(2);
|
|
3488
3718
|
(0, testHelpers_spec_1.expectTypeToBe)(typetimeSymbols.get('myinterface').type, types_1.InterfaceType);
|
|
3489
3719
|
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('myenum').type, types_1.EnumType);
|
|
@@ -3496,7 +3726,7 @@ describe('BrsFile', () => {
|
|
|
3496
3726
|
end sub
|
|
3497
3727
|
`);
|
|
3498
3728
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3499
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3729
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3500
3730
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3501
3731
|
mainFile = program.setFile('source/main.bs', `
|
|
3502
3732
|
sub someFunc()
|
|
@@ -3508,9 +3738,9 @@ describe('BrsFile', () => {
|
|
|
3508
3738
|
end sub
|
|
3509
3739
|
`);
|
|
3510
3740
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3511
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3741
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3512
3742
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3513
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3743
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3514
3744
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3515
3745
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc2')).to.be.true;
|
|
3516
3746
|
});
|
|
@@ -3525,7 +3755,7 @@ describe('BrsFile', () => {
|
|
|
3525
3755
|
end sub
|
|
3526
3756
|
`);
|
|
3527
3757
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3528
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3758
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3529
3759
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3530
3760
|
mainFile = program.setFile('source/main.bs', `
|
|
3531
3761
|
sub someFunc()
|
|
@@ -3533,9 +3763,9 @@ describe('BrsFile', () => {
|
|
|
3533
3763
|
end sub
|
|
3534
3764
|
`);
|
|
3535
3765
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3536
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3766
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3537
3767
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3538
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3768
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3539
3769
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3540
3770
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc2')).to.be.true;
|
|
3541
3771
|
});
|
|
@@ -3545,7 +3775,7 @@ describe('BrsFile', () => {
|
|
|
3545
3775
|
end namespace
|
|
3546
3776
|
`);
|
|
3547
3777
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3548
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3778
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3549
3779
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(0);
|
|
3550
3780
|
mainFile = program.setFile('source/main.bs', `
|
|
3551
3781
|
namespace Alpha
|
|
@@ -3553,9 +3783,9 @@ describe('BrsFile', () => {
|
|
|
3553
3783
|
end namespace
|
|
3554
3784
|
`);
|
|
3555
3785
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3556
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3786
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3557
3787
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3558
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3788
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3559
3789
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3560
3790
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('alpha.abc')).to.be.true;
|
|
3561
3791
|
});
|
|
@@ -3570,7 +3800,7 @@ describe('BrsFile', () => {
|
|
|
3570
3800
|
end namespace
|
|
3571
3801
|
`);
|
|
3572
3802
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3573
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3803
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3574
3804
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3575
3805
|
mainFile = program.setFile('source/main.bs', `
|
|
3576
3806
|
sub printSomething()
|
|
@@ -3582,9 +3812,9 @@ describe('BrsFile', () => {
|
|
|
3582
3812
|
end namespace
|
|
3583
3813
|
`);
|
|
3584
3814
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3585
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3815
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3586
3816
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3587
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3817
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3588
3818
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3589
3819
|
});
|
|
3590
3820
|
it('should include changes in function signatures', () => {
|
|
@@ -3594,7 +3824,7 @@ describe('BrsFile', () => {
|
|
|
3594
3824
|
end function
|
|
3595
3825
|
`);
|
|
3596
3826
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3597
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3827
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3598
3828
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3599
3829
|
mainFile = program.setFile('source/main.bs', `
|
|
3600
3830
|
function someFunc(x, y)
|
|
@@ -3602,9 +3832,9 @@ describe('BrsFile', () => {
|
|
|
3602
3832
|
end function
|
|
3603
3833
|
`);
|
|
3604
3834
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3605
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3835
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3606
3836
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3607
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3837
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3608
3838
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3609
3839
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc'));
|
|
3610
3840
|
});
|
|
@@ -3618,7 +3848,7 @@ describe('BrsFile', () => {
|
|
|
3618
3848
|
end class
|
|
3619
3849
|
`);
|
|
3620
3850
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3621
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3851
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3622
3852
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3623
3853
|
mainFile = program.setFile('source/main.bs', `
|
|
3624
3854
|
class MyKlass
|
|
@@ -3629,12 +3859,12 @@ describe('BrsFile', () => {
|
|
|
3629
3859
|
end class
|
|
3630
3860
|
`);
|
|
3631
3861
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3632
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3862
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3633
3863
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3634
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3864
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3635
3865
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3636
3866
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('myklass'));
|
|
3637
|
-
let typeTimeChanges = mainFile.providedSymbols.changes.get(
|
|
3867
|
+
let typeTimeChanges = mainFile.providedSymbols.changes.get(2 /* SymbolTypeFlag.typetime */);
|
|
3638
3868
|
(0, chai_config_spec_1.expect)(typeTimeChanges.size).to.eq(1);
|
|
3639
3869
|
(0, chai_config_spec_1.expect)(typeTimeChanges.has('myklass'));
|
|
3640
3870
|
});
|
|
@@ -3646,9 +3876,9 @@ describe('BrsFile', () => {
|
|
|
3646
3876
|
end interface
|
|
3647
3877
|
`);
|
|
3648
3878
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3649
|
-
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3879
|
+
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(2 /* SymbolTypeFlag.typetime */);
|
|
3650
3880
|
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3651
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3881
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3652
3882
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(0);
|
|
3653
3883
|
mainFile = program.setFile('source/main.bs', `
|
|
3654
3884
|
interface Iface1
|
|
@@ -3658,12 +3888,12 @@ describe('BrsFile', () => {
|
|
|
3658
3888
|
end interface
|
|
3659
3889
|
`);
|
|
3660
3890
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3661
|
-
typetimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3891
|
+
typetimeSymbols = mainFile.providedSymbols.symbolMap.get(2 /* SymbolTypeFlag.typetime */);
|
|
3662
3892
|
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3663
|
-
let typeTimeChanges = mainFile.providedSymbols.changes.get(
|
|
3893
|
+
let typeTimeChanges = mainFile.providedSymbols.changes.get(2 /* SymbolTypeFlag.typetime */);
|
|
3664
3894
|
(0, chai_config_spec_1.expect)(typeTimeChanges.size).to.eq(1);
|
|
3665
3895
|
(0, chai_config_spec_1.expect)(typeTimeChanges.has('iface1'));
|
|
3666
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3896
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3667
3897
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3668
3898
|
});
|
|
3669
3899
|
it('should not include changes in enum values, if inner type is the same', () => {
|
|
@@ -3676,7 +3906,7 @@ describe('BrsFile', () => {
|
|
|
3676
3906
|
end enum
|
|
3677
3907
|
`);
|
|
3678
3908
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3679
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3909
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3680
3910
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3681
3911
|
mainFile = program.setFile('source/main.bs', `
|
|
3682
3912
|
enum MyEnum
|
|
@@ -3687,13 +3917,13 @@ describe('BrsFile', () => {
|
|
|
3687
3917
|
end enum
|
|
3688
3918
|
`);
|
|
3689
3919
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3690
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3920
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3691
3921
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3692
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3922
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3693
3923
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3694
|
-
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3924
|
+
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(2 /* SymbolTypeFlag.typetime */);
|
|
3695
3925
|
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3696
|
-
let typetimeChanges = mainFile.providedSymbols.changes.get(
|
|
3926
|
+
let typetimeChanges = mainFile.providedSymbols.changes.get(2 /* SymbolTypeFlag.typetime */);
|
|
3697
3927
|
(0, chai_config_spec_1.expect)(typetimeChanges.size).to.eq(0);
|
|
3698
3928
|
});
|
|
3699
3929
|
it('should include changes in enum, if different number of members', () => {
|
|
@@ -3718,7 +3948,7 @@ describe('BrsFile', () => {
|
|
|
3718
3948
|
end enum
|
|
3719
3949
|
`);
|
|
3720
3950
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3721
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3951
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3722
3952
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3723
3953
|
mainFile = program.setFile('source/main.bs', `
|
|
3724
3954
|
enum Direction ' same
|
|
@@ -3741,9 +3971,9 @@ describe('BrsFile', () => {
|
|
|
3741
3971
|
end enum
|
|
3742
3972
|
`);
|
|
3743
3973
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3744
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3974
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3745
3975
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3746
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
3976
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3747
3977
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(2);
|
|
3748
3978
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('weather'));
|
|
3749
3979
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('colors'));
|
|
@@ -3758,7 +3988,7 @@ describe('BrsFile', () => {
|
|
|
3758
3988
|
end enum
|
|
3759
3989
|
`);
|
|
3760
3990
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3761
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
3991
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3762
3992
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3763
3993
|
mainFile = program.setFile('source/main.bs', `
|
|
3764
3994
|
enum Direction ' now is a string
|
|
@@ -3769,9 +3999,9 @@ describe('BrsFile', () => {
|
|
|
3769
3999
|
end enum
|
|
3770
4000
|
`);
|
|
3771
4001
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3772
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
4002
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3773
4003
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3774
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
4004
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3775
4005
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3776
4006
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('direction'));
|
|
3777
4007
|
});
|
|
@@ -3782,7 +4012,7 @@ describe('BrsFile', () => {
|
|
|
3782
4012
|
end namespace
|
|
3783
4013
|
`);
|
|
3784
4014
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3785
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
4015
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3786
4016
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3787
4017
|
mainFile = program.setFile('source/main.bs', `
|
|
3788
4018
|
namespace alpha.beta
|
|
@@ -3790,9 +4020,9 @@ describe('BrsFile', () => {
|
|
|
3790
4020
|
end namespace
|
|
3791
4021
|
`);
|
|
3792
4022
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3793
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
4023
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3794
4024
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3795
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
4025
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3796
4026
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3797
4027
|
(0, chai_config_spec_1.expect)(runtimeChanges.has('alpha.beta.pi'));
|
|
3798
4028
|
});
|
|
@@ -3810,11 +4040,11 @@ describe('BrsFile', () => {
|
|
|
3810
4040
|
end sub
|
|
3811
4041
|
`);
|
|
3812
4042
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3813
|
-
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
4043
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3814
4044
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3815
4045
|
mainFile = program.setFile('source/main.bs', `
|
|
3816
4046
|
function func1(p as string) as integer
|
|
3817
|
-
return len(p)+1
|
|
4047
|
+
return len(p) + 1
|
|
3818
4048
|
end function
|
|
3819
4049
|
|
|
3820
4050
|
sub displayModelTypeInLabel(myLabel as roSgNodeLabel)
|
|
@@ -3825,9 +4055,9 @@ describe('BrsFile', () => {
|
|
|
3825
4055
|
end sub
|
|
3826
4056
|
`);
|
|
3827
4057
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3828
|
-
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(
|
|
4058
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(1 /* SymbolTypeFlag.runtime */);
|
|
3829
4059
|
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3830
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
4060
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3831
4061
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3832
4062
|
});
|
|
3833
4063
|
it('classes that override AA built-in methods show change properly', () => {
|
|
@@ -3843,7 +4073,7 @@ describe('BrsFile', () => {
|
|
|
3843
4073
|
// No changes!
|
|
3844
4074
|
mainFile = program.setFile('source/class.bs', classFileContent);
|
|
3845
4075
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3846
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
4076
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3847
4077
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3848
4078
|
});
|
|
3849
4079
|
it('functions in a namespace that return classes show change properly', () => {
|
|
@@ -3869,17 +4099,16 @@ describe('BrsFile', () => {
|
|
|
3869
4099
|
// No changes!
|
|
3870
4100
|
mainFile = program.setFile('source/class.bs', fileContent);
|
|
3871
4101
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3872
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
4102
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3873
4103
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3874
4104
|
});
|
|
3875
4105
|
it('functions in a namespace that have class params show change properly', () => {
|
|
3876
4106
|
const fileContent = `
|
|
3877
4107
|
namespace Alpha.Beta
|
|
3878
|
-
|
|
3879
4108
|
class SomeKlass
|
|
3880
4109
|
name as string
|
|
3881
4110
|
function combineName(klass as SomeKlass)
|
|
3882
|
-
m.name = m.name+klass.name
|
|
4111
|
+
m.name = m.name + klass.name
|
|
3883
4112
|
end function
|
|
3884
4113
|
end class
|
|
3885
4114
|
|
|
@@ -3894,7 +4123,7 @@ describe('BrsFile', () => {
|
|
|
3894
4123
|
// No changes!
|
|
3895
4124
|
mainFile = program.setFile('source/class.bs', fileContent);
|
|
3896
4125
|
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3897
|
-
let runtimeChanges = mainFile.providedSymbols.changes.get(
|
|
4126
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(1 /* SymbolTypeFlag.runtime */);
|
|
3898
4127
|
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3899
4128
|
});
|
|
3900
4129
|
});
|
|
@@ -3906,7 +4135,7 @@ describe('BrsFile', () => {
|
|
|
3906
4135
|
aa1 = {
|
|
3907
4136
|
"sprop1": 0,
|
|
3908
4137
|
prop1: 1
|
|
3909
|
-
|
|
4138
|
+
prop2: {
|
|
3910
4139
|
prop3: 2
|
|
3911
4140
|
}
|
|
3912
4141
|
}
|
|
@@ -3940,7 +4169,7 @@ describe('BrsFile', () => {
|
|
|
3940
4169
|
aa1 = {
|
|
3941
4170
|
"constructor": 0,
|
|
3942
4171
|
constructor: 1
|
|
3943
|
-
|
|
4172
|
+
valueOf: {
|
|
3944
4173
|
toString: 2
|
|
3945
4174
|
}
|
|
3946
4175
|
}
|
|
@@ -3954,6 +4183,44 @@ describe('BrsFile', () => {
|
|
|
3954
4183
|
const { propertyHints } = file['_cachedLookups'];
|
|
3955
4184
|
(0, chai_config_spec_1.expect)(Object.keys(propertyHints).sort()).to.deep.equal(expected, 'Initial hints');
|
|
3956
4185
|
});
|
|
4186
|
+
it('allows built-in types for class members', () => {
|
|
4187
|
+
program.setFile('source/main.bs', `
|
|
4188
|
+
class MyBase
|
|
4189
|
+
regex as roRegex
|
|
4190
|
+
node as roSGNodeLabel
|
|
4191
|
+
|
|
4192
|
+
sub outputMatches(textInput as string)
|
|
4193
|
+
matches = m.regex.match(textInput)
|
|
4194
|
+
if matches.count() > 1
|
|
4195
|
+
m.node.text = matches[1]
|
|
4196
|
+
else
|
|
4197
|
+
m.node.text = "no match"
|
|
4198
|
+
end if
|
|
4199
|
+
end sub
|
|
4200
|
+
|
|
4201
|
+
function getLabelParent() as roSGNode
|
|
4202
|
+
return m.node.getParent()
|
|
4203
|
+
end function
|
|
4204
|
+
end class
|
|
4205
|
+
`);
|
|
4206
|
+
program.validate();
|
|
4207
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
4208
|
+
});
|
|
4209
|
+
it('allows types on lhs of assignments', async () => {
|
|
4210
|
+
await testTranspile(`
|
|
4211
|
+
sub foo(node as roSGNode)
|
|
4212
|
+
nodeParent as roSGNode = node.getParent()
|
|
4213
|
+
text as string = nodeParent.id
|
|
4214
|
+
print text
|
|
4215
|
+
end sub
|
|
4216
|
+
`, `
|
|
4217
|
+
sub foo(node as dynamic)
|
|
4218
|
+
nodeParent = node.getParent()
|
|
4219
|
+
text = nodeParent.id
|
|
4220
|
+
print text
|
|
4221
|
+
end sub
|
|
4222
|
+
`);
|
|
4223
|
+
});
|
|
3957
4224
|
});
|
|
3958
4225
|
});
|
|
3959
4226
|
//# sourceMappingURL=BrsFile.spec.js.map
|