brighterscript 0.52.3 → 0.54.0
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 +29 -0
- package/dist/DiagnosticMessages.d.ts +14 -3
- package/dist/DiagnosticMessages.js +14 -3
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.js +51 -9
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +8 -4
- package/dist/Program.js +70 -35
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +24 -9
- package/dist/Scope.js +96 -50
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +62 -0
- package/dist/SymbolTable.js +101 -0
- package/dist/SymbolTable.js.map +1 -0
- package/dist/astUtils/reflection.d.ts +2 -1
- package/dist/astUtils/reflection.js +6 -2
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +2 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +3 -1
- package/dist/bscPlugin/BscPlugin.js +8 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +11 -5
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +75 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +6 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +45 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +13 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +146 -0
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +167 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.d.ts +7 -1
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +81 -22
- package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +5 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +28 -2
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +18 -3
- package/dist/bscPlugin/validation/ScopeValidator.js +139 -47
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +10 -10
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +14 -9
- package/dist/files/BrsFile.js +121 -142
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +164 -109
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +1 -2
- package/dist/files/XmlFile.js +0 -5
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/tests/imports.spec.js +1 -1
- package/dist/files/tests/imports.spec.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.js +20 -16
- package/dist/files/tests/optionalChaning.spec.js.map +1 -1
- package/dist/globalCallables.js +3 -0
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +44 -2
- package/dist/lexer/Lexer.spec.js +7 -0
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +1 -0
- package/dist/lexer/TokenKind.js +7 -3
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/Expression.d.ts +4 -1
- package/dist/parser/Expression.js +8 -2
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +1 -1
- package/dist/parser/Parser.d.ts +13 -2
- package/dist/parser/Parser.js +137 -60
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Statement.d.ts +29 -1
- package/dist/parser/Statement.js +66 -4
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +73 -31
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +148 -47
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +219 -37
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.d.ts +1 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js +182 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -0
- package/dist/parser/tests/statement/Enum.spec.js +17 -2
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +72 -57
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
- package/dist/types/DynamicType.d.ts +1 -0
- package/dist/types/DynamicType.js +1 -0
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/util.d.ts +37 -6
- package/dist/util.js +90 -6
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js +4 -6
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +1 -1
|
@@ -1330,7 +1330,7 @@ describe('BrsFile', () => {
|
|
|
1330
1330
|
`);
|
|
1331
1331
|
program.validate();
|
|
1332
1332
|
(0, testHelpers_spec_1.expectDiagnostics)(program, [
|
|
1333
|
-
DiagnosticMessages_1.DiagnosticMessages.
|
|
1333
|
+
DiagnosticMessages_1.DiagnosticMessages.cannotFindName('DoesNotExist')
|
|
1334
1334
|
]);
|
|
1335
1335
|
});
|
|
1336
1336
|
it('finds arguments with variable values', () => {
|
|
@@ -1503,6 +1503,32 @@ describe('BrsFile', () => {
|
|
|
1503
1503
|
(0, chai_1.expect)(file.functionScopes[1].range).to.eql(vscode_languageserver_1.Range.create(2, 30, 4, 32));
|
|
1504
1504
|
});
|
|
1505
1505
|
});
|
|
1506
|
+
it('handles mixed case `then` partions of conditionals', () => {
|
|
1507
|
+
let mainFile = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1508
|
+
sub Main()
|
|
1509
|
+
if true then
|
|
1510
|
+
print "works"
|
|
1511
|
+
end if
|
|
1512
|
+
end sub
|
|
1513
|
+
`);
|
|
1514
|
+
(0, chai_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
|
|
1515
|
+
mainFile = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1516
|
+
sub Main()
|
|
1517
|
+
if true Then
|
|
1518
|
+
print "works"
|
|
1519
|
+
end if
|
|
1520
|
+
end sub
|
|
1521
|
+
`);
|
|
1522
|
+
(0, chai_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
|
|
1523
|
+
mainFile = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
1524
|
+
sub Main()
|
|
1525
|
+
if true THEN
|
|
1526
|
+
print "works"
|
|
1527
|
+
end if
|
|
1528
|
+
end sub
|
|
1529
|
+
`);
|
|
1530
|
+
(0, chai_1.expect)(mainFile.getDiagnostics()).to.be.lengthOf(0);
|
|
1531
|
+
});
|
|
1506
1532
|
describe('getHover', () => {
|
|
1507
1533
|
it('works for param types', () => {
|
|
1508
1534
|
let file = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -1513,11 +1539,11 @@ describe('BrsFile', () => {
|
|
|
1513
1539
|
end sub
|
|
1514
1540
|
`);
|
|
1515
1541
|
//hover over the `name = 1` line
|
|
1516
|
-
let hover =
|
|
1542
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 24))[0];
|
|
1517
1543
|
(0, chai_1.expect)(hover).to.exist;
|
|
1518
1544
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 24));
|
|
1519
1545
|
//hover over the `name` parameter declaration
|
|
1520
|
-
hover =
|
|
1546
|
+
hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 34))[0];
|
|
1521
1547
|
(0, chai_1.expect)(hover).to.exist;
|
|
1522
1548
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(1, 32, 1, 36));
|
|
1523
1549
|
});
|
|
@@ -1530,9 +1556,9 @@ describe('BrsFile', () => {
|
|
|
1530
1556
|
end sub
|
|
1531
1557
|
`);
|
|
1532
1558
|
//hover over the `as`
|
|
1533
|
-
(0, chai_1.expect)(
|
|
1559
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 31))).to.be.empty;
|
|
1534
1560
|
//hover over the `string`
|
|
1535
|
-
(0, chai_1.expect)(
|
|
1561
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 36))).to.be.empty;
|
|
1536
1562
|
});
|
|
1537
1563
|
it('finds declared function', () => {
|
|
1538
1564
|
let file = program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
|
|
@@ -1542,7 +1568,7 @@ describe('BrsFile', () => {
|
|
|
1542
1568
|
shoeSize = 10
|
|
1543
1569
|
end function
|
|
1544
1570
|
`);
|
|
1545
|
-
let hover =
|
|
1571
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(1, 28))[0];
|
|
1546
1572
|
(0, chai_1.expect)(hover).to.exist;
|
|
1547
1573
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(1, 25, 1, 29));
|
|
1548
1574
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1561,7 +1587,7 @@ describe('BrsFile', () => {
|
|
|
1561
1587
|
end function
|
|
1562
1588
|
end namespace
|
|
1563
1589
|
`);
|
|
1564
|
-
let hover =
|
|
1590
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 28))[0];
|
|
1565
1591
|
(0, chai_1.expect)(hover).to.exist;
|
|
1566
1592
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 25, 2, 29));
|
|
1567
1593
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1579,7 +1605,7 @@ describe('BrsFile', () => {
|
|
|
1579
1605
|
sayMyName()
|
|
1580
1606
|
end sub
|
|
1581
1607
|
`);
|
|
1582
|
-
let hover =
|
|
1608
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(5, 24))[0];
|
|
1583
1609
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(5, 20, 5, 29));
|
|
1584
1610
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1585
1611
|
'```brightscript',
|
|
@@ -1587,25 +1613,25 @@ describe('BrsFile', () => {
|
|
|
1587
1613
|
'```'
|
|
1588
1614
|
].join('\n'));
|
|
1589
1615
|
});
|
|
1590
|
-
it('does not crash when hovering on built-in functions',
|
|
1616
|
+
it('does not crash when hovering on built-in functions', () => {
|
|
1591
1617
|
let file = program.setFile('source/main.brs', `
|
|
1592
1618
|
function doUcase(text)
|
|
1593
1619
|
return ucase(text)
|
|
1594
1620
|
end function
|
|
1595
1621
|
`);
|
|
1596
|
-
(0, chai_1.expect)(
|
|
1622
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 30))[0].contents).to.equal([
|
|
1597
1623
|
'```brightscript',
|
|
1598
1624
|
'function UCase(s as string) as string',
|
|
1599
1625
|
'```'
|
|
1600
1626
|
].join('\n'));
|
|
1601
1627
|
});
|
|
1602
|
-
it('does not crash when hovering on object method call',
|
|
1628
|
+
it('does not crash when hovering on object method call', () => {
|
|
1603
1629
|
let file = program.setFile('source/main.brs', `
|
|
1604
1630
|
function getInstr(url, text)
|
|
1605
1631
|
return url.instr(text)
|
|
1606
1632
|
end function
|
|
1607
1633
|
`);
|
|
1608
|
-
(0, chai_1.expect)(
|
|
1634
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 35))[0].contents).to.equal([
|
|
1609
1635
|
'```brightscript',
|
|
1610
1636
|
//TODO this really shouldn't be returning the global function, but it does...so make sure it doesn't crash right now.
|
|
1611
1637
|
'function Instr(start as integer, text as string, substring as string) as integer',
|
|
@@ -1622,7 +1648,7 @@ describe('BrsFile', () => {
|
|
|
1622
1648
|
|
|
1623
1649
|
end sub
|
|
1624
1650
|
`);
|
|
1625
|
-
let hover =
|
|
1651
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(2, 25))[0];
|
|
1626
1652
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1627
1653
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1628
1654
|
'```brightscript',
|
|
@@ -1642,7 +1668,7 @@ describe('BrsFile', () => {
|
|
|
1642
1668
|
end sub
|
|
1643
1669
|
end namespace
|
|
1644
1670
|
`);
|
|
1645
|
-
let hover =
|
|
1671
|
+
let hover = program.getHover(file.srcPath, vscode_languageserver_1.Position.create(3, 25))[0];
|
|
1646
1672
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(3, 20, 3, 29));
|
|
1647
1673
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
1648
1674
|
'```brightscript',
|
|
@@ -1665,7 +1691,7 @@ describe('BrsFile', () => {
|
|
|
1665
1691
|
|
|
1666
1692
|
end sub
|
|
1667
1693
|
`);
|
|
1668
|
-
let hover =
|
|
1694
|
+
let hover = program.getHover(mainFile.srcPath, vscode_languageserver_1.Position.create(2, 25))[0];
|
|
1669
1695
|
(0, chai_1.expect)(hover).to.exist;
|
|
1670
1696
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 20, 2, 29));
|
|
1671
1697
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1690,7 +1716,7 @@ describe('BrsFile', () => {
|
|
|
1690
1716
|
end sub
|
|
1691
1717
|
end namespace
|
|
1692
1718
|
`);
|
|
1693
|
-
let hover =
|
|
1719
|
+
let hover = program.getHover(mainFile.srcPath, vscode_languageserver_1.Position.create(2, 34))[0];
|
|
1694
1720
|
(0, chai_1.expect)(hover).to.exist;
|
|
1695
1721
|
(0, chai_1.expect)(hover.range).to.eql(vscode_languageserver_1.Range.create(2, 28, 2, 37));
|
|
1696
1722
|
(0, chai_1.expect)(hover.contents).to.equal([
|
|
@@ -1699,7 +1725,7 @@ describe('BrsFile', () => {
|
|
|
1699
1725
|
'```'
|
|
1700
1726
|
].join('\n'));
|
|
1701
1727
|
});
|
|
1702
|
-
it('includes markdown comments in hover.',
|
|
1728
|
+
it('includes markdown comments in hover.', () => {
|
|
1703
1729
|
let rootDir = process.cwd();
|
|
1704
1730
|
program = new Program_1.Program({
|
|
1705
1731
|
rootDir: rootDir
|
|
@@ -1721,7 +1747,7 @@ describe('BrsFile', () => {
|
|
|
1721
1747
|
end sub
|
|
1722
1748
|
`);
|
|
1723
1749
|
//hover over log("hello")
|
|
1724
|
-
(0, chai_1.expect)(
|
|
1750
|
+
(0, chai_1.expect)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(5, 22))[0].contents).to.equal([
|
|
1725
1751
|
'```brightscript',
|
|
1726
1752
|
'sub log(message as string) as void',
|
|
1727
1753
|
'```',
|
|
@@ -1732,7 +1758,7 @@ describe('BrsFile', () => {
|
|
|
1732
1758
|
''
|
|
1733
1759
|
].join('\n'));
|
|
1734
1760
|
//hover over sub ma|in()
|
|
1735
|
-
(0, chai_1.expect)((0, testHelpers_spec_1.trim)(
|
|
1761
|
+
(0, chai_1.expect)((0, testHelpers_spec_1.trim)(program.getHover(file.srcPath, vscode_languageserver_1.Position.create(4, 22))[0].contents.toString())).to.equal((0, testHelpers_spec_1.trim) `
|
|
1736
1762
|
\`\`\`brightscript
|
|
1737
1763
|
sub main() as void
|
|
1738
1764
|
\`\`\`
|
|
@@ -1809,49 +1835,56 @@ describe('BrsFile', () => {
|
|
|
1809
1835
|
});
|
|
1810
1836
|
it('transpiles if statement keywords as provided', () => {
|
|
1811
1837
|
const code = `
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1838
|
+
sub main()
|
|
1839
|
+
If True Then
|
|
1840
|
+
Print True
|
|
1841
|
+
Else If True Then
|
|
1842
|
+
print True
|
|
1843
|
+
Else If False Then
|
|
1844
|
+
Print False
|
|
1845
|
+
Else
|
|
1846
|
+
Print False
|
|
1847
|
+
End If
|
|
1848
|
+
end sub
|
|
1821
1849
|
`;
|
|
1822
1850
|
testTranspile(code);
|
|
1823
1851
|
testTranspile(code.toLowerCase());
|
|
1824
1852
|
testTranspile(code.toUpperCase());
|
|
1825
1853
|
});
|
|
1826
1854
|
it('does not transpile `then` tokens', () => {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1855
|
+
testTranspile(`
|
|
1856
|
+
sub main()
|
|
1857
|
+
if true
|
|
1858
|
+
print true
|
|
1859
|
+
else if true
|
|
1860
|
+
print false
|
|
1861
|
+
end if
|
|
1862
|
+
end sub
|
|
1863
|
+
`);
|
|
1835
1864
|
});
|
|
1836
1865
|
it('honors spacing between multi-word tokens', () => {
|
|
1837
1866
|
testTranspile(`
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1867
|
+
sub main()
|
|
1868
|
+
if true
|
|
1869
|
+
print true
|
|
1870
|
+
elseif true
|
|
1871
|
+
print false
|
|
1872
|
+
endif
|
|
1873
|
+
end sub
|
|
1843
1874
|
`);
|
|
1844
1875
|
});
|
|
1845
1876
|
it('handles when only some of the statements have `then`', () => {
|
|
1846
1877
|
testTranspile(`
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
if true then
|
|
1852
|
-
|
|
1878
|
+
sub main()
|
|
1879
|
+
if true
|
|
1880
|
+
else if true then
|
|
1881
|
+
else if true
|
|
1882
|
+
else if true then
|
|
1883
|
+
if true then
|
|
1884
|
+
return true
|
|
1885
|
+
end if
|
|
1853
1886
|
end if
|
|
1854
|
-
end
|
|
1887
|
+
end sub
|
|
1855
1888
|
`);
|
|
1856
1889
|
});
|
|
1857
1890
|
it('retains casing of parameter types', () => {
|
|
@@ -1924,7 +1957,7 @@ describe('BrsFile', () => {
|
|
|
1924
1957
|
testTranspile(`
|
|
1925
1958
|
sub main()
|
|
1926
1959
|
try
|
|
1927
|
-
print
|
|
1960
|
+
print m.b.c
|
|
1928
1961
|
catch e
|
|
1929
1962
|
print e
|
|
1930
1963
|
end try
|
|
@@ -1942,7 +1975,7 @@ describe('BrsFile', () => {
|
|
|
1942
1975
|
sub main()
|
|
1943
1976
|
sayHello = NameA.NameB.Speak
|
|
1944
1977
|
sayHello()
|
|
1945
|
-
someOtherObject =
|
|
1978
|
+
someOtherObject = m.other.object
|
|
1946
1979
|
end sub
|
|
1947
1980
|
`, `
|
|
1948
1981
|
sub NameA_NameB_Speak()
|
|
@@ -1951,7 +1984,7 @@ describe('BrsFile', () => {
|
|
|
1951
1984
|
sub main()
|
|
1952
1985
|
sayHello = NameA_NameB_Speak
|
|
1953
1986
|
sayHello()
|
|
1954
|
-
someOtherObject =
|
|
1987
|
+
someOtherObject = m.other.object
|
|
1955
1988
|
end sub
|
|
1956
1989
|
`);
|
|
1957
1990
|
});
|
|
@@ -2075,27 +2108,42 @@ describe('BrsFile', () => {
|
|
|
2075
2108
|
`, 'trim', 'source/main.bs');
|
|
2076
2109
|
});
|
|
2077
2110
|
it('transpiles dim', () => {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2111
|
+
function doTest(code) {
|
|
2112
|
+
testTranspile(`
|
|
2113
|
+
sub main()
|
|
2114
|
+
requestList = []
|
|
2115
|
+
${code}
|
|
2116
|
+
end sub
|
|
2117
|
+
`, `
|
|
2118
|
+
sub main()
|
|
2119
|
+
requestList = []
|
|
2120
|
+
${code}
|
|
2121
|
+
end sub
|
|
2122
|
+
`);
|
|
2123
|
+
}
|
|
2124
|
+
doTest(`Dim c[5]`);
|
|
2125
|
+
doTest(`Dim c[5, 4]`);
|
|
2126
|
+
doTest(`Dim c[5, 4, 6]`);
|
|
2127
|
+
doTest(`Dim requestData[requestList.count()]`);
|
|
2128
|
+
doTest(`Dim requestData[1, requestList.count()]`);
|
|
2129
|
+
doTest(`Dim requestData[1, requestList.count(), 2]`);
|
|
2130
|
+
doTest(`Dim requestData[requestList[2]]`);
|
|
2131
|
+
doTest(`Dim requestData[1, requestList[2]]`);
|
|
2132
|
+
doTest(`Dim requestData[1, requestList[2], 2]`);
|
|
2133
|
+
doTest(`Dim requestData[requestList["2"]]`);
|
|
2134
|
+
doTest(`Dim requestData[1, requestList["2"]]`);
|
|
2135
|
+
doTest(`Dim requestData[1, requestList["2"], 2]`);
|
|
2136
|
+
doTest(`Dim requestData[1, StrToI("1"), 2]`);
|
|
2091
2137
|
testTranspile(`
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2138
|
+
function getValue(param1)
|
|
2139
|
+
end function
|
|
2140
|
+
|
|
2141
|
+
sub main()
|
|
2142
|
+
requestList = []
|
|
2143
|
+
Dim requestData[1, getValue({
|
|
2144
|
+
key: "value"
|
|
2145
|
+
}), 2]
|
|
2146
|
+
end sub
|
|
2099
2147
|
`);
|
|
2100
2148
|
});
|
|
2101
2149
|
it('transpiles calls to fully-qualified namespaced functions', () => {
|
|
@@ -2209,49 +2257,55 @@ describe('BrsFile', () => {
|
|
|
2209
2257
|
});
|
|
2210
2258
|
it('handles empty if block', () => {
|
|
2211
2259
|
testTranspile(`
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2260
|
+
sub main()
|
|
2261
|
+
if true then
|
|
2262
|
+
end if
|
|
2263
|
+
if true then
|
|
2264
|
+
else
|
|
2265
|
+
print "else"
|
|
2266
|
+
end if
|
|
2267
|
+
if true then
|
|
2268
|
+
else if true then
|
|
2269
|
+
print "else"
|
|
2270
|
+
end if
|
|
2271
|
+
if true then
|
|
2272
|
+
else if true then
|
|
2273
|
+
print "elseif"
|
|
2274
|
+
else
|
|
2275
|
+
print "else"
|
|
2276
|
+
end if
|
|
2277
|
+
end sub
|
|
2228
2278
|
`);
|
|
2229
2279
|
});
|
|
2230
2280
|
it('handles empty elseif block', () => {
|
|
2231
2281
|
testTranspile(`
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2282
|
+
sub main()
|
|
2283
|
+
if true then
|
|
2284
|
+
print "if"
|
|
2285
|
+
else if true then
|
|
2286
|
+
end if
|
|
2287
|
+
if true then
|
|
2288
|
+
print "if"
|
|
2289
|
+
else if true then
|
|
2290
|
+
else if true then
|
|
2291
|
+
end if
|
|
2292
|
+
end sub
|
|
2241
2293
|
`);
|
|
2242
2294
|
});
|
|
2243
2295
|
it('handles empty else block', () => {
|
|
2244
2296
|
testTranspile(`
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2297
|
+
sub main()
|
|
2298
|
+
if true then
|
|
2299
|
+
print "if"
|
|
2300
|
+
else
|
|
2301
|
+
end if
|
|
2302
|
+
if true then
|
|
2303
|
+
print "if"
|
|
2304
|
+
else if true then
|
|
2305
|
+
print "elseif"
|
|
2306
|
+
else
|
|
2307
|
+
end if
|
|
2308
|
+
end sub
|
|
2255
2309
|
`);
|
|
2256
2310
|
});
|
|
2257
2311
|
it('works for function parameters', () => {
|
|
@@ -2361,7 +2415,7 @@ describe('BrsFile', () => {
|
|
|
2361
2415
|
3 'comment
|
|
2362
2416
|
] 'comment
|
|
2363
2417
|
firstIndex = indexes[0] 'comment
|
|
2364
|
-
for each idx in
|
|
2418
|
+
for each idx in indexes 'comment
|
|
2365
2419
|
indexes[idx] = idx + 1 'comment
|
|
2366
2420
|
end for 'comment
|
|
2367
2421
|
if not true then 'comment
|
|
@@ -2441,8 +2495,9 @@ describe('BrsFile', () => {
|
|
|
2441
2495
|
describe('transpile', () => {
|
|
2442
2496
|
it('does not produce diagnostics', () => {
|
|
2443
2497
|
program.setFile('source/main.bs', `
|
|
2444
|
-
sub
|
|
2445
|
-
|
|
2498
|
+
sub test()
|
|
2499
|
+
someNode = createObject("roSGNode", "Rectangle")
|
|
2500
|
+
someNode@.someFunction(test.value)
|
|
2446
2501
|
end sub
|
|
2447
2502
|
`);
|
|
2448
2503
|
program.validate();
|