Skip to content

Commit d9099fb

Browse files
committed
fix errors in tests
1 parent 4be46c0 commit d9099fb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/test/compiler.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createSyntaxScriptDiagnosticReport } from '../diagnostic.js';
77
import { expect } from 'chai';
88
import { syxparser } from '../ast.js';
99

10+
function r(sc:number,ec:number):Range {
11+
return {start:{line:1,character:sc},end:{line:1,character:ec}};
12+
}
13+
1014
describe('Compiler module', () => {
1115

1216
function rangeExpectations(r: Range) {
@@ -200,7 +204,7 @@ describe('Compiler module', () => {
200204

201205
const tokens = tokenizeSyx('keyword ruleish;');
202206
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
203-
const stmt: KeywordStatement = { type: NodeType.Keyword, modifiers: [], range: { end: { line: 1, character: 16 }, start: { line: 1, character: 1 } }, word: 'ruleish' };
207+
const stmt: KeywordStatement = { type: NodeType.Keyword, modifiers: [], range: { end: { line: 1, character: 16 }, start: { line: 1, character: 1 } }, word: {value:'ruleish',type:NodeType.Identifier,modifiers:[],range:{start:{line:1,character:9},end:{line:1,character:16}}} };
204208

205209
astTypeExpectations(ast);
206210
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);
@@ -211,7 +215,7 @@ describe('Compiler module', () => {
211215

212216
const tokens = tokenizeSyx('rule \'function-value-return-enabled\': true;');
213217
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
214-
const stmt: RuleStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 43 } }, modifiers: [], rule: 'function-value-return-enabled', value: 'true', type: NodeType.Rule };
218+
const stmt: RuleStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 43 } }, modifiers: [], rule: {range:r(6,38),type:NodeType.String,value:'function-value-return-enabled',modifiers:[]}, value: 'true', type: NodeType.Rule };
215219

216220
astTypeExpectations(ast);
217221
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);
@@ -222,7 +226,7 @@ describe('Compiler module', () => {
222226

223227
const tokens = tokenizeSyx('compile(ts,js) \'test\';');
224228
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
225-
const stmt: CompileStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 22 } }, formats: ['ts', 'js'], type: NodeType.Compile, modifiers: [], body: [{ type: NodeType.String, modifiers: [], range: { start: { line: 1, character: 16 }, end: { line: 1, character: 22 } }, value: 'test' }] };
229+
const stmt: CompileStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 22 } }, formats: [{modifiers:[],type:NodeType.Identifier,range:r(9,11),value:'ts'},{modifiers:[],type:NodeType.Identifier,range:r(12,14),value:'js'}], type: NodeType.Compile, modifiers: [], body: [{ type: NodeType.String, modifiers: [], range: { start: { line: 1, character: 16 }, end: { line: 1, character: 22 } }, value: 'test' }] };
226230

227231
astTypeExpectations(ast);
228232
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);
@@ -233,7 +237,7 @@ describe('Compiler module', () => {
233237

234238
const tokens = tokenizeSyx('imports(ts,js) \'math\';');
235239
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
236-
const stmt: ImportsStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 22 } }, formats: ['ts', 'js'], type: NodeType.Imports, modifiers: [], module: 'math' };
240+
const stmt: ImportsStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 22 } }, formats: [{modifiers:[],type:NodeType.Identifier,range:r(9,11),value:'ts'},{modifiers:[],type:NodeType.Identifier,range:r(12,14),value:'js'}], type: NodeType.Imports, modifiers: [], module: {range:r(16,22),modifiers:[],type:NodeType.String,value:'math'} };
237241

238242
astTypeExpectations(ast);
239243
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);
@@ -244,7 +248,7 @@ describe('Compiler module', () => {
244248

245249
const tokens = tokenizeSyx('global randomizer {}');
246250
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
247-
const stmt: GlobalStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 21 } }, name: 'randomizer', type: NodeType.Global, modifiers: [], body: [] };
251+
const stmt: GlobalStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 21 } }, name: {type:NodeType.Identifier,modifiers:[],range:r(8,18),value:'randomizer'}, type: NodeType.Global, modifiers: [], body: [] };
248252

249253
astTypeExpectations(ast);
250254
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);
@@ -255,7 +259,7 @@ describe('Compiler module', () => {
255259

256260
const tokens = tokenizeSyx('function randomizer <int> {}');
257261
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
258-
const stmt: FunctionStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 29 } }, name: 'randomizer', type: NodeType.Function, modifiers: [], body: [], arguments: ['int'] };
262+
const stmt: FunctionStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 29 } }, name: {type:NodeType.Identifier,modifiers:[],range:r(10,20),value:'randomizer'}, type: NodeType.Function, modifiers: [], body: [], arguments: [{modifiers:[],range:r(21,26),type:NodeType.PrimitiveType,value:'int'}] };
259263

260264
astTypeExpectations(ast);
261265
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);
@@ -266,7 +270,7 @@ describe('Compiler module', () => {
266270

267271
const tokens = tokenizeSyx('import \'./math\';');
268272
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
269-
const stmt: ImportStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 16 } }, type: NodeType.Import, modifiers: [], path: './math' };
273+
const stmt: ImportStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 16 } }, type: NodeType.Import, modifiers: [], path: {range:r(8,16),value:'./math',modifiers:[],type:NodeType.String} };
270274

271275
astTypeExpectations(ast);
272276
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);
@@ -277,7 +281,7 @@ describe('Compiler module', () => {
277281

278282
const tokens = tokenizeSyx('export keyword ruleish;');
279283
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
280-
const stmt: KeywordStatement = { type: NodeType.Keyword, modifiers: [{ range: { end: { line: 1, character: 7 }, start: { line: 1, character: 1 } }, type: TokenType.ExportKeyword, value: 'export' }], range: { end: { line: 1, character: 23 }, start: { line: 1, character: 1 } }, word: 'ruleish' };
284+
const stmt: KeywordStatement = { type: NodeType.Keyword, modifiers: [{ range: { end: { line: 1, character: 7 }, start: { line: 1, character: 1 } }, type: TokenType.ExportKeyword, value: 'export' }], range: { end: { line: 1, character: 23 }, start: { line: 1, character: 1 } }, word: {range:r(16,23),modifiers:[],type:NodeType.Identifier,value:'ruleish'} };
281285

282286
astTypeExpectations(ast);
283287
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);

0 commit comments

Comments
 (0)