brighterscript 1.0.0-alpha.10 → 1.0.0-alpha.14

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 (299) hide show
  1. package/CHANGELOG.md +247 -267
  2. package/README.md +2 -2
  3. package/dist/Cache.d.ts +3 -3
  4. package/dist/Cache.js +10 -6
  5. package/dist/Cache.js.map +1 -1
  6. package/dist/CodeActionUtil.js.map +1 -1
  7. package/dist/CommentFlagProcessor.d.ts +4 -4
  8. package/dist/CommentFlagProcessor.js +5 -3
  9. package/dist/CommentFlagProcessor.js.map +1 -1
  10. package/dist/DependencyGraph.js.map +1 -1
  11. package/dist/DiagnosticFilterer.js +1 -1
  12. package/dist/DiagnosticFilterer.js.map +1 -1
  13. package/dist/LanguageServer.d.ts +1 -6
  14. package/dist/LanguageServer.js +5 -14
  15. package/dist/LanguageServer.js.map +1 -1
  16. package/dist/Logger.js.map +1 -1
  17. package/dist/PluginInterface.d.ts +3 -3
  18. package/dist/PluginInterface.js +3 -0
  19. package/dist/PluginInterface.js.map +1 -1
  20. package/dist/Program.d.ts +35 -20
  21. package/dist/Program.js +132 -67
  22. package/dist/Program.js.map +1 -1
  23. package/dist/ProgramBuilder.js +4 -4
  24. package/dist/ProgramBuilder.js.map +1 -1
  25. package/dist/Scope.d.ts +22 -13
  26. package/dist/Scope.js +85 -70
  27. package/dist/Scope.js.map +1 -1
  28. package/dist/SymbolTable.d.ts +1 -1
  29. package/dist/SymbolTable.js +2 -2
  30. package/dist/SymbolTable.js.map +1 -1
  31. package/dist/XmlScope.d.ts +2 -2
  32. package/dist/XmlScope.js +5 -5
  33. package/dist/XmlScope.js.map +1 -1
  34. package/dist/astUtils/AstEditor.d.ts +27 -0
  35. package/dist/astUtils/AstEditor.js +97 -0
  36. package/dist/astUtils/AstEditor.js.map +1 -0
  37. package/dist/{bscPlugin/semanticTokens/SemanticTokensProcessor.spec.d.ts → astUtils/AstEditor.spec.d.ts} +0 -0
  38. package/dist/astUtils/AstEditor.spec.js +133 -0
  39. package/dist/astUtils/AstEditor.spec.js.map +1 -0
  40. package/dist/astUtils/creators.spec.js +4 -4
  41. package/dist/astUtils/creators.spec.js.map +1 -1
  42. package/dist/astUtils/reflection.d.ts +4 -2
  43. package/dist/astUtils/reflection.js +10 -1
  44. package/dist/astUtils/reflection.js.map +1 -1
  45. package/dist/astUtils/reflection.spec.js +116 -116
  46. package/dist/astUtils/reflection.spec.js.map +1 -1
  47. package/dist/astUtils/stackedVisitor.js.map +1 -1
  48. package/dist/astUtils/stackedVisitor.spec.js +13 -13
  49. package/dist/astUtils/stackedVisitor.spec.js.map +1 -1
  50. package/dist/astUtils/visitors.js +1 -1
  51. package/dist/astUtils/visitors.js.map +1 -1
  52. package/dist/astUtils/visitors.spec.js +26 -26
  53. package/dist/astUtils/visitors.spec.js.map +1 -1
  54. package/dist/astUtils/xml.d.ts +1 -0
  55. package/dist/astUtils/xml.js +6 -1
  56. package/dist/astUtils/xml.js.map +1 -1
  57. package/dist/bscPlugin/BscPlugin.js +5 -2
  58. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  59. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +3 -3
  60. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  61. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +17 -17
  62. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  63. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +8 -0
  64. package/dist/bscPlugin/semanticTokens/{SemanticTokensProcessor.js → BrsFileSemanticTokensProcessor.js} +13 -15
  65. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
  66. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +1 -0
  67. package/dist/bscPlugin/semanticTokens/{SemanticTokensProcessor.spec.js → BrsFileSemanticTokensProcessor.spec.js} +5 -5
  68. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -0
  69. package/dist/diagnosticUtils.d.ts +1 -0
  70. package/dist/diagnosticUtils.js +14 -7
  71. package/dist/diagnosticUtils.js.map +1 -1
  72. package/dist/examples/plugins/removePrint.js +2 -2
  73. package/dist/examples/plugins/removePrint.js.map +1 -1
  74. package/dist/files/BrsFile.Class.spec.js +444 -269
  75. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  76. package/dist/files/BrsFile.d.ts +17 -11
  77. package/dist/files/BrsFile.js +220 -153
  78. package/dist/files/BrsFile.js.map +1 -1
  79. package/dist/files/BrsFile.spec.js +620 -272
  80. package/dist/files/BrsFile.spec.js.map +1 -1
  81. package/dist/files/XmlFile.d.ts +6 -5
  82. package/dist/files/XmlFile.js +14 -9
  83. package/dist/files/XmlFile.js.map +1 -1
  84. package/dist/files/XmlFile.spec.js +238 -191
  85. package/dist/files/XmlFile.spec.js.map +1 -1
  86. package/dist/files/tests/imports.spec.js +29 -27
  87. package/dist/files/tests/imports.spec.js.map +1 -1
  88. package/dist/globalCallables.d.ts +3 -1
  89. package/dist/globalCallables.js +198 -99
  90. package/dist/globalCallables.js.map +1 -1
  91. package/dist/index.d.ts +12 -3
  92. package/dist/index.js +22 -4
  93. package/dist/index.js.map +1 -1
  94. package/dist/interfaces.d.ts +71 -10
  95. package/dist/lexer/Lexer.d.ts +5 -1
  96. package/dist/lexer/Lexer.js +52 -35
  97. package/dist/lexer/Lexer.js.map +1 -1
  98. package/dist/lexer/Lexer.spec.js +564 -534
  99. package/dist/lexer/Lexer.spec.js.map +1 -1
  100. package/dist/lexer/TokenKind.d.ts +4 -0
  101. package/dist/lexer/TokenKind.js +44 -1
  102. package/dist/lexer/TokenKind.js.map +1 -1
  103. package/dist/parser/Expression.d.ts +1 -1
  104. package/dist/parser/Expression.js +66 -66
  105. package/dist/parser/Expression.js.map +1 -1
  106. package/dist/parser/Parser.Class.spec.js +107 -106
  107. package/dist/parser/Parser.Class.spec.js.map +1 -1
  108. package/dist/parser/Parser.d.ts +17 -5
  109. package/dist/parser/Parser.js +431 -315
  110. package/dist/parser/Parser.js.map +1 -1
  111. package/dist/parser/Parser.spec.js +418 -296
  112. package/dist/parser/Parser.spec.js.map +1 -1
  113. package/dist/parser/SGParser.js +2 -2
  114. package/dist/parser/SGParser.js.map +1 -1
  115. package/dist/parser/SGParser.spec.js +22 -22
  116. package/dist/parser/SGParser.spec.js.map +1 -1
  117. package/dist/parser/SGTypes.d.ts +3 -0
  118. package/dist/parser/SGTypes.js +12 -7
  119. package/dist/parser/SGTypes.js.map +1 -1
  120. package/dist/parser/SGTypes.spec.js +84 -84
  121. package/dist/parser/SGTypes.spec.js.map +1 -1
  122. package/dist/parser/Statement.d.ts +3 -3
  123. package/dist/parser/Statement.js +61 -61
  124. package/dist/parser/Statement.js.map +1 -1
  125. package/dist/parser/Statement.spec.js +10 -10
  126. package/dist/parser/Statement.spec.js.map +1 -1
  127. package/dist/parser/tests/Parser.spec.d.ts +3 -3
  128. package/dist/parser/tests/Parser.spec.js +4 -4
  129. package/dist/parser/tests/Parser.spec.js.map +1 -1
  130. package/dist/parser/tests/controlFlow/For.spec.js +58 -58
  131. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  132. package/dist/parser/tests/controlFlow/ForEach.spec.js +40 -39
  133. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  134. package/dist/parser/tests/controlFlow/If.spec.js +201 -200
  135. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  136. package/dist/parser/tests/controlFlow/While.spec.js +37 -37
  137. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  138. package/dist/parser/tests/expression/Additive.spec.js +30 -30
  139. package/dist/parser/tests/expression/Additive.spec.js.map +1 -1
  140. package/dist/parser/tests/expression/ArrayLiterals.spec.js +119 -119
  141. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  142. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +141 -141
  143. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  144. package/dist/parser/tests/expression/Boolean.spec.js +24 -24
  145. package/dist/parser/tests/expression/Boolean.spec.js.map +1 -1
  146. package/dist/parser/tests/expression/Call.spec.js +41 -40
  147. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  148. package/dist/parser/tests/expression/Exponential.spec.js +17 -17
  149. package/dist/parser/tests/expression/Exponential.spec.js.map +1 -1
  150. package/dist/parser/tests/expression/Function.spec.js +256 -256
  151. package/dist/parser/tests/expression/Function.spec.js.map +1 -1
  152. package/dist/parser/tests/expression/Indexing.spec.js +87 -87
  153. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  154. package/dist/parser/tests/expression/Multiplicative.spec.js +37 -37
  155. package/dist/parser/tests/expression/Multiplicative.spec.js.map +1 -1
  156. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +74 -62
  157. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  158. package/dist/parser/tests/expression/PrefixUnary.spec.js +41 -41
  159. package/dist/parser/tests/expression/PrefixUnary.spec.js.map +1 -1
  160. package/dist/parser/tests/expression/Primary.spec.js +41 -41
  161. package/dist/parser/tests/expression/Primary.spec.js.map +1 -1
  162. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +110 -2
  163. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  164. package/dist/parser/tests/expression/Relational.spec.js +43 -43
  165. package/dist/parser/tests/expression/Relational.spec.js.map +1 -1
  166. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +6 -6
  167. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  168. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +18 -18
  169. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  170. package/dist/parser/tests/expression/TernaryExpression.spec.js +100 -100
  171. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  172. package/dist/parser/tests/statement/AssignmentOperators.spec.js +36 -36
  173. package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +1 -1
  174. package/dist/parser/tests/statement/Declaration.spec.js +44 -44
  175. package/dist/parser/tests/statement/Declaration.spec.js.map +1 -1
  176. package/dist/parser/tests/statement/Dim.spec.js +21 -21
  177. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  178. package/dist/parser/tests/statement/Function.spec.js +198 -197
  179. package/dist/parser/tests/statement/Function.spec.js.map +1 -1
  180. package/dist/parser/tests/statement/Goto.spec.js +15 -14
  181. package/dist/parser/tests/statement/Goto.spec.js.map +1 -1
  182. package/dist/parser/tests/statement/Increment.spec.js +50 -50
  183. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  184. package/dist/parser/tests/statement/InterfaceStatement.spec.js +14 -2
  185. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  186. package/dist/parser/tests/statement/LibraryStatement.spec.js +17 -17
  187. package/dist/parser/tests/statement/LibraryStatement.spec.js.map +1 -1
  188. package/dist/parser/tests/statement/Misc.spec.js +91 -90
  189. package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
  190. package/dist/parser/tests/statement/PrintStatement.spec.js +34 -34
  191. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  192. package/dist/parser/tests/statement/ReturnStatement.spec.js +46 -46
  193. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  194. package/dist/parser/tests/statement/Set.spec.js +83 -83
  195. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  196. package/dist/parser/tests/statement/Stop.spec.js +12 -11
  197. package/dist/parser/tests/statement/Stop.spec.js.map +1 -1
  198. package/dist/parser/tests/statement/Throw.spec.js +5 -5
  199. package/dist/parser/tests/statement/Throw.spec.js.map +1 -1
  200. package/dist/parser/tests/statement/TryCatch.spec.js +13 -13
  201. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  202. package/dist/preprocessor/Chunk.d.ts +1 -1
  203. package/dist/preprocessor/Chunk.js.map +1 -1
  204. package/dist/preprocessor/Manifest.d.ts +1 -1
  205. package/dist/preprocessor/Preprocessor.d.ts +1 -1
  206. package/dist/preprocessor/Preprocessor.js +8 -8
  207. package/dist/preprocessor/Preprocessor.js.map +1 -1
  208. package/dist/preprocessor/Preprocessor.spec.js +49 -49
  209. package/dist/preprocessor/Preprocessor.spec.js.map +1 -1
  210. package/dist/preprocessor/PreprocessorParser.spec.js +72 -72
  211. package/dist/preprocessor/PreprocessorParser.spec.js.map +1 -1
  212. package/dist/types/ArrayType.d.ts +8 -5
  213. package/dist/types/ArrayType.js +48 -12
  214. package/dist/types/ArrayType.js.map +1 -1
  215. package/dist/types/ArrayType.spec.js +69 -10
  216. package/dist/types/ArrayType.spec.js.map +1 -1
  217. package/dist/types/BooleanType.js +3 -3
  218. package/dist/types/BooleanType.js.map +1 -1
  219. package/dist/types/BooleanType.spec.js +2 -2
  220. package/dist/types/BooleanType.spec.js.map +1 -1
  221. package/dist/types/BscType.d.ts +1 -1
  222. package/dist/types/BscType.js +1 -1
  223. package/dist/types/BscType.js.map +1 -1
  224. package/dist/types/CustomType.d.ts +1 -1
  225. package/dist/types/CustomType.js +6 -4
  226. package/dist/types/CustomType.js.map +1 -1
  227. package/dist/types/DoubleType.js +7 -7
  228. package/dist/types/DoubleType.js.map +1 -1
  229. package/dist/types/DoubleType.spec.js +2 -2
  230. package/dist/types/DoubleType.spec.js.map +1 -1
  231. package/dist/types/DynamicType.js +1 -1
  232. package/dist/types/DynamicType.js.map +1 -1
  233. package/dist/types/DynamicType.spec.js +2 -2
  234. package/dist/types/DynamicType.spec.js.map +1 -1
  235. package/dist/types/FloatType.js +7 -7
  236. package/dist/types/FloatType.js.map +1 -1
  237. package/dist/types/FloatType.spec.js +2 -2
  238. package/dist/types/FloatType.spec.js.map +1 -1
  239. package/dist/types/FunctionType.d.ts +5 -5
  240. package/dist/types/FunctionType.js +13 -13
  241. package/dist/types/FunctionType.js.map +1 -1
  242. package/dist/types/FunctionType.spec.js +7 -7
  243. package/dist/types/FunctionType.spec.js.map +1 -1
  244. package/dist/types/IntegerType.js +7 -7
  245. package/dist/types/IntegerType.js.map +1 -1
  246. package/dist/types/IntegerType.spec.js +2 -2
  247. package/dist/types/IntegerType.spec.js.map +1 -1
  248. package/dist/types/InterfaceType.js +3 -3
  249. package/dist/types/InterfaceType.js.map +1 -1
  250. package/dist/types/InterfaceType.spec.js +7 -7
  251. package/dist/types/InterfaceType.spec.js.map +1 -1
  252. package/dist/types/InvalidType.js +4 -4
  253. package/dist/types/InvalidType.js.map +1 -1
  254. package/dist/types/InvalidType.spec.js +2 -2
  255. package/dist/types/InvalidType.spec.js.map +1 -1
  256. package/dist/types/LazyType.d.ts +1 -2
  257. package/dist/types/LazyType.js +1 -5
  258. package/dist/types/LazyType.js.map +1 -1
  259. package/dist/types/LongIntegerType.js +8 -8
  260. package/dist/types/LongIntegerType.js.map +1 -1
  261. package/dist/types/LongIntegerType.spec.js +2 -2
  262. package/dist/types/LongIntegerType.spec.js.map +1 -1
  263. package/dist/types/ObjectType.js +3 -3
  264. package/dist/types/ObjectType.js.map +1 -1
  265. package/dist/types/ObjectType.spec.js +2 -2
  266. package/dist/types/ObjectType.spec.js.map +1 -1
  267. package/dist/types/StringType.js +3 -3
  268. package/dist/types/StringType.js.map +1 -1
  269. package/dist/types/StringType.spec.js +2 -2
  270. package/dist/types/StringType.spec.js.map +1 -1
  271. package/dist/types/UninitializedType.js +3 -3
  272. package/dist/types/UninitializedType.js.map +1 -1
  273. package/dist/types/VoidType.js +3 -3
  274. package/dist/types/VoidType.js.map +1 -1
  275. package/dist/types/VoidType.spec.js +2 -2
  276. package/dist/types/VoidType.spec.js.map +1 -1
  277. package/dist/types/helpers.js +6 -6
  278. package/dist/types/helpers.js.map +1 -1
  279. package/dist/util.d.ts +15 -9
  280. package/dist/util.js +104 -57
  281. package/dist/util.js.map +1 -1
  282. package/dist/validators/ClassValidator.js +40 -40
  283. package/dist/validators/ClassValidator.js.map +1 -1
  284. package/package.json +10 -9
  285. package/dist/astUtils/index.d.ts +0 -7
  286. package/dist/astUtils/index.js +0 -26
  287. package/dist/astUtils/index.js.map +0 -1
  288. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.d.ts +0 -7
  289. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js.map +0 -1
  290. package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +0 -1
  291. package/dist/lexer/index.d.ts +0 -3
  292. package/dist/lexer/index.js +0 -17
  293. package/dist/lexer/index.js.map +0 -1
  294. package/dist/parser/index.d.ts +0 -3
  295. package/dist/parser/index.js +0 -16
  296. package/dist/parser/index.js.map +0 -1
  297. package/dist/preprocessor/index.d.ts +0 -3
  298. package/dist/preprocessor/index.js +0 -16
  299. package/dist/preprocessor/index.js.map +0 -1
