brighterscript 1.0.0-alpha.16 → 1.0.0-alpha.19

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.
Files changed (158) hide show
  1. package/CHANGELOG.md +72 -1
  2. package/README.md +30 -9
  3. package/dist/BsConfig.d.ts +4 -0
  4. package/dist/DiagnosticMessages.d.ts +16 -1
  5. package/dist/DiagnosticMessages.js +15 -0
  6. package/dist/DiagnosticMessages.js.map +1 -1
  7. package/dist/Logger.js +5 -5
  8. package/dist/Logger.js.map +1 -1
  9. package/dist/Program.d.ts +2 -2
  10. package/dist/Program.js +3 -3
  11. package/dist/Program.js.map +1 -1
  12. package/dist/ProgramBuilder.d.ts +4 -0
  13. package/dist/ProgramBuilder.js +14 -4
  14. package/dist/ProgramBuilder.js.map +1 -1
  15. package/dist/Scope.d.ts +58 -8
  16. package/dist/Scope.js +141 -25
  17. package/dist/Scope.js.map +1 -1
  18. package/dist/XmlScope.js +1 -1
  19. package/dist/XmlScope.js.map +1 -1
  20. package/dist/astUtils/creators.d.ts +3 -3
  21. package/dist/astUtils/creators.js +8 -8
  22. package/dist/astUtils/creators.js.map +1 -1
  23. package/dist/astUtils/creators.spec.js +10 -0
  24. package/dist/astUtils/creators.spec.js.map +1 -1
  25. package/dist/astUtils/reflection.d.ts +8 -5
  26. package/dist/astUtils/reflection.js +18 -6
  27. package/dist/astUtils/reflection.js.map +1 -1
  28. package/dist/astUtils/reflection.spec.js +10 -0
  29. package/dist/astUtils/reflection.spec.js.map +1 -1
  30. package/dist/astUtils/visitors.d.ts +4 -1
  31. package/dist/astUtils/visitors.js.map +1 -1
  32. package/dist/astUtils/visitors.spec.js +2 -0
  33. package/dist/astUtils/visitors.spec.js.map +1 -1
  34. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +2 -2
  35. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  36. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +7 -3
  37. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -1
  38. package/dist/{types/FunctionType.spec.d.ts → bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.d.ts} +0 -0
  39. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +32 -0
  40. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +1 -0
  41. package/dist/cli.js +9 -2
  42. package/dist/cli.js.map +1 -1
  43. package/dist/examples/plugins/removePrint.js +12 -14
  44. package/dist/examples/plugins/removePrint.js.map +1 -1
  45. package/dist/files/BrsFile.Class.spec.js +3 -3
  46. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  47. package/dist/files/BrsFile.d.ts +2 -2
  48. package/dist/files/BrsFile.js +89 -59
  49. package/dist/files/BrsFile.js.map +1 -1
  50. package/dist/files/BrsFile.spec.js +187 -67
  51. package/dist/files/BrsFile.spec.js.map +1 -1
  52. package/dist/globalCallables.js +79 -79
  53. package/dist/globalCallables.js.map +1 -1
  54. package/dist/interfaces.d.ts +43 -4
  55. package/dist/parser/Expression.d.ts +75 -8
  56. package/dist/parser/Expression.js +147 -22
  57. package/dist/parser/Expression.js.map +1 -1
  58. package/dist/parser/Parser.Class.spec.js +6 -6
  59. package/dist/parser/Parser.Class.spec.js.map +1 -1
  60. package/dist/parser/Parser.d.ts +3 -6
  61. package/dist/parser/Parser.js +145 -142
  62. package/dist/parser/Parser.js.map +1 -1
  63. package/dist/parser/Parser.spec.js +61 -6
  64. package/dist/parser/Parser.spec.js.map +1 -1
  65. package/dist/parser/SGTypes.d.ts +2 -2
  66. package/dist/parser/SGTypes.js +2 -2
  67. package/dist/parser/SGTypes.js.map +1 -1
  68. package/dist/parser/Statement.d.ts +63 -43
  69. package/dist/parser/Statement.js +135 -92
  70. package/dist/parser/Statement.js.map +1 -1
  71. package/dist/parser/tests/statement/InterfaceStatement.spec.js +181 -0
  72. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  73. package/dist/parser/tests/statement/TryCatch.spec.js +7 -5
  74. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  75. package/dist/types/ArrayType.js +4 -1
  76. package/dist/types/ArrayType.js.map +1 -1
  77. package/dist/types/ArrayType.spec.js +3 -1
  78. package/dist/types/ArrayType.spec.js.map +1 -1
  79. package/dist/types/BooleanType.d.ts +4 -2
  80. package/dist/types/BooleanType.js +7 -2
  81. package/dist/types/BooleanType.js.map +1 -1
  82. package/dist/types/BooleanType.spec.js +3 -1
  83. package/dist/types/BooleanType.spec.js.map +1 -1
  84. package/dist/types/BscType.d.ts +1 -0
  85. package/dist/types/BscType.js +16 -1
  86. package/dist/types/BscType.js.map +1 -1
  87. package/dist/types/CustomType.js +10 -0
  88. package/dist/types/CustomType.js.map +1 -1
  89. package/dist/types/DoubleType.d.ts +2 -0
  90. package/dist/types/DoubleType.js +7 -2
  91. package/dist/types/DoubleType.js.map +1 -1
  92. package/dist/types/DoubleType.spec.js +3 -1
  93. package/dist/types/DoubleType.spec.js.map +1 -1
  94. package/dist/types/DynamicType.d.ts +2 -0
  95. package/dist/types/DynamicType.js +5 -1
  96. package/dist/types/DynamicType.js.map +1 -1
  97. package/dist/types/FloatType.d.ts +3 -1
  98. package/dist/types/FloatType.js +7 -2
  99. package/dist/types/FloatType.js.map +1 -1
  100. package/dist/types/FloatType.spec.js +2 -0
  101. package/dist/types/FloatType.spec.js.map +1 -1
  102. package/dist/types/FunctionType.d.ts +3 -22
  103. package/dist/types/FunctionType.js +8 -68
  104. package/dist/types/FunctionType.js.map +1 -1
  105. package/dist/types/IntegerType.d.ts +3 -1
  106. package/dist/types/IntegerType.js +7 -2
  107. package/dist/types/IntegerType.js.map +1 -1
  108. package/dist/types/IntegerType.spec.js +3 -1
  109. package/dist/types/IntegerType.spec.js.map +1 -1
  110. package/dist/types/InterfaceType.d.ts +13 -10
  111. package/dist/types/InterfaceType.js +33 -29
  112. package/dist/types/InterfaceType.js.map +1 -1
  113. package/dist/types/InterfaceType.spec.js +36 -16
  114. package/dist/types/InterfaceType.spec.js.map +1 -1
  115. package/dist/types/InvalidType.d.ts +4 -2
  116. package/dist/types/InvalidType.js +7 -2
  117. package/dist/types/InvalidType.js.map +1 -1
  118. package/dist/types/InvalidType.spec.js +2 -0
  119. package/dist/types/InvalidType.spec.js.map +1 -1
  120. package/dist/types/LazyType.js +4 -0
  121. package/dist/types/LazyType.js.map +1 -1
  122. package/dist/types/LongIntegerType.d.ts +3 -1
  123. package/dist/types/LongIntegerType.js +7 -2
  124. package/dist/types/LongIntegerType.js.map +1 -1
  125. package/dist/types/LongIntegerType.spec.js +2 -0
  126. package/dist/types/LongIntegerType.spec.js.map +1 -1
  127. package/dist/types/ObjectType.d.ts +2 -1
  128. package/dist/types/ObjectType.js +4 -2
  129. package/dist/types/ObjectType.js.map +1 -1
  130. package/dist/types/StringType.d.ts +4 -2
  131. package/dist/types/StringType.js +7 -2
  132. package/dist/types/StringType.js.map +1 -1
  133. package/dist/types/StringType.spec.js +2 -0
  134. package/dist/types/StringType.spec.js.map +1 -1
  135. package/dist/types/TypedFunctionType.d.ts +28 -0
  136. package/dist/types/TypedFunctionType.js +88 -0
  137. package/dist/types/TypedFunctionType.js.map +1 -0
  138. package/dist/types/TypedFunctionType.spec.d.ts +1 -0
  139. package/dist/types/TypedFunctionType.spec.js +37 -0
  140. package/dist/types/TypedFunctionType.spec.js.map +1 -0
  141. package/dist/types/UninitializedType.js.map +1 -1
  142. package/dist/types/VoidType.d.ts +4 -2
  143. package/dist/types/VoidType.js +5 -1
  144. package/dist/types/VoidType.js.map +1 -1
  145. package/dist/types/helpers.js +7 -2
  146. package/dist/types/helpers.js.map +1 -1
  147. package/dist/util.d.ts +6 -7
  148. package/dist/util.js +43 -55
  149. package/dist/util.js.map +1 -1
  150. package/dist/validators/ClassValidator.d.ts +14 -1
  151. package/dist/validators/ClassValidator.js +129 -82
  152. package/dist/validators/ClassValidator.js.map +1 -1
  153. package/package.json +3 -2
  154. package/dist/types/FunctionType.spec.js +0 -35
  155. package/dist/types/FunctionType.spec.js.map +0 -1
  156. package/dist/types/UniversalFunctionType.d.ts +0 -9
  157. package/dist/types/UniversalFunctionType.js +0 -25
  158. package/dist/types/UniversalFunctionType.js.map +0 -1
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const chai_1 = require("chai");
4
4
  const sinonImport = require("sinon");