@@ -14,10 +14,10 @@ const assert_1 = require("assert");
14
14
  const reflection_1 = require("../astUtils/reflection");
15
15
  let sinon = sinonImport.createSandbox();
16
16
  describe('BrsFile BrighterScript classes', () => {
17
- let tmpPath = util_1.standardizePath `${process.cwd()}/.tmp`;
18
- let rootDir = util_1.standardizePath `${tmpPath}/rootDir`;
17
+ let tmpPath = (0, util_1.standardizePath) `${process.cwd()}/.tmp`;
18
+ let rootDir = (0, util_1.standardizePath) `${tmpPath}/rootDir`;
19
19
  let program;
20
- let testTranspile = testHelpers_spec_1.getTestTranspile(() => [program, rootDir]);
20
+ let testTranspile = (0, testHelpers_spec_1.getTestTranspile)(() => [program, rootDir]);
21
21
  beforeEach(() => {
22
22
  fsExtra.ensureDirSync(rootDir);
23
23
  fsExtra.emptyDirSync(tmpPath);
@@ -41,7 +41,7 @@ describe('BrsFile BrighterScript classes', () => {
41
41
 
42
42
  end class
43
43
  `);
44
- chai_1.expect(file.parser.references.classStatements.map(x => x.getName(Parser_1.ParseMode.BrighterScript)).sort()).to.eql(['Animal', 'Duck']);
44
+ (0, chai_1.expect)(file.parser.references.classStatements.map(x => x.getName(Parser_1.ParseMode.BrighterScript)).sort()).to.eql(['Animal', 'Duck']);
45
45
  });
46
46
  it('does not cause errors with incomplete class statement', () => {
47
47
  program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
@@ -51,7 +51,6 @@ describe('BrsFile BrighterScript classes', () => {
51
51
  //if no exception was thrown, this test passes
52
52
  });
53
53
  it('catches child class missing super call in constructor', () => {
54
- var _a;
55
54
  program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
56
55
  class Person
57
56
  sub new()
@@ -63,10 +62,11 @@ describe('BrsFile BrighterScript classes', () => {
63
62
  end class
64
63
  `);
65
64
  program.validate();
66
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall().message);
65
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
66
+ DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall()
67
+ ]);
67
68
  });
68
69
  it('access modifier is option for override', () => {
69
- var _a;
70
70
  let file = program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
71
71
  class Animal
72
72
  sub move()
@@ -79,13 +79,12 @@ describe('BrsFile BrighterScript classes', () => {
79
79
  end class
80
80
  `);
81
81
  program.validate();
82
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
82
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
83
83
  let duckClass = file.parser.references.classStatements.find(x => x.name.text.toLowerCase() === 'duck');
84
- chai_1.expect(duckClass).to.exist;
85
- chai_1.expect(duckClass.memberMap['move']).to.exist;
84
+ (0, chai_1.expect)(duckClass).to.exist;
85
+ (0, chai_1.expect)(duckClass.memberMap['move']).to.exist;
86
86
  });
87
87
  it('supports various namespace configurations', () => {
88
- var _a;
89
88
  program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
90
89
  class Animal
91
90
  sub new()
@@ -106,11 +105,10 @@ describe('BrsFile BrighterScript classes', () => {
106
105
  end namespace
107
106
  `);
108
107
  program.validate();
109
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
108
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
110
109
  });
111
110
  describe('super', () => {
112
111
  it('always requires super call in child constructor', () => {
113
- var _a;
114
112
  program.setFile('source/main.bs', `
115
113
  class Bird
116
114
  end class
@@ -120,10 +118,11 @@ describe('BrsFile BrighterScript classes', () => {
120
118
  end class
121
119
  `);
122
120
  program.validate();
123
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.eql(DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall().message);
121
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
122
+ DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall()
123
+ ]);
124
124
  });
125
125
  it('requires super call in child when parent has own `new` method', () => {
126
- var _a;
127
126
  program.setFile('source/main.bs', `
128
127
  class Bird
129
128
  sub new()
@@ -135,10 +134,11 @@ describe('BrsFile BrighterScript classes', () => {
135
134
  end class
136
135
  `);
137
136
  program.validate();
138
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.eql(DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall().message);
137
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
138
+ DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall()
139
+ ]);
139
140
  });
140
141
  it('allows non-`m` expressions and statements before the super call', () => {
141
- var _a;
142
142
  program.setFile('source/main.bs', `
143
143
  class Bird
144
144
  sub new(name)
@@ -154,7 +154,7 @@ describe('BrsFile BrighterScript classes', () => {
154
154
  end class
155
155
  `);
156
156
  program.validate();
157
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.be.undefined;
157
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
158
158
  });
159
159
  it('allows non-`m` expressions and statements before the super call', () => {
160
160
  program.setFile('source/main.bs', `
@@ -170,13 +170,7 @@ describe('BrsFile BrighterScript classes', () => {
170
170
  end class
171
171
  `);
172
172
  program.validate();
173
- chai_1.expect(program.getDiagnostics().map(x => ({ message: x.message, range: x.range }))).to.eql([{
174
- message: DiagnosticMessages_1.DiagnosticMessages.classConstructorIllegalUseOfMBeforeSuperCall().message,
175
- range: vscode_languageserver_1.Range.create(7, 24, 7, 25)
176
- }, {
177
- message: DiagnosticMessages_1.DiagnosticMessages.classConstructorIllegalUseOfMBeforeSuperCall().message,
178
- range: vscode_languageserver_1.Range.create(7, 33, 7, 34)
179
- }]);
173
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.classConstructorIllegalUseOfMBeforeSuperCall()), { range: vscode_languageserver_1.Range.create(7, 24, 7, 25) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.classConstructorIllegalUseOfMBeforeSuperCall()), { range: vscode_languageserver_1.Range.create(7, 33, 7, 34) })]);
180
174
  });
181
175
  });
182
176
  describe('transpile', () => {
@@ -666,8 +660,7 @@ describe('BrsFile BrighterScript classes', () => {
666
660
  });
667
661
  });