5
- const path = require("path");
6
5
  const vscode_languageserver_1 = require("vscode-languageserver");
7
6
  const Program_1 = require("../Program");
8
7
  const BooleanType_1 = require("../types/BooleanType");
9
8
  const DynamicType_1 = require("../types/DynamicType");
10
- const FunctionType_1 = require("../types/FunctionType");
9
+ const TypedFunctionType_1 = require("../types/TypedFunctionType");
11
10
  const IntegerType_1 = require("../types/IntegerType");
12
11
  const StringType_1 = require("../types/StringType");
13
12
  const BrsFile_1 = require("./BrsFile");
@@ -20,19 +19,24 @@ const PluginInterface_1 = require("../PluginInterface");
20
19
  const testHelpers_spec_1 = require("../testHelpers.spec");
21
20
  const Parser_1 = require("../parser/Parser");
22
21
  const Logger_1 = require("../Logger");
23
- const VoidType_1 = require("../types/VoidType");
22
+ const Statement_1 = require("../parser/Statement");
23
+ const creators_1 = require("../astUtils/creators");
24
+ const fsExtra = require("fs-extra");
25
+ const ArrayType_1 = require("../types/ArrayType");
24
26
  const FloatType_1 = require("../types/FloatType");
25
27
  const ObjectType_1 = require("../types/ObjectType");