668
662
  it('detects using `new` keyword on non-classes', () => {
669
- var _a;
670
- program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
663
+ program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.brs' }, `
671
664
  sub quack()
672
665
  end sub
673
666
  sub main()
@@ -675,37 +668,41 @@ describe('BrsFile BrighterScript classes', () => {
675
668
  end sub
676
669
  `);
677
670
  program.validate();
678
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.expressionIsNotConstructable('sub').message);
671
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
672
+ DiagnosticMessages_1.DiagnosticMessages.expressionIsNotConstructable('sub')
673
+ ]);
679
674
  });
680
675
  it('detects missing call to super', () => {
681
- var _a;
682
- program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
676
+ program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.brs' }, `
683
677
  class Animal
684
- sub new()
678
+ sub new ()
685
679
  end sub
686
680
  end class
687
681
  class Duck extends Animal
688
- sub new()
682
+ sub new ()
689
683
  end sub
690
684
  end class
691
685
  `);
692
686
  program.validate();
693
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall().message);
687
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
688
+ DiagnosticMessages_1.DiagnosticMessages.classConstructorMissingSuperCall()
689
+ ]);
694
690
  });
695
691
  it.skip('detects calls to unknown m methods', () => {
696
- var _a;
697
- program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
692
+ program.setFile({ src: `$ { rootDir } / source / main.brs`, dest: 'source/main.brs' }, `
698
693
  class Animal
699
- sub new()
694
+ sub new ()
700
695
  m.methodThatDoesNotExist()
701
696
  end sub
702
697
  end class
703
698
  `);
704
699
  program.validate();
705
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.methodDoesNotExistOnType('methodThatDoesNotExist', 'Animal'));
700
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
701
+ DiagnosticMessages_1.DiagnosticMessages.methodDoesNotExistOnType('methodThatDoesNotExist', 'Animal')
702
+ ]);
706
703
  });
707
704
  it('detects duplicate member names', () => {
708
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
705
+ program.setFile({ src: `${rootDir} / source / main.bs`, dest: 'source/main.bs' }, `
709
706
  class Animal
710
707
  public name
711
708
  public name
@@ -719,33 +716,27 @@ describe('BrsFile BrighterScript classes', () => {
719
716
  end class
720
717
  `);
721
718
  program.validate();
722
- let diagnostics = program.getDiagnostics().map(x => {
723
- return {
724
- code: x.code,
725
- message: x.message,
726
- range: x.range,
727
- severity: vscode_languageserver_1.DiagnosticSeverity.Error
728
- };
729
- });
730
- chai_1.expect(diagnostics).to.eql([Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('name')), { range: vscode_languageserver_1.Range.create(3, 23, 3, 27) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('name')), { range: vscode_languageserver_1.Range.create(4, 27, 4, 31) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('age')), { range: vscode_languageserver_1.Range.create(8, 27, 8, 30) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('age')), { range: vscode_languageserver_1.Range.create(10, 23, 10, 26) })]);
719
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('name')), { range: vscode_languageserver_1.Range.create(3, 23, 3, 27) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('name')), { range: vscode_languageserver_1.Range.create(4, 27, 4, 31) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('age')), { range: vscode_languageserver_1.Range.create(8, 27, 8, 30) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.duplicateIdentifier('age')), { range: vscode_languageserver_1.Range.create(10, 23, 10, 26) })]);
731
720
  });
732
721
  it('detects mismatched member type in child class', () => {
733
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
722
+ program.setFile({ src: `${rootDir} / source / main.bs`, dest: 'source/main.bs' }, `
734
723
  class Animal
735
724
  public name
736
725
  end class
737
726
  class Duck extends Animal
738
- public function name()
727
+ public override function name()
739
728
  return "Donald"
740
729
  end function
741
730
  end class
742
731
  `);
743
732
  program.validate();
744
- chai_1.expect(program.getDiagnostics().map(x => x.message).sort()[0]).to.eql(DiagnosticMessages_1.DiagnosticMessages.classChildMemberDifferentMemberTypeThanAncestor('method', 'field', 'Animal').message);
733
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
734
+ DiagnosticMessages_1.DiagnosticMessages.classChildMemberDifferentMemberTypeThanAncestor('method', 'field', 'Animal')
735
+ ]);
745
736
  });
746
737
  it('allows untyped overridden field in child class', () => {
747
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
748
- class Animal
738
+ program.setFile({ src: `${rootDir} /source/main.bs`, dest: 'source/main.bs' }, `
739
+ class Animal
749
740
  public name
750
741
  end class
751
742
  class Duck extends Animal
@@ -753,7 +744,7 @@ describe('BrsFile BrighterScript classes', () => {
753
744
  end class
754
745
  `);
755
746
  program.validate();
756
- testHelpers_spec_1.expectZeroDiagnostics(program);
747
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
757
748
  });
758
749
  it('allows overridden property name in child class', () => {
759
750
  program.setFile('source/main.bs', `
@@ -765,7 +756,7 @@ describe('BrsFile BrighterScript classes', () => {
765
756
  end class
766
757
  `);
767
758
  program.validate();
768
- testHelpers_spec_1.expectZeroDiagnostics(program);
759
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
769
760
  });
770
761
  it('flags incompatible child field type changes', () => {
771
762
  program.setFile('source/main.bs', `
@@ -781,15 +772,15 @@ describe('BrsFile BrighterScript classes', () => {
781
772
  end class
782
773
  `);
783
774
  program.validate();
784
- chai_1.expect(program.getDiagnostics().map(x => x.message).sort()).to.eql([
785
- DiagnosticMessages_1.DiagnosticMessages.cannotFindType('Person').message,
786
- DiagnosticMessages_1.DiagnosticMessages.childFieldTypeNotAssignableToBaseProperty('Duck', 'Bird', 'age', 'float', 'integer').message,
787
- DiagnosticMessages_1.DiagnosticMessages.childFieldTypeNotAssignableToBaseProperty('Duck', 'Bird', 'name', 'integer', 'string').message,
788
- DiagnosticMessages_1.DiagnosticMessages.childFieldTypeNotAssignableToBaseProperty('Duck', 'Bird', 'owner', 'string', 'Person').message
775
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
776
+ DiagnosticMessages_1.DiagnosticMessages.cannotFindType('Person'),
777
+ DiagnosticMessages_1.DiagnosticMessages.childFieldTypeNotAssignableToBaseProperty('Duck', 'Bird', 'age', 'float', 'integer'),
778
+ DiagnosticMessages_1.DiagnosticMessages.childFieldTypeNotAssignableToBaseProperty('Duck', 'Bird', 'name', 'integer', 'string'),
779
+ DiagnosticMessages_1.DiagnosticMessages.childFieldTypeNotAssignableToBaseProperty('Duck', 'Bird', 'owner', 'string', 'Person')
789
780
  ]);
790
781
  });
791
782
  it('detects overridden methods without override keyword', () => {
792
- program.setFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, `
783
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.brs' }, `
793
784
  class Animal
794
785
  sub speak()
795
786
  end sub
@@ -800,10 +791,12 @@ describe('BrsFile BrighterScript classes', () => {
800
791
  end class
801
792
  `);
802
793
  program.validate();
803
- chai_1.expect(program.getDiagnostics()[0]).to.exist.and.to.include(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.missingOverrideKeyword('Animal')));
794
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
795
+ DiagnosticMessages_1.DiagnosticMessages.missingOverrideKeyword('Animal')
796
+ ]);
804
797
  });
805
798
  it('detects overridden methods with different visibility', () => {
806
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
799
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
807
800
  class Animal
808
801
  sub speakInPublic()
809
802
  end sub
@@ -822,12 +815,14 @@ describe('BrsFile BrighterScript classes', () => {
822
815
  end class
823
816
  `);
824
817
  program.validate();
825
- chai_1.expect(program.getDiagnostics()[0]).to.exist.and.to.include(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedOverriddenMemberVisibility('Duck', 'speakInPublic', 'private', 'public', 'Animal')));
826
- chai_1.expect(program.getDiagnostics()[1]).to.exist.and.to.include(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedOverriddenMemberVisibility('Duck', 'speakWithFriends', 'public', 'protected', 'Animal')));
827
- chai_1.expect(program.getDiagnostics()[2]).to.exist.and.to.include(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedOverriddenMemberVisibility('Duck', 'speakWithFamily', 'public', 'private', 'Animal')));
818
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
819
+ DiagnosticMessages_1.DiagnosticMessages.mismatchedOverriddenMemberVisibility('Duck', 'speakInPublic', 'private', 'public', 'Animal'),
820
+ DiagnosticMessages_1.DiagnosticMessages.mismatchedOverriddenMemberVisibility('Duck', 'speakWithFriends', 'public', 'protected', 'Animal'),
821
+ DiagnosticMessages_1.DiagnosticMessages.mismatchedOverriddenMemberVisibility('Duck', 'speakWithFamily', 'public', 'private', 'Animal')
822
+ ]);
828
823
  });
829
824
  it('allows overridden methods with matching visibility', () => {
830
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
825
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
831
826
  class Animal
832
827
  sub speakInPublic()
833
828
  end sub
@@ -846,141 +841,224 @@ describe('BrsFile BrighterScript classes', () => {
846
841
  end class
847
842
  `);
848
843
  program.validate();
849
- chai_1.expect(program.getDiagnostics()).to.be.empty;
844
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
850
845
  });
851
- it('detects extending unknown parent class', () => {
852
- program.setFile('source/main.brs', `
853
- class Duck extends Animal
854
- sub speak()
855
- end sub
856
- end class
857
- `);
858
- program.validate();
859
- chai_1.expect(program.getDiagnostics()[0]).to.exist.and.to.deep.include(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Animal', 'source')), { range: vscode_languageserver_1.Range.create(1, 31, 1, 37) }));
846
+ describe('detects unknown parent class', () => {
847
+ it('non-namespaced parent from outside namespace', () => {
848
+ program.setFile('source/main.bs', `
849
+ class Duck extends Animal
850
+ sub speak()
851
+ end sub
852
+ end class
853
+
854
+ namespace Vertibrates
855
+ class Animal
856
+ end class
857
+ end namespace
858
+ `);
859
+ program.validate();
860
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Animal', 'source')), { range: vscode_languageserver_1.Range.create(1, 35, 1, 41) })]);
861
+ });
862
+ it('non-namespaced parent from within namespace', () => {
863
+ program.setFile('source/main.bs', `
864
+ namespace Vertibrates
865
+ class Duck extends Animal
866
+ sub speak()
867
+ end sub
868
+ end class
869
+ end namespace
870
+ `);
871
+ program.validate();
872
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
873
+ DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Animal', 'source')
874
+ ]);
875
+ });
876
+ it('non-namespaced name from outside namespace alongside existing namespace', () => {
877
+ program.setFile('source/main.bs', `
878
+ namespace Vertibrates
879
+ class Animal
880
+ end class
881
+ end namespace
882
+
883
+ class Duck extends Animal
884
+ sub speak()
885
+ end sub
886
+ end class
887
+ `);
888
+ program.validate();
889
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
890
+ DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Animal', 'source')
891
+ ]);
892
+ });
893
+ it('namespaced parent class from outside namespace', () => {
894
+ program.setFile('source/vertibrates.bs', `
895
+ namespace Vertibrates
896
+ class Bird
897
+ end class
898
+ end namespace
899
+ `);
900
+ program.setFile('source/Duck.bs', `
901
+ class Duck extends Vertibrates.GroundedBird
902
+ sub speak()
903
+ end sub
904
+ end class
905
+ `);
906
+ program.validate();
907
+ //TODO replace this with `expectDiagnostics` once we fix the duplicate diagnostic one-per-file for missing base classes issue
908
+ (0, chai_1.expect)(program.getDiagnostics()[0].message).to.eql(DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Vertibrates.GroundedBird', 'source').message);
909
+ });
910
+ it('namespaced parent class from inside namespace', () => {
911
+ program.setFile('source/main.bs', ``);
912
+ program.setFile('source/vertibrates.bs', `
913
+ namespace Vertibrates
914
+ class Bird
915
+ end class
916
+ end namespace
917
+ `);
918
+ program.setFile('source/Duck.bs', `
919
+ namespace Birdies
920
+ class Duck extends Vertibrates.GroundedBird
921
+ sub speak()
922
+ end sub
923
+ end class
924
+ end namespace
925
+ `);
926
+ program.validate();
927
+ //TODO replace this with `expectDiagnostics` once we fix the duplicate diagnostic one-per-file for missing base classes issue
928
+ (0, chai_1.expect)(program.getDiagnostics()[0].message).to.eql(DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Vertibrates.GroundedBird', 'source').message);
929
+ });
860
930
  });
861
931
  it('catches newable class without namespace name', () => {
862
- var _a;
863
932
  program.setFile('source/main.bs', `
864
933
  namespace NameA.NameB
865
934
  class Duck
866
935
  end class
867
- end namespace
936
+ end namespace
868
937
  sub main()
869
938
  ' this should be an error because the proper name is NameA.NameB.Duck"
870
939
  d = new Duck()
871
940
  end sub
872
- `);
941
+ `);
873
942
  program.validate();
874
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Duck', 'source').message);
943
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
944
+ DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('Duck', 'source')
945
+ ]);
875
946
  });
876
947
  it('supports newable class namespace inference', () => {
877
- var _a;
878
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
948
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
879
949
  namespace NameA.NameB
880
950
  class Duck
881
951
  end class
882
- sub main()
952
+ sub main()
883
953
  d = new Duck()
884
954
  end sub
885
955
  end namespace
886
- `);
956
+ `);
887
957
  program.validate();
888
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
958
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
889
959
  });
890
960
  it('catches extending unknown namespaced class', () => {
891
- var _a;
892
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
961
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
893
962
  namespace NameA.NameB
894
963
  class Animal
895
964
  end class
896
965
  class Duck extends NameA.NameB.Animal1
897
966
  end class
898
- end namespace
899
- `);
967
+ end namespace
968
+ `);
900
969
  program.validate();
901
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('NameA.NameB.Animal1', 'source').message);
970
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
971
+ DiagnosticMessages_1.DiagnosticMessages.classCouldNotBeFound('NameA.NameB.Animal1', 'source')
972
+ ]);
902
973
  });
903
974
  it('supports omitting namespace prefix for items in same namespace', () => {
904
- var _a;
905
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
975
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
906
976
  namespace NameA.NameB
907
977
  class Animal
908
978
  end class
909
979
  class Duck extends Animal
910
980
  end class
911
- end namespace
912
- `);
981
+ end namespace
982
+ `);
913
983
  program.validate();
914
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).not.to.exist;
984
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
915
985
  });
916
986
  it('catches duplicate root-level class declarations', () => {
917
- var _a;
918
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
987
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
919
988
  class Animal
920
989
  end class
921
990
  class Animal
991
+ end class
922
992
  `);
923
993
  program.validate();
924
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.duplicateClassDeclaration('source', 'Animal').message);
994
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
995
+ DiagnosticMessages_1.DiagnosticMessages.duplicateClassDeclaration('source', 'Animal')
996
+ ]);
925
997
  });
926
998
  it('catches duplicate namespace-level class declarations', () => {
927
- var _a;
928
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
999
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
929
1000
  namespace NameA.NameB
930
1001
  class Animal
931
1002
  end class
932
1003
  class Animal
933
- end namespace
934
- `);
1004
+ end class
1005
+ end namespace
1006
+ `);
935
1007
  program.validate();
936
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.duplicateClassDeclaration('source', 'NameA.NameB.Animal').message);
1008
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
1009
+ DiagnosticMessages_1.DiagnosticMessages.duplicateClassDeclaration('source', 'NameA.NameB.Animal')
1010
+ ]);
937
1011
  });
938
1012
  it('catches namespaced class name which is the same as a global class', () => {
939
- var _a;
940
- program.setFile({ src: `${rootDir}/source/main.bs`, dest: 'source/main.bs' }, `
1013
+ program.setFile({ src: `$ { rootDir }/source/main.bs`, dest: 'source/main.bs' }, `
941
1014
  namespace NameA.NameB
942
1015
  class Animal
943
1016
  end class
944
- end namespace
1017
+ end namespace
945
1018
  class Animal
946
1019
  end class
947
1020
  `);
948
1021
  program.validate();
949
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.namespacedClassCannotShareNamewithNonNamespacedClass('Animal').message);
1022
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
1023
+ DiagnosticMessages_1.DiagnosticMessages.namespacedClassCannotShareNamewithNonNamespacedClass('Animal').message
1024
+ ]);
950
1025
  });
951
1026
  it('catches class with same name as function', () => {
952
- var _a;
953
1027
  program.setFile('source/main.bs', `
954
1028
  class Animal
955
1029
  end class
956
- sub Animal()
1030
+ sub Animal()
957
1031
  end sub
958
- `);
1032
+ `);
959
1033
  program.validate();
960
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass('Animal').message);
1034
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
1035
+ DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass('Animal').message
1036
+ ]);
961
1037
  });
962
1038
  it('catches class with same name (but different case) as function', () => {
963
- var _a;
964
1039
  program.setFile('source/main.bs', `
965
1040
  class ANIMAL
966
1041
  end class
967
- sub animal()
1042
+ sub animal()
968
1043
  end sub
969
- `);
1044
+ `);
970
1045
  program.validate();
971
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass('animal').message);
1046
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
1047
+ DiagnosticMessages_1.DiagnosticMessages.functionCannotHaveSameNameAsClass('animal').message
1048
+ ]);
972
1049
  });
973
1050
  it('catches variable with same name as class', () => {
974
- var _a;
975
1051
  program.setFile('source/main.bs', `
976
1052
  class Animal
977
1053
  end class
978
- sub main()
1054
+ sub main()
979
1055
  animal = new Animal()
980
1056
  end sub
981
- `);
1057
+ `);
982
1058
  program.validate();
983
- chai_1.expect((_a = program.getDiagnostics()[0]) === null || _a === void 0 ? void 0 : _a.message).to.equal(DiagnosticMessages_1.DiagnosticMessages.localVarSameNameAsClass('Animal').message);
1059
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
1060
+ DiagnosticMessages_1.DiagnosticMessages.localVarSameNameAsClass('Animal').message
1061
+ ]);
984
1062
  });
985
1063
  it('allows extending classes with more than one dot in the filename', () => {
986
1064
  program.setFile('source/testclass.bs', `
@@ -988,27 +1066,27 @@ describe('BrsFile BrighterScript classes', () => {
988
1066
  end class
989
1067
 
990
1068
  class Bar extends Foo
991
- sub new()
1069
+ sub new ()
992
1070
  super()
993
1071
  end sub
994
1072
  end class
995
1073
  `);
996
1074
  program.setFile('source/testclass_no_testdot.bs', `
997
1075
  class BarNoDot extends Foo
998
- sub new()
1076
+ sub new ()
999
1077
  super()
1000
1078
  end sub
1001
1079
  end class
1002
1080
  `);
1003
1081
  program.setFile('source/testclass.dot.bs', `
1004
1082
  class BarDot extends Foo
1005
- sub new()
1083
+ sub new ()
1006
1084
  super()
1007
1085
  end sub
1008
1086
  end class
1009
1087
  `);
1010
1088
  program.validate();
1011
- testHelpers_spec_1.expectZeroDiagnostics(program);
1089
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
1012
1090
  });
1013
1091
  it('computes correct super index for grandchild class', () => {
1014
1092
  program.setFile('source/main.bs', `
@@ -1027,7 +1105,7 @@ describe('BrsFile BrighterScript classes', () => {
1027
1105
  testTranspile(`
1028
1106
  namespace App
1029
1107
  class ClassC extends ClassB
1030
- sub new()
1108
+ sub new ()
1031
1109
  super()
1032
1110
  end sub
1033
1111
  end class
@@ -1058,7 +1136,7 @@ describe('BrsFile BrighterScript classes', () => {
1058
1136
  class ClassB extends ClassA
1059
1137
  end class
1060
1138
  end namespace
1061
- `, `
1139
+ `, `
1062
1140
  function __App_ClassB_builder()
1063
1141
  instance = __ClassA_builder()
1064
1142
  instance.super0_new = instance.new
@@ -1076,121 +1154,151 @@ describe('BrsFile BrighterScript classes', () => {
1076
1154
  });
1077
1155
  it('does not crash when parent class is missing', () => {
1078
1156
  const file = program.setFile('source/ClassB.bs', `
1079
- class ClassB extends ClassA
1157
+ class ClassB extends ClassA
1080
1158
  end class
1081
1159
  `);
1082
- assert_1.doesNotThrow(() => {
1160
+ (0, assert_1.doesNotThrow)(() => {
1083
1161
  file.parser.references.classStatements[0].getParentClassIndex(new BrsTranspileState_1.BrsTranspileState(file));
1084
1162
  });
1085
1163
  });
1086
1164
  describe('getHover', () => {
1087
1165
  const animalClassCode = `
1088
- class Animal
1089
- kind as string
1090
- isHungry as boolean
1166
+ class Animal
1167
+ kind as string
1168
+ isHungry as boolean
1091
1169
 
1092
- sub new(kind as string)
1093
- m.kind = kind
1094
- m.isHungry = true ' born hungry
1095
- end sub
1170
+ sub new (kind as string)
1171
+ m.kind = kind
1172
+ m.isHungry = true ' born hungry
1173
+ end sub
1096
1174
 
1097
- sub eat(foodAmount as integer)
1098
- if foodAmount > 100
1099
- m.isHungry = false
1100
- end if
1101
- end sub
1175
+ sub eat(foodAmount as integer)
1176
+ if foodAmount > 100
1177
+ m.isHungry = false
1178
+ end if
1179
+ end sub
1102
1180
 
1103
- sub sleep()
1104
- m.isHungry = false
1105
- end sub
1181
+ sub sleep()
1182
+ m.isHungry = false
1183
+ end sub
1106
1184
 
1107
- end class
1185
+ end class
1108
1186
 
1109
- class Dog extends Animal
1110
- breed as string
1111
- sub new(breed as string)
1112
- super("Dog")
1113
- m.breed = breed
1114
- end sub
1187
+ class Dog extends Animal
1188
+ breed as string
1189
+ sub new (breed as string)
1190
+ super("Dog")
1191
+ m.breed = breed
1192
+ end sub
1115
1193
 
1116
- sub snooze()
1117
- m.sleep()
1118
- end sub
1119
- end class
1194
+ sub snooze()
1195
+ m.sleep()
1196
+ end sub
1197
+ end class
1120
1198
 
1121
- class DogHouse
1122
- puppy as Dog
1123
- sub new(pup as Dog)
1124
- m.puppy = pup
1125
- end sub
1126
- end class
1199
+ class DogHouse
1200
+ puppy as Dog
1201
+ sub new (pup as Dog)
1202
+ m.puppy = pup
1203
+ end sub
1204
+ end class
1127
1205
 
1128
- sub main()
1129
- snoopy = new Dog("Beagle")
1130
- biplane = new DogHouse(snoopy)
1131
- print snoopy.kind ' Dog
1132
- print snoopy.breed ' Beagle
1133
- print snoopy.isHungry ' true
1134
- feedAnimal(biplane.puppy)
1135
- print snoopy.isHungry ' false
1136
- end sub
1206
+ sub main()
1207
+ snoopy = new Dog("Beagle")
1208
+ biplane = new DogHouse(snoopy)
1209
+ print snoopy.kind ' Dog
1210
+ print snoopy.breed ' Beagle
1211
+ print snoopy.isHungry ' true
1212
+ feedAnimal(biplane.puppy)
1213
+ print snoopy.isHungry ' false
1214
+ end sub
1137
1215
 
1138
- sub feedAnimal(beast as Animal)
1139
- beast.eat(100)
1140
- end sub
1216
+ sub feedAnimal(beast as Animal)
1217
+ beast.eat(100)
1218
+ end sub
1141
1219
  `;
1142
1220
  it('correctly parses the file', () => {
1143
1221
  program.setFile('source/animal.bs', animalClassCode);
1144
1222
  program.validate();
1145
- chai_1.expect(program.getDiagnostics().length).to.equal(0);
1223
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
1146
1224
  });
1147
1225
  it('gets the correct text for m', () => {
1148
1226
  let animalCode = program.setFile('source/animal.bs', animalClassCode);
1149
1227
  program.validate();
1150
- let hover = animalCode.getHover(vscode_languageserver_1.Position.create(6, 17));
1151
- chai_1.expect(hover).to.exist;
1152
- chai_1.expect(hover.contents).to.equal('m as Animal');
1153
- hover = animalCode.getHover(vscode_languageserver_1.Position.create(26, 17));
1154
- chai_1.expect(hover).to.exist;
1155
- chai_1.expect(hover.contents).to.equal('m as Dog');
1228
+ let hover = animalCode.getHover(vscode_languageserver_1.Position.create(6, 21));
1229
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1230
+ '```brightscript',
1231
+ 'm as Animal',
1232
+ '```'
1233
+ ].join('\n'));
1234
+ hover = animalCode.getHover(vscode_languageserver_1.Position.create(26, 20));
1235
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1236
+ '```brightscript',
1237
+ 'm as Dog',
1238
+ '```'
1239
+ ].join('\n'));
1156
1240
  });
1157
1241
  it('gets the correct text for m.field', () => {
1158
1242
  let animalCode = program.setFile('source/animal.bs', animalClassCode);
1159
1243
  program.validate();
1160
- let hover = animalCode.getHover(vscode_languageserver_1.Position.create(6, 19));
1161
- chai_1.expect(hover).to.exist;
1162
- chai_1.expect(hover.contents).to.equal('Animal.kind as string');
1163
- hover = animalCode.getHover(vscode_languageserver_1.Position.create(26, 19));
1164
- chai_1.expect(hover).to.exist;
1165
- chai_1.expect(hover.contents).to.equal('Dog.breed as string');
1244
+ let hover = animalCode.getHover(vscode_languageserver_1.Position.create(6, 26));
1245
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1246
+ '```brightscript',
1247
+ 'Animal.kind as string',
1248
+ '```'
1249
+ ].join('\n'));
1250
+ hover = animalCode.getHover(vscode_languageserver_1.Position.create(26, 25));
1251
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1252
+ '```brightscript',
1253
+ 'Dog.breed as string',
1254
+ '```'
1255
+ ].join('\n'));
1166
1256
  });
1167
1257
  it('gets the correct text for m.method', () => {
1168
1258
  let animalCode = program.setFile('source/animal.bs', animalClassCode);
1169
1259
  program.validate();
1170
- let hover = animalCode.getHover(vscode_languageserver_1.Position.create(30, 21));
1171
- chai_1.expect(hover).to.exist;
1172
- chai_1.expect(hover.contents).to.equal('sub Animal.sleep() as void');
1260
+ let hover = animalCode.getHover(vscode_languageserver_1.Position.create(30, 25));
1261
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1262
+ '```brightscript',
1263
+ 'sub Animal.sleep() as void',
1264
+ '```'
1265
+ ].join('\n'));
1173
1266
  });
1174
1267
  it('gets the correct text for obj.field', () => {
1175
1268
  let animalCode = program.setFile('source/animal.brs', animalClassCode);
1176
1269
  program.validate();
1177
- let hover = animalCode.getHover(vscode_languageserver_1.Position.create(46, 29));
1178
- chai_1.expect(hover).to.exist;
1270
+ let hover = animalCode.getHover(vscode_languageserver_1.Position.create(46, 33));
1271
+ (0, chai_1.expect)(hover).to.exist;
1179
1272
  //TODO TYPES: This should probably say 'Animal.isHungry ...' because that field is defined in Animal
1180
- chai_1.expect(hover.contents).to.equal('Dog.isHungry as boolean');
1273
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1274
+ '```brightscript',
1275
+ 'Dog.isHungry as boolean',
1276
+ '```'
1277
+ ].join('\n'));
1181
1278
  });
1182
1279
  it('gets the correct text for obj.method', () => {
1183
- let animalCode = program.setFile('source/animal.bs', animalClassCode);
1280
+ let animalCode = program.setFile('source/animal.bs', `
1281
+ sub feedAnimal(beast as Animal)
1282
+ beast.eat(100)
1283
+ end sub
1284
+ class Animal
1285
+ sub eat(foodAmount as integer)
1286
+ end sub
1287
+ end class
1288
+ `);
1184
1289
  program.validate();
1185
- let hover = animalCode.getHover(vscode_languageserver_1.Position.create(52, 21));
1186
- chai_1.expect(hover).to.exist;
1187
- chai_1.expect(hover.contents).to.equal('sub Animal.eat(foodAmount as integer) as void');
1290
+ let hover = animalCode.getHover(vscode_languageserver_1.Position.create(2, 29));
1291
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1292
+ '```brightscript',
1293
+ 'sub Animal.eat(foodAmount as integer) as void',
1294
+ '```'
1295
+ ].join('\n'));
1188
1296
  });
1189
1297
  });
1190
1298
  describe('getHover class members', () => {
1191
1299
  const testCode = `
1192
1300
  class Foo
1193
- sub new(name as string)
1301
+ sub new (name as string)
1194
1302
  end sub
1195
1303
  end class
1196
1304
 
@@ -1202,17 +1310,17 @@ describe('BrsFile BrighterScript classes', () => {
1202
1310
  function getInt() as integer
1203
1311
  return 1
1204
1312
  end function
1205
- end class
1313
+ end class
1206
1314
 
1207
1315
  class Buz
1208
1316
  myInt as integer
1209
- sub new(i as integer)
1210
- myInt = i
1317
+ sub new (i as integer)
1318
+ myInt = i
1211
1319
  end sub
1212
1320
  end class
1213
1321
 
1214
1322
  class Bee extends Buz
1215
- sub new(i as integer)
1323
+ sub new (i as integer)
1216
1324
  super(i)
1217
1325
  end sub
1218
1326
 
@@ -1224,96 +1332,116 @@ describe('BrsFile BrighterScript classes', () => {
1224
1332
  it('correctly parses the file', () => {
1225
1333
  program.setFile('source/fooBar.bs', testCode);
1226
1334
  program.validate();
1227
- chai_1.expect(program.getDiagnostics().length).to.equal(0);
1335
+ (0, chai_1.expect)(program.getDiagnostics().length).to.equal(0);
1228
1336
  });
1229
1337
  it('gets the correct text for new Class()', () => {
1230
1338
  let file = program.setFile('source/fooBar.bs', testCode);
1231
1339
  program.validate();
1232
1340
  let hover = file.getHover(vscode_languageserver_1.Position.create(8, 34)); // new Foo("hello")
1233
- chai_1.expect(hover).to.exist;
1234
- chai_1.expect(hover.contents).to.equal('new Foo(name as string)');
1341
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1342
+ '```brightscript',
1343
+ 'new Foo(name as string)',
1344
+ '```'
1345
+ ].join('\n'));
1235
1346
  });
1236
1347
  it('gets the correct text for created object', () => {
1237
1348
  let file = program.setFile('source/fooBar.bs', testCode);
1238
1349
  program.validate();
1239
1350
  let hover = file.getHover(vscode_languageserver_1.Position.create(8, 23)); // myFoo
1240
- chai_1.expect(hover).to.exist;
1241
- chai_1.expect(hover.contents).to.equal('myFoo as Foo');
1351
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1352
+ '```brightscript',
1353
+ 'myFoo as Foo',
1354
+ '```'
1355
+ ].join('\n'));
1242
1356
  });
1243
1357
  it('gets the correct text for class declaration', () => {
1244
1358
  let file = program.setFile('source/fooBar.bs', testCode);
1245
1359
  program.validate();
1246
1360
  let hover = file.getHover(vscode_languageserver_1.Position.create(6, 21)); // class Bar
1247
- chai_1.expect(hover).to.exist;
1248
- chai_1.expect(hover.contents).to.equal('class Bar');
1361
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1362
+ '```brightscript',
1363
+ 'class Bar',
1364
+ '```'
1365
+ ].join('\n'));
1249
1366
  });
1250
1367
  it('gets the correct text for class method declaration', () => {
1251
1368
  let file = program.setFile('source/fooBar.bs', testCode);
1252
1369
  program.validate();
1253
1370
  let hover = file.getHover(vscode_languageserver_1.Position.create(11, 29)); // getInt
1254
- chai_1.expect(hover).to.exist;
1255
- chai_1.expect(hover.contents).to.equal('function Bar.getInt() as integer');
1371
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1372
+ '```brightscript',
1373
+ 'function Bar.getInt() as integer',
1374
+ '```'
1375
+ ].join('\n'));
1256
1376
  });
1257
1377
  it('gets the correct text for class field declaration', () => {
1258
1378
  let file = program.setFile('source/fooBar.bs', testCode);
1259
1379
  program.validate();
1260
1380
  let hover = file.getHover(vscode_languageserver_1.Position.create(17, 20)); // myInt
1261
- chai_1.expect(hover).to.exist;
1262
- chai_1.expect(hover.contents).to.equal('Buz.myInt as integer');
1381
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1382
+ '```brightscript',
1383
+ 'Buz.myInt as integer',
1384
+ '```'
1385
+ ].join('\n'));
1263
1386
  });
1264
1387
  it('gets the correct text for super() call', () => {
1265
1388
  let file = program.setFile('source/fooBar.bs', testCode);
1266
1389
  program.validate();
1267
1390
  let hover = file.getHover(vscode_languageserver_1.Position.create(25, 23)); // super() in Bee.new
1268
- chai_1.expect(hover).to.exist;
1269
- chai_1.expect(hover.contents).to.equal('new Buz(i as integer)');
1391
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1392
+ '```brightscript',
1393
+ 'new Buz(i as integer)',
1394
+ '```'
1395
+ ].join('\n'));
1270
1396
  });
1271
1397
  it('gets the correct text for variable with same name as a member', () => {
1272
1398
  let file = program.setFile('source/fooBar.bs', testCode);
1273
1399
  program.validate();
1274
1400
  let hover = file.getHover(vscode_languageserver_1.Position.create(29, 23)); // myInt in Bee.varSameNameAsMember
1275
- chai_1.expect(hover).to.exist;
1276
- chai_1.expect(hover.contents).to.equal('myInt as integer');
1401
+ (0, chai_1.expect)(hover === null || hover === void 0 ? void 0 : hover.contents).to.equal([
1402
+ '```brightscript',
1403
+ 'myInt as integer',
1404
+ '```'
1405
+ ].join('\n'));
1277
1406
  });
1278
1407
  });