26
- const ArrayType_1 = require("../types/ArrayType");
28
+ const VoidType_1 = require("../types/VoidType");
27
29
  let sinon = sinonImport.createSandbox();
28
30
  describe('BrsFile', () => {
29
- let rootDir = (0, util_1.standardizePath) `${process.cwd()}/.tmp/rootDir`;
31
+ let tempDir = (0, util_1.standardizePath) `${process.cwd()}/.tmp`;
32
+ let rootDir = (0, util_1.standardizePath) `${tempDir}/rootDir`;
30
33
  let program;
31
34
  let srcPath = (0, util_1.standardizePath) `${rootDir}/source/main.brs`;
32
35
  let destPath = 'source/main.brs';
33
36
  let file;
34
37
  let testTranspile = (0, testHelpers_spec_1.getTestTranspile)(() => [program, rootDir]);
35
38
  beforeEach(() => {
39
+ fsExtra.emptyDirSync(tempDir);
36
40
  program = new Program_1.Program({ rootDir: rootDir, sourceMap: true });
37
41
  file = new BrsFile_1.BrsFile(srcPath, destPath, program);
38
42
  });
@@ -64,6 +68,14 @@ describe('BrsFile', () => {
64
68
  //BrighterScript
65
69
  (0, chai_1.expect)(new BrsFile_1.BrsFile(`${rootDir}/source/main.bs`, 'source/main.bs', program).needsTranspiled).to.be.true;
66
70
  });
71
+ it('computes new import statements after clearing parser references', () => {
72
+ const file = program.setFile('source/main.bs', ``);
73
+ (0, chai_1.expect)(file.ownScriptImports).to.be.empty;
74
+ file.parser.ast.statements.push(new Statement_1.ImportStatement((0, creators_1.createToken)(TokenKind_1.TokenKind.Import), (0, creators_1.createToken)(TokenKind_1.TokenKind.StringLiteral, 'pkg:/source/lib.brs')));
75
+ (0, chai_1.expect)(file.ownScriptImports).to.be.empty;
76
+ file.parser.invalidateReferences();
77
+ (0, chai_1.expect)(file.ownScriptImports.map(x => x.text)).to.eql(['pkg:/source/lib.brs']);
78
+ });
67
79
  it('allows adding diagnostics', () => {
68
80
  const expected = [{
69
81
  message: 'message',
@@ -1373,7 +1385,7 @@ describe('BrsFile', () => {
1373
1385
  end sub
1374
1386
  `);
1375
1387
  (0, testHelpers_spec_1.expectSymbolTableEquals)(file.parser.references.functionExpressions[0].symbolTable, [
1376
- ['sayHi', new FunctionType_1.FunctionType(new VoidType_1.VoidType(), true), util_1.default.createRange(2, 20, 2, 25)]
1388
+ ['sayHi', new TypedFunctionType_1.TypedFunctionType(new VoidType_1.VoidType(), true), util_1.default.createRange(2, 20, 2, 25)]
1377
1389
  ]);
1378
1390
  (0, testHelpers_spec_1.expectSymbolTableEquals)(file.parser.references.functionExpressions[1].symbolTable, [
1379
1391
  ['age', new IntegerType_1.IntegerType(), util_1.default.createRange(3, 24, 3, 27)]
@@ -1735,6 +1747,106 @@ describe('BrsFile', () => {
1735
1747
  //this test will throw an exception if something went wrong
1736
1748
  });
1737
1749
  describe('transpile', () => {
1750
+ it('transpiles if statement keywords as provided', () => {
1751
+ const code = `
1752
+ If True Then
1753
+ Print True
1754
+ Else If True Then
1755
+ print True
1756
+ Else If False Then
1757
+ Print False
1758
+ Else
1759
+ Print False
1760
+ End If
1761
+ `;
1762
+ testTranspile(code);
1763
+ testTranspile(code.toLowerCase());
1764
+ testTranspile(code.toUpperCase());
1765
+ });
1766
+ it('does not transpile `then` tokens', () => {
1767
+ const code = `
1768
+ if true
1769
+ print true
1770
+ else if true
1771
+ print false
1772
+ end if
1773
+ `;
1774
+ testTranspile(code);
1775
+ });
1776
+ it('honors spacing between multi-word tokens', () => {
1777
+ testTranspile(`
1778
+ if true
1779
+ print true
1780
+ elseif true
1781
+ print false
1782
+ endif
1783
+ `);
1784
+ });
1785
+ it('handles when only some of the statements have `then`', () => {
1786
+ testTranspile(`
1787
+ if true
1788
+ else if true then
1789
+ else if true
1790
+ else if true then
1791
+ if true then
1792
+ return true
1793
+ end if
1794
+ end if
1795
+ `);
1796
+ });
1797
+ it('retains casing of parameter types', () => {
1798
+ function test(type) {
1799
+ testTranspile(`
1800
+ sub one(a as ${type}, b as ${type.toUpperCase()}, c as ${type.toLowerCase()})
1801
+ end sub
1802
+ `);
1803
+ }
1804
+ test('Boolean');
1805
+ test('Double');
1806
+ test('Dynamic');
1807
+ test('Float');
1808
+ test('Integer');
1809
+ test('LongInteger');
1810
+ test('Object');
1811
+ test('String');
1812
+ });
1813
+ it('retains casing of return types', () => {
1814
+ function test(type) {
1815
+ testTranspile(`
1816
+ sub one() as ${type}
1817
+ end sub
1818
+
1819
+ sub two() as ${type.toLowerCase()}
1820
+ end sub
1821
+
1822
+ sub three() as ${type.toUpperCase()}
1823
+ end sub
1824
+ `);
1825
+ }
1826
+ test('Boolean');
1827
+ test('Double');
1828
+ test('Dynamic');
1829
+ test('Float');
1830
+ test('Integer');
1831
+ test('LongInteger');
1832
+ test('Object');
1833
+ test('String');
1834
+ test('Void');
1835
+ });
1836
+ it('retains casing of literal types', () => {
1837
+ function test(type) {
1838
+ testTranspile(`
1839
+ sub main()
1840
+ thing = ${type}
1841
+ thing = ${type.toLowerCase()}
1842
+ thing = ${type.toUpperCase()}
1843
+ end sub
1844
+ `);
1845
+ }
1846
+ test('Invalid');
1847
+ test('True');
1848
+ test('False');
1849
+ });
1738
1850
  describe('throwStatement', () => {
1739
1851
  it('transpiles properly', () => {
1740
1852
  testTranspile(`
@@ -1983,29 +2095,6 @@ describe('BrsFile', () => {
1983
2095
  end sub
1984
2096
  `, null, 'trim');
1985
2097
  });
1986
- it('adds `then` when missing', () => {
1987
- testTranspile(`
1988
- sub a()
1989
- if true
1990
- print "true"
1991
- else if true
1992
- print "true"
1993
- else
1994
- print "true"
1995
- end if
1996
- end sub
1997
- `, `
1998
- sub a()
1999
- if true then
2000
- print "true"
2001
- else if true then
2002
- print "true"
2003
- else
2004
- print "true"
2005
- end if
2006
- end sub
2007
- `, 'trim');
2008
- });
2009
2098
  it('does not add leading or trailing newlines', () => {
2010
2099
  testTranspile(`function abc()\nend function`, undefined, 'none');
2011
2100
  });
@@ -2455,11 +2544,16 @@ describe('BrsFile', () => {
2455
2544
  end class
2456
2545
  class Duck extends Bird
2457
2546
  end class
2458
- end namespace`, (0, testHelpers_spec_1.trim) `
2547
+ end namespace
2548
+ `, (0, testHelpers_spec_1.trim) `
2459
2549
  namespace AnimalKingdom
2460
2550
  class Bird
2551
+ sub new()
2552
+ end sub
2461
2553
  end class
2462
2554
  class Duck extends AnimalKingdom.Bird
2555
+ sub new()
2556
+ end sub
2463
2557
  end class
2464
2558
  end namespace
2465
2559
  `);
@@ -2499,6 +2593,8 @@ describe('BrsFile', () => {
2499
2593
  function getDuck()
2500
2594
  end function
2501
2595
  class Duck
2596
+ sub new()
2597
+ end sub
2502
2598
  @anMember
2503
2599
  @anMember("field")
2504
2600
  private thing as dynamic
@@ -2558,6 +2654,8 @@ describe('BrsFile', () => {
2558
2654
  end namespace
2559
2655
  `, (0, testHelpers_spec_1.trim) `
2560
2656
  class Person
2657
+ sub new()
2658
+ end sub
2561
2659
  public name as string
2562
2660
  public age as integer
2563
2661
  public sub getAge() as integer
@@ -2565,6 +2663,8 @@ describe('BrsFile', () => {
2565
2663
  end class
2566
2664
  namespace NameA.NameB
2567
2665
  class Person
2666
+ sub new()
2667
+ end sub
2568
2668
  public name as string
2569
2669
  public age as integer
2570
2670
  public sub getAge() as integer
@@ -2573,6 +2673,17 @@ describe('BrsFile', () => {
2573
2673
  end namespace
2574
2674
  `);
2575
2675
  });
2676
+ it('creates constructor properly', () => {
2677
+ testTypedef(`
2678
+ class Parent
2679
+ end class
2680
+ `, (0, testHelpers_spec_1.trim) `
2681
+ class Parent
2682
+ sub new()
2683
+ end sub
2684
+ end class
2685
+ `);
2686
+ });
2576
2687
  it('sets properties to dynamic when initialized to invalid', () => {
2577
2688
  testTypedef(`
2578
2689
  class Human
@@ -2581,6 +2692,8 @@ describe('BrsFile', () => {
2581
2692
  end class
2582
2693
  `, (0, testHelpers_spec_1.trim) `
2583
2694
  class Human
2695
+ sub new()
2696
+ end sub
2584
2697
  public firstName as dynamic
2585
2698
  public lastName as string
2586
2699
  end class
@@ -2627,6 +2740,8 @@ describe('BrsFile', () => {
2627
2740
  end class
2628
2741
  `, (0, testHelpers_spec_1.trim) `
2629
2742
  class Human
2743
+ sub new()
2744
+ end sub
2630
2745
  public firstName as string
2631
2746
  protected middleName as string
2632
2747
  private lastName as string
@@ -2653,10 +2768,14 @@ describe('BrsFile', () => {
2653
2768
  end class
2654
2769
  `, (0, testHelpers_spec_1.trim) `
2655
2770
  class Animal
2771
+ sub new()
2772
+ end sub
2656
2773
  public sub speak()
2657
2774
  end sub
2658
2775
  end class
2659
2776
  class Dog extends Animal
2777
+ sub new()
2778
+ end sub
2660
2779
  public override sub speak()
2661
2780
  end sub
2662
2781
  end class
@@ -2728,47 +2847,35 @@ describe('BrsFile', () => {
2728
2847
  });
2729
2848
  });
2730
2849
  describe('Plugins', () => {
2731
- function testPluginTranspile() {
2732
- testTranspile(`
2733
- sub main()
2734
- sayHello(sub()
2735
- print "sub hello"
2736
- end sub)
2737
- print "something"
2738
- end sub
2739
-
2740
- sub sayHello(fn)
2741
- fn()
2742
- print "hello"
2743
- end sub
2744
- `, `
2745
- sub main()
2746
- sayHello(sub()
2747
- \n end sub)
2748
- \n end sub
2749
-
2750
- sub sayHello(fn)
2751
- fn()
2752
- \n end sub
2850
+ let pluginFileName;
2851
+ let idx = 1;
2852
+ beforeEach(() => {
2853
+ pluginFileName = `plugin-${idx++}.js`;
2854
+ fsExtra.outputFileSync((0, util_1.standardizePath) `${tempDir}/plugins/${pluginFileName}`, `
2855
+ function plugin() {
2856
+ return {
2857
+ name: 'lower-file-name',
2858
+ afterFileParse: (evt) => {
2859
+ evt.file._customProp = true;
2860
+ }
2861
+ };
2862
+ }
2863
+ exports.default = plugin;
2753
2864
  `);
2754
- }
2755
- it('can use a plugin object which transforms the AST', () => {
2756
- program.plugins = new PluginInterface_1.default(util_1.default.loadPlugins('', [
2757
- require.resolve('../examples/plugins/removePrint')
2758
- ]), new Logger_1.Logger());
2759
- testPluginTranspile();
2760
2865
  });
2761
- it('can load an absolute plugin which transforms the AST', () => {
2762
- program.plugins = new PluginInterface_1.default(util_1.default.loadPlugins('', [
2763
- path.resolve(process.cwd(), './dist/examples/plugins/removePrint.js')
2866
+ it('can load an absolute plugin which receives callbacks', () => {
2867
+ program.plugins = new PluginInterface_1.default(util_1.default.loadPlugins(tempDir, [
2868
+ (0, util_1.standardizePath) `${tempDir}/plugins/${pluginFileName}`
2764
2869
  ]), new Logger_1.Logger());
2765
- testPluginTranspile();
2870
+ const file = program.setFile('source/MAIN.brs', '');
2871
+ (0, chai_1.expect)(file._customProp).to.exist;
2766
2872
  });
2767
- it('can load a relative plugin which transforms the AST', () => {
2768
- program.plugins = new PluginInterface_1.default(util_1.default.loadPlugins(process.cwd(), [
2769
- './dist/examples/plugins/removePrint.js'
2873
+ it('can load a relative plugin which receives callbacks', () => {
2874
+ program.plugins = new PluginInterface_1.default(util_1.default.loadPlugins(tempDir, [
2875
+ `./plugins/${pluginFileName}`
2770
2876
  ]), new Logger_1.Logger());
2771
- testPluginTranspile();
2877
+ const file = program.setFile('source/MAIN.brs', '');
2878
+ (0, chai_1.expect)(file._customProp).to.exist;
2772
2879
  });
2773
2880
  });
2774
2881
  describe('getSymbolTypeFromToken', () => {
@@ -2826,7 +2933,7 @@ describe('BrsFile', () => {
2826
2933
  (0, chai_1.expect)(symbol.expandedTokenText).to.equal('klass');
2827
2934
  const classStmt = file.parser.references.classStatements[0];
2828
2935
  (0, chai_1.expect)(classStmt.name.text).to.equal('MyKlass');
2829
- (0, chai_1.expect)(symbol.type.isAssignableTo(classStmt.getCustomType())).be.true;
2936
+ (0, chai_1.expect)(symbol.type.isAssignableTo(classStmt.getThisBscType())).be.true;
2830
2937
  (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
2831
2938
  });
2832
2939
  it('gets types of properties of a klass', () => {
@@ -2973,5 +3080,18 @@ describe('BrsFile', () => {
2973
3080
  (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
2974
3081
  });
2975
3082
  });
3083
+ it('defaults to `dynamic` type for a complex expression', () => {
3084
+ const file = program.setFile('source/main.brs', `
3085
+ sub main()
3086
+ name = "cat"
3087
+ thing = m["key"](true)
3088
+ end sub
3089
+ `);
3090
+ program.validate();
3091
+ //sanity check
3092
+ (0, chai_1.expect)(file.parser.references.assignmentStatements[0].containingFunction.symbolTable.getSymbolType('name')).be.instanceof(StringType_1.StringType);
3093
+ //this complex expression should resolve to dynamic type when not known
3094
+ (0, chai_1.expect)(file.parser.references.assignmentStatements[0].containingFunction.symbolTable.getSymbolType('thing')).be.instanceof(DynamicType_1.DynamicType);
3095
+ });
2976
3096
  });
2977
3097
  //# sourceMappingURL=BrsFile.spec.js.map