1279
1408
  describe('getSymbolTypeFromToken', () => {
1280
1409
  const testClassCode = `
1281
- class KlassA
1282
- function getInt() as integer
1283
- return 1
1284
- end function
1285
-
1286
- sub printInt(i as integer)
1287
- print i
1410
+ sub main()
1411
+ c = new KlassC()
1412
+ a = c.b.getA()
1413
+ num = c.b.getA().getInt()
1414
+ c.b.getA().printInt(num)
1288
1415
  end sub
1289
- end class
1416
+ class KlassA
1417
+ function getInt() as integer
1418
+ return 1
1419
+ end function
1290
1420
 
1291
- class KlassB
1421
+ sub printInt(i as integer)
1422
+ print i
1423
+ end sub
1424
+ end class
1292
1425
 
1293
- function getA() as KlassA
1294
- return new KlassA()
1295
- end function
1296
- end class
1426
+ class KlassB
1297
1427
 
1298
- class KlassC
1299
- public b as KlassB
1428
+ function getA() as KlassA
1429
+ return new KlassA()
1430
+ end function
1431
+ end class
1300
1432
 
1301
- sub new()
1302
- m.b = new KlassB()
1303
- end sub
1304
- end class
1433
+ class KlassC
1434
+ public b as KlassB
1305
1435
 
1306
- sub main()
1307
- c = new KlassC()
1308
- a = c.b.getA()
1309
- num = c.b.getA().getInt()
1310
- c.b.getA().printInt(num)
1311
- end sub
1436
+ sub new ()
1437
+ m.b = new KlassB()
1438
+ end sub
1439
+ end class
1312
1440
  `;
1313
1441
  it('correctly parses the file', () => {
1314
1442
  program.setFile('source/klassTest.bs', testClassCode);
1315
1443
  program.validate();
1316
- chai_1.expect(program.getDiagnostics().length).to.equal(0);
1444
+ (0, testHelpers_spec_1.expectZeroDiagnostics)(program);
1317
1445
  });
1318
1446
  describe('finding tokens', () => {
1319
1447
  let klassCode;
@@ -1321,7 +1449,7 @@ describe('BrsFile BrighterScript classes', () => {
1321
1449
  beforeEach(() => {
1322
1450
  klassCode = program.setFile('source/klassTest.bs', testClassCode);
1323
1451
  const scopes = program.getScopesForFile(klassCode);
1324
- chai_1.expect(scopes.length).to.eql(1);
1452
+ (0, chai_1.expect)(scopes.length).to.eql(1);
1325
1453
  mainScope = scopes[0];
1326
1454
  mainScope.linkSymbolTable();
1327
1455
  });
@@ -1330,67 +1458,114 @@ describe('BrsFile BrighterScript classes', () => {
1330
1458
  });
1331
1459
  it('gets correct class for m', () => {
1332
1460
  var _a;
1333
- const position = vscode_languageserver_1.Position.create(22, 17); // 'm' from m.b = new KlassB()
1461
+ const position = vscode_languageserver_1.Position.create(28, 20); // 'm' from m.b = new KlassB()
1334
1462
  const token = klassCode.parser.getTokenAt(position);
1335
- chai_1.expect(token.text).to.equal('m');
1463
+ (0, chai_1.expect)(token.text).to.equal('m');
1336
1464
  const func = klassCode.getFunctionExpressionAtPosition(position);
1337
1465
  let klass = (_a = klassCode.getClassFromToken(token, func, mainScope)) === null || _a === void 0 ? void 0 : _a.item;
1338
- chai_1.expect(klass).to.exist;
1339
- chai_1.expect(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassC');
1466
+ (0, chai_1.expect)(klass).to.exist;
1467
+ (0, chai_1.expect)(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassC');
1340
1468
  });
1341
1469
  it('gets correct class for fieldMember', () => {
1342
1470
  var _a;
1343
- const position = vscode_languageserver_1.Position.create(22, 19); // 'b' from m.b = new KlassB()
1471
+ const position = vscode_languageserver_1.Position.create(28, 23); // 'b' from m.b = new KlassB()
1344
1472
  const token = klassCode.parser.getTokenAt(position);
1345
- chai_1.expect(token.text).to.equal('b');
1473
+ (0, chai_1.expect)(token.text).to.equal('b');
1346
1474
  const func = klassCode.getFunctionExpressionAtPosition(position);
1347
1475
  let klass = (_a = klassCode.getClassFromToken(token, func, mainScope)) === null || _a === void 0 ? void 0 : _a.item;
1348
- chai_1.expect(klass).to.exist;
1349
- chai_1.expect(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassB');
1476
+ (0, chai_1.expect)(klass).to.exist;
1477
+ (0, chai_1.expect)(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassB');
1350
1478
  });
1351
1479
  it('gets correct class for variable', () => {
1352
1480
  var _a;
1353
- const position = vscode_languageserver_1.Position.create(28, 17); // 'c' from c.b.getA().getInt()
1481
+ const position = vscode_languageserver_1.Position.create(4, 22); // 'c' from c.b.getA().getInt()
1354
1482
  const token = klassCode.parser.getTokenAt(position);
1355
- chai_1.expect(token.text).to.equal('c');
1483
+ (0, chai_1.expect)(token.text).to.equal('c');
1356
1484
  const func = klassCode.getFunctionExpressionAtPosition(position);
1357
1485
  let klass = (_a = klassCode.getClassFromToken(token, func, mainScope)) === null || _a === void 0 ? void 0 : _a.item;
1358
- chai_1.expect(klass).to.exist;
1359
- chai_1.expect(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassC');
1486
+ (0, chai_1.expect)(klass).to.exist;
1487
+ (0, chai_1.expect)(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassC');
1360
1488
  });
1361
1489
  it('gets correct class for variable field', () => {
1362
1490
  var _a;
1363
- const position = vscode_languageserver_1.Position.create(28, 19); // 'b' from c.b.getA()
1491
+ const position = vscode_languageserver_1.Position.create(3, 23); // 'b' from c.b.getA()
1364
1492
  const token = klassCode.parser.getTokenAt(position);
1365
- chai_1.expect(token.text).to.equal('b');
1493
+ (0, chai_1.expect)(token.text).to.equal('b');
1366
1494
  const func = klassCode.getFunctionExpressionAtPosition(position);
1367
1495
  let klass = (_a = klassCode.getClassFromToken(token, func, mainScope)) === null || _a === void 0 ? void 0 : _a.item;
1368
- chai_1.expect(klass).to.exist;
1369
- chai_1.expect(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassB');
1496
+ (0, chai_1.expect)(klass).to.exist;
1497
+ (0, chai_1.expect)(klass.getName(Parser_1.ParseMode.BrighterScript)).to.equal('KlassB');
1370
1498
  });
1371
1499
  it('gets type and return class for variable function field', () => {
1372
- const position = vscode_languageserver_1.Position.create(28, 23); // 'getA' from c.b.getA()
1500
+ const position = vscode_languageserver_1.Position.create(3, 28); // 'getA' from c.b.getA()
1373
1501
  const token = klassCode.parser.getTokenAt(position);
1374
- chai_1.expect(token.text).to.equal('getA');
1502
+ (0, chai_1.expect)(token.text).to.equal('getA');
1375
1503
  const func = klassCode.getFunctionExpressionAtPosition(position);
1376
1504
  let { type, symbolContainer } = klassCode.getSymbolTypeFromToken(token, func, mainScope);
1377
- chai_1.expect(type).to.exist;
1378
- chai_1.expect(reflection_1.isFunctionType(type)).to.be.true;
1379
- chai_1.expect(symbolContainer).to.exist;
1380
- chai_1.expect(reflection_1.isCustomType(symbolContainer)).to.be.true;
1381
- chai_1.expect(symbolContainer.name).to.equal('KlassA');
1505
+ (0, chai_1.expect)((0, reflection_1.isFunctionType)(type)).to.be.true;
1506
+ (0, chai_1.expect)((0, reflection_1.isCustomType)(symbolContainer)).to.be.true;
1507
+ (0, chai_1.expect)(symbolContainer.name).to.equal('KlassA');
1382
1508
  });
1383
1509
  it('gets type and class for field from return value of function', () => {
1384
- const position = vscode_languageserver_1.Position.create(29, 30); // 'getInt' from c.b.getA().getInt()
1510
+ const position = vscode_languageserver_1.Position.create(4, 37); // 'getInt' from c.b.getA().getInt()
1385
1511
  const token = klassCode.parser.getTokenAt(position);
1386
- chai_1.expect(token.text).to.equal('getInt');
1512
+ (0, chai_1.expect)(token.text).to.equal('getInt');
1387
1513
  const func = klassCode.getFunctionExpressionAtPosition(position);
1388
1514
  let { type, symbolContainer } = klassCode.getSymbolTypeFromToken(token, func, mainScope);
1389
- chai_1.expect(type).to.exist;
1390
- chai_1.expect(reflection_1.isFunctionType(type)).to.be.true;
1391
- chai_1.expect(symbolContainer).to.be.undefined; // getInt() returns integer - no class reference at this point
1515
+ (0, chai_1.expect)(type).to.exist;
1516
+ (0, chai_1.expect)((0, reflection_1.isFunctionType)(type)).to.be.true;
1517
+ (0, chai_1.expect)(symbolContainer).to.be.undefined; // getInt() returns integer - no class reference at this point
1392
1518
  });
1393
1519
  });
1394
1520
  });
1521
+ it('does not crash when child has field with same name as sub in parent', () => {
1522
+ program.setFile('source/main.bs', `
1523
+ class Parent
1524
+ public function helloWorld()
1525
+ end function
1526
+ end class
1527
+ class Child extends Parent
1528
+ public helloWorld as string
1529
+ end class
1530
+ `);
1531
+ program.validate();
1532
+ });
1533
+ it('does not crash when child has method with same name as field in parent', () => {
1534
+ program.setFile('source/main.bs', `
1535
+ class Parent
1536
+ public helloWorld as string
1537
+ end class
1538
+ class Child extends Parent
1539
+ public function helloWorld()
1540
+ end function
1541
+ end class
1542
+ `);
1543
+ program.validate();
1544
+ });
1545
+ it.skip('detects calling class constructors with too many parameters', () => {
1546
+ program.setFile('source/main.bs', `
1547
+ class Parameterless
1548
+ sub new ()
1549
+ end sub
1550
+ end class
1551
+
1552
+ class OneParam
1553
+ sub new (param1)
1554
+ end sub
1555
+ end class
1556
+
1557
+ sub main()
1558
+ c1 = new Parameterless(1)
1559
+ c2 = new OneParam(1, 2)
1560
+ c2 = new OneParam()
1561
+ end sub
1562
+ `);
1563
+ program.validate();
1564
+ (0, testHelpers_spec_1.expectDiagnostics)(program, [
1565
+ DiagnosticMessages_1.DiagnosticMessages.mismatchArgumentCount(0, 1),
1566
+ DiagnosticMessages_1.DiagnosticMessages.mismatchArgumentCount(1, 2),
1567
+ DiagnosticMessages_1.DiagnosticMessages.mismatchArgumentCount(1, 0)
1568
+ ]);
1569
+ });
1395
1570
  });
1396
1571
  //# sourceMappingURL=BrsFile.Class.spec.js.map