diff --git a/test/full_flow/backtracking/backtracking_parser_spec.ts b/test/full_flow/backtracking/backtracking_parser_spec.ts index 8f80a1c9b..bce81a6e0 100644 --- a/test/full_flow/backtracking/backtracking_parser_spec.ts +++ b/test/full_flow/backtracking/backtracking_parser_spec.ts @@ -13,7 +13,7 @@ import { import * as _ from "lodash" -describe("Simple backtracking example", function () { +describe("Simple backtracking example", () => { // TODO: modify example to use the Chevrotain Lexer to increase readability let largeFqnTokenVector = [ @@ -28,7 +28,7 @@ describe("Simple backtracking example", function () { // new ElementTok(1, 1), new IdentTok("A" , 0, 1, 1), new ColonTok(1,1), // largeFqnTokenVector,new DefaultTok(1,1), new NumberTok(1,1,"666"), new SemiColonTok(";", 0, 1, 1) - it("can parse an element with Equals and a very long qualified name", function () { + it("can parse an element with Equals and a very long qualified name", () => { let input:any = _.flatten([ // element A:ns1.ns2.ns3.ns4.ns5.ns6.ns7.ns8.ns9.ns10.ns11.ns12 = 666; new ElementTok("element", 0, 1, 1), new IdentTok("A", 0, 1, 1), new ColonTok(":", 0, 1, 1), @@ -43,7 +43,7 @@ describe("Simple backtracking example", function () { expect(result).to.equal(RET_TYPE.WITH_EQUALS) }) - it("can parse an element with Default and a very long qualified name", function () { + it("can parse an element with Default and a very long qualified name", () => { let input:any = _.flatten([ // element A:ns1.ns2.ns3.ns4.ns5.ns6.ns7.ns8.ns9.ns10.ns11.ns12 default 666; new ElementTok("element", 0, 1, 1), new IdentTok("A", 0, 1, 1), new ColonTok(":", 0, 1, 1), largeFqnTokenVector, diff --git a/test/full_flow/error_recovery/sql_statements/sql_recovery_spec.ts b/test/full_flow/error_recovery/sql_statements/sql_recovery_spec.ts index f9930fcb6..d84957902 100644 --- a/test/full_flow/error_recovery/sql_statements/sql_recovery_spec.ts +++ b/test/full_flow/error_recovery/sql_statements/sql_recovery_spec.ts @@ -32,7 +32,7 @@ import {exceptions} from "../../../../src/parse/exceptions_public" import {ParseTree} from "../../parse_tree" import * as _ from "lodash" -describe("Error Recovery SQL DDL Example", function () { +describe("Error Recovery SQL DDL Example", () => { "use strict" let schemaFQN = [new IdentTok(1, 1, "schema2"), new DotTok(1, 1), new IdentTok(1, 1, "Persons")] @@ -42,7 +42,7 @@ describe("Error Recovery SQL DDL Example", function () { let shahar31Record = [new LParenTok(1, 1), new IntTok(1, 9, "31"), new CommaTok(1, 1), new StringTok(1, 1, '"SHAHAR"'), new RParenTok(1, 1)] /* tslint:enable:quotemark */ - it("can parse a series of three statements successfully", function () { + it("can parse a series of three statements successfully", () => { let input:any = _.flatten([ // CREATE TABLE schema2.Persons new CreateTok(1, 1), new TableTok(1, 1), schemaFQN, new SemiColonTok(1, 1), @@ -70,7 +70,7 @@ describe("Error Recovery SQL DDL Example", function () { new DeleteTok(1, 1), shahar31Record, new FromTok(1, 1), schemaFQN, new SemiColonTok(1, 1) ]) - it("can perform single token insertion for a missing semicolon", function () { + it("can perform single token insertion for a missing semicolon", () => { let parser = new DDLExampleRecoveryParser(input) let ptResult:any = parser.ddl() // one error encountered @@ -85,7 +85,7 @@ describe("Error Recovery SQL DDL Example", function () { expect(insertedSemiColon.isInsertedInRecovery).to.equal(true) }) - it("can disable single token insertion for a missing semicolon", function () { + it("can disable single token insertion for a missing semicolon", () => { let parser = new DDLExampleRecoveryParser(input, false) let ptResult:any = parser.ddl() expect(parser.errors.length).to.equal(1) @@ -106,7 +106,7 @@ describe("Error Recovery SQL DDL Example", function () { new DeleteTok(1, 1), shahar31Record, new FromTok(1, 1), schemaFQN, new SemiColonTok(1, 1) ]) - it("can perform single token deletion for a redundant keyword", function () { + it("can perform single token deletion for a redundant keyword", () => { let parser = new DDLExampleRecoveryParser(input) let ptResult = parser.ddl() // one error encountered @@ -117,7 +117,7 @@ describe("Error Recovery SQL DDL Example", function () { assertAllThreeStatementsPresentAndValid(ptResult) }) - it("can disable single token deletion for a redundant keyword", function () { + it("can disable single token deletion for a redundant keyword", () => { let parser = new DDLExampleRecoveryParser(input, false) let ptResult:any = parser.ddl() expect(parser.errors.length).to.equal(1) @@ -130,7 +130,7 @@ describe("Error Recovery SQL DDL Example", function () { describe("resync recovery mechanism", () => { - it("can perform re-sync recovery and only 'lose' part of the input", function () { + it("can perform re-sync recovery and only 'lose' part of the input", () => { let input:any = _.flatten([ // CREATE TABLE schema2.Persons new CreateTok(1, 1), new TableTok(1, 1), schemaFQN, new SemiColonTok(1, 1), @@ -172,7 +172,7 @@ describe("Error Recovery SQL DDL Example", function () { new DeleteTok(1, 1), shahar31Record, new FromTok(1, 1), schemaFQN, new SemiColonTok(1, 1) ]) - it("can perform re-sync recovery and only 'lose' part of the input even when re-syncing to two rules 'above'", function () { + it("can perform re-sync recovery and only 'lose' part of the input even when re-syncing to two rules 'above'", () => { let parser = new DDLExampleRecoveryParser(input) let ptResult:any = parser.ddl() // one error encountered @@ -191,7 +191,7 @@ describe("Error Recovery SQL DDL Example", function () { expect(ptResult.children[2].payload).not.to.be.an.instanceof(INVALID_DELETE_STMT) }) - it("can disable re-sync recovery and only 'lose' part of the input even when re-syncing to two rules 'above'", function () { + it("can disable re-sync recovery and only 'lose' part of the input even when re-syncing to two rules 'above'", () => { let parser = new DDLExampleRecoveryParser(input, false) let ptResult:any = parser.ddl() // one error encountered @@ -217,7 +217,7 @@ describe("Error Recovery SQL DDL Example", function () { } - it("will encounter an NotAllInputParsedException when some of the input vector has not been parsed", function () { + it("will encounter an NotAllInputParsedException when some of the input vector has not been parsed", () => { let input:any = _.flatten([ // CREATE TABLE schema2.Persons; TABLE <-- redundant "TABLE" token new CreateTok(1, 1), new TableTok(1, 1), schemaFQN, new SemiColonTok(1, 1), new TableTok(1, 1)]) @@ -228,7 +228,7 @@ describe("Error Recovery SQL DDL Example", function () { expect(parser.errors[0]).to.be.an.instanceof(exceptions.NotAllInputParsedException) }) - it("can use the same parser instance to parse multiple inputs", function () { + it("can use the same parser instance to parse multiple inputs", () => { let input1:any = _.flatten([ // CREATE TABLE schema2.Persons; new CreateTok(1, 1), new TableTok(1, 1), schemaFQN, new SemiColonTok(1, 1)]) @@ -254,7 +254,7 @@ describe("Error Recovery SQL DDL Example", function () { expect(ptResult.children[0].payload).not.to.be.an.instanceof(INVALID_DELETE_STMT) }) - it("can re-sync to the next iteration in a MANY rule", function () { + it("can re-sync to the next iteration in a MANY rule", () => { let input:any = _.flatten([ // CREATE TABLE schema2.Persons new CreateTok(1, 1), new TableTok(1, 1), schemaFQN, new SemiColonTok(1, 1), diff --git a/test/full_flow/error_recovery/switch_case/swithcase_recovery_spec.ts b/test/full_flow/error_recovery/switch_case/swithcase_recovery_spec.ts index 0ff350a1b..ff85bd99c 100644 --- a/test/full_flow/error_recovery/switch_case/swithcase_recovery_spec.ts +++ b/test/full_flow/error_recovery/switch_case/swithcase_recovery_spec.ts @@ -20,10 +20,10 @@ import {exceptions} from "../../../../src/parse/exceptions_public" import * as _ from "lodash" -describe("Error Recovery switch-case Example", function () { +describe("Error Recovery switch-case Example", () => { "use strict" - it("can parse a valid text successfully", function () { + it("can parse a valid text successfully", () => { let input = [ // switch (name) { new SwitchTok(1, 1), new LParenTok(1, 1), new IdentTok("name", 0, 1, 1), new RParenTok(1, 1), new LCurlyTok(1, 1), @@ -48,7 +48,7 @@ describe("Error Recovery switch-case Example", function () { }) }) - it("can perform re-sync recovery to the next case stmt", function () { + it("can perform re-sync recovery to the next case stmt", () => { let input = [ // switch (name) { new SwitchTok(1, 1), new LParenTok(1, 1), new IdentTok("name", 0, 1, 1), new RParenTok(1, 1), new LCurlyTok(1, 1), @@ -73,7 +73,7 @@ describe("Error Recovery switch-case Example", function () { }) }) - it("will detect an error if missing AT_LEAST_ONCE occurrence", function () { + it("will detect an error if missing AT_LEAST_ONCE occurrence", () => { let input = [ // switch (name) { } new SwitchTok(1, 1), new LParenTok(1, 1), new IdentTok("name", 0, 1, 1), new RParenTok(1, 1), new LCurlyTok(1, 1), new RCurlyTok(1, 1) @@ -89,7 +89,7 @@ describe("Error Recovery switch-case Example", function () { }) - it("can perform re-sync recovery to the next case stmt even if the unexpected tokens are between valid case stmts", function () { + it("can perform re-sync recovery to the next case stmt even if the unexpected tokens are between valid case stmts", () => { let input = [ // switch (name) { new SwitchTok(1, 1), new LParenTok(1, 1), new IdentTok("name", 0, 1, 1), new RParenTok(1, 1), new LCurlyTok(1, 1), @@ -118,7 +118,7 @@ describe("Error Recovery switch-case Example", function () { }) }) - it("can also sometimes fail in automatic error recovery :)", function () { + it("can also sometimes fail in automatic error recovery :)", () => { let input = [ // switch (name) { new SwitchTok(1, 1), new LParenTok(1, 1), new IdentTok("name", 0, 1, 1), new RParenTok(1, 1), new LCurlyTok(1, 1), @@ -142,7 +142,7 @@ describe("Error Recovery switch-case Example", function () { expect(parseResult).to.deep.equal({}) }) - it("can perform single token deletion recovery", function () { + it("can perform single token deletion recovery", () => { let input = [ // switch (name) { new SwitchTok(1, 1), new LParenTok(1, 1), new IdentTok("name", 0, 1, 1), new RParenTok(1, 1), new LCurlyTok(1, 1), @@ -167,7 +167,7 @@ describe("Error Recovery switch-case Example", function () { }) }) - it("will perform single token insertion for a missing colon", function () { + it("will perform single token insertion for a missing colon", () => { let input = [ // case "Terry" return 2 <-- missing the colon between "Terry" and return new CaseTok(1, 1), new StringTok("Terry", 0, 1, 1), /* new ColonTok(1, 1) ,*/ new ReturnTok(1, 1), new IntTok("2", 0, 1, 1), new SemiColonTok(1, 1), @@ -181,7 +181,7 @@ describe("Error Recovery switch-case Example", function () { expect(parseResult).to.deep.equal({"Terry": 2}) }) - it("will NOT perform single token insertion for a missing string", function () { + it("will NOT perform single token insertion for a missing string", () => { let input = [ // case : return 2 <-- missing the string for the case's value new CaseTok(1, 1), /* new StringTok("Terry" , 0, 1, 1),*/ new ColonTok(1, 1), new ReturnTok(1, 1), diff --git a/test/lang/hash_table_spec.ts b/test/lang/hash_table_spec.ts index 31983b75c..6f109b146 100644 --- a/test/lang/hash_table_spec.ts +++ b/test/lang/hash_table_spec.ts @@ -1,8 +1,8 @@ import {HashTable} from "../../src/lang/lang_extensions" -describe("The HashTable implementation", function () { +describe("The HashTable implementation", () => { - it("will return undefined for a key that does not exist, and the value for a key that does exist", function () { + it("will return undefined for a key that does not exist, and the value for a key that does exist", () => { let hashTable = new HashTable(); hashTable.put("one", 1) hashTable.put("two", 2) @@ -12,7 +12,7 @@ describe("The HashTable implementation", function () { expect(hashTable.get("three")).to.be.undefined }) - it("support property names that are also names of built in properties on javascript Object", function () { + it("support property names that are also names of built in properties on javascript Object", () => { let hashTable = new HashTable(); hashTable.put("toString", 1) hashTable.put("hasOwnProperty", 2) diff --git a/test/parse/gast_builder_spec.ts b/test/parse/gast_builder_spec.ts index b89563034..4ca19ce0e 100644 --- a/test/parse/gast_builder_spec.ts +++ b/test/parse/gast_builder_spec.ts @@ -43,7 +43,7 @@ import { import * as _ from "lodash" -describe("The GAst Builder namespace", function () { +describe("The GAst Builder namespace", () => { "use strict" let typeDefText = "// parse\r\n" + @@ -94,7 +94,7 @@ describe("The GAst Builder namespace", function () { " let rSquare = this.CONSUME1(RSquareTok)" - it("can extract Terminals IPRODRanges from a text", function () { + it("can extract Terminals IPRODRanges from a text", () => { let actual = createTerminalRanges(typeDefText) expect(actual.length).to.equal(4) let terminalTypes = _.map(actual, (rangeProd) => { return rangeProd.type}) @@ -108,7 +108,7 @@ describe("The GAst Builder namespace", function () { expect(terminalTexts[3]).to.equal(".CONSUME2(SemicolonTok") }) - it("can extract SubRule references IPRODRanges from a text", function () { + it("can extract SubRule references IPRODRanges from a text", () => { let actual = createRefsRanges(typeDefText) expect(actual.length).to.equal(2) let refTypes = _.map(actual, (rangeProd) => { return rangeProd.type}) @@ -120,7 +120,7 @@ describe("The GAst Builder namespace", function () { expect(refText[1]).to.equal(".SUBRULE(this.assignedTypeSpec") }) - it("can extract Option IPRODRanges from a text", function () { + it("can extract Option IPRODRanges from a text", () => { let actual = createOptionRanges(elementDefText) expect(actual.length).to.equal(2) let refTypes = _.map(actual, (rangeProd) => { return rangeProd.type}) @@ -136,7 +136,7 @@ describe("The GAst Builder namespace", function () { " })") }) - it("can extract 'at least one' IPRODRanges from a text", function () { + it("can extract 'at least one' IPRODRanges from a text", () => { let actual = createAtLeastOneRanges("this.MANY(...) this.AT_LEAST_ONE(bamba) this.AT_LEAST_ONE(THIS.OPTION(bisli))") expect(actual.length).to.equal(2) let refTypes = _.map(actual, (rangeProd) => { return rangeProd.type}) @@ -148,7 +148,7 @@ describe("The GAst Builder namespace", function () { expect(refText[1]).to.equal(".AT_LEAST_ONE(THIS.OPTION(bisli))") }) - it("can extract 'many' IPRODRanges from a text", function () { + it("can extract 'many' IPRODRanges from a text", () => { let actual = createManyRanges(literalArrayText) expect(actual.length).to.equal(1) let refTypes = _.map(actual, (rangeProd) => { return rangeProd.type}) @@ -163,7 +163,7 @@ describe("The GAst Builder namespace", function () { " )") }) - it("can extract 'or' IPRODRanges from a text", function () { + it("can extract 'or' IPRODRanges from a text", () => { let actual = createOrRanges(elementDefText) // 1 or range + 2 orPart ranges (flat ranges) expect(actual.length).to.equal(3) @@ -182,7 +182,7 @@ describe("The GAst Builder namespace", function () { " ], \"\")") }) - it("can extract all IPRODRanges from a text", function () { + it("can extract all IPRODRanges from a text", () => { let ter = ".CONSUME3(one1" let option = ".OPTION(2)" let many = ".MANY(3)" @@ -210,7 +210,7 @@ describe("The GAst Builder namespace", function () { setEquality(refText, [ter, option, many, many_sep, ref, at_least_one_sep, atLeastOne, or]) }) - it("has a utility function that can remove comments(single line and multiline) from texts", function () { + it("has a utility function that can remove comments(single line and multiline) from texts", () => { let input = "// single line comment" + "\nhello" + "/* multi line comment \n" + @@ -223,7 +223,7 @@ describe("The GAst Builder namespace", function () { expect(actual).to.equal("\nhello world") }) - it("has a utility function that can remove string literals from texts", function () { + it("has a utility function that can remove string literals from texts", () => { let input = "'single quotes string'" + "\nhello" + "\"\"" + @@ -235,12 +235,12 @@ describe("The GAst Builder namespace", function () { expect(actual).to.equal("\nhello world") }) - it("can detect missing closing parenthesis in a string", function () { + it("can detect missing closing parenthesis in a string", () => { let input = " ((()))" // the input is assumed to start right after an opening parenthesis expect(() => findClosingOffset("(", ")", 0, input)).to.throw("INVALID INPUT TEXT, UNTERMINATED PARENTHESIS") }) - it("can find the direct 'childs' of another Production from an IProd representation", function () { + it("can find the direct 'childs' of another Production from an IProd representation", () => { let allProdRanges:IProdRange[] = [ {range: new Range(1, 10), text: "1.1", type: ProdType.TERMINAL}, {range: new Range(11, 200), text: "1.2", type: ProdType.OR}, @@ -269,7 +269,7 @@ describe("The GAst Builder namespace", function () { expect(manyRange[1].text).to.equal("1.2.1.2") }) - it("can build a Terminal Production from a RangeProd", function () { + it("can build a Terminal Production from a RangeProd", () => { gastBuilder.terminalNameToConstructor = tok let actual = buildProdGast({ range: new Range(1, 2), @@ -281,7 +281,7 @@ describe("The GAst Builder namespace", function () { expect((actual).terminalType).to.equal(IdentTok) }) - it("will fail building a terminal if it cannot find it's constructor", function () { + it("will fail building a terminal if it cannot find it's constructor", () => { gastBuilder.terminalNameToConstructor = {} let buildMissingTerminal = () => buildProdGast({ range: new Range(1, 2), @@ -292,7 +292,7 @@ describe("The GAst Builder namespace", function () { expect(buildMissingTerminal).to.throw("Terminal Token name: " + "IdentTok" + " not found") }) - it("can build a Ref Production from a RangeProd", function () { + it("can build a Ref Production from a RangeProd", () => { let actual = buildProdGast({ range: new Range(1, 2), text: "this.SUBRULE(this.bamba(1))", @@ -303,19 +303,19 @@ describe("The GAst Builder namespace", function () { expect((actual).nonTerminalName).to.equal("bamba") }) - it("can build an OR Production from a RangeProd", function () { + it("can build an OR Production from a RangeProd", () => { let actual = buildProdGast({range: new Range(1, 2), text: "this.OR(...)", type: ProdType.OR}, []) expect(actual).to.be.an.instanceof(Alternation) expect((actual).definition.length).to.equal(0) }) - it("can build a MANY Production from a RangeProd", function () { + it("can build a MANY Production from a RangeProd", () => { let actual = buildProdGast({range: new Range(1, 2), text: "this.MANY(...)", type: ProdType.MANY}, []) expect(actual).to.be.an.instanceof(Repetition) expect((actual).definition.length).to.equal(0) }) - it("can build a MANY_SEP Production from a RangeProd", function () { + it("can build a MANY_SEP Production from a RangeProd", () => { // hack, using "toString" because it exists on plain js object as the "separator". let actual = buildProdGast({ range: new Range(1, 2), @@ -326,7 +326,7 @@ describe("The GAst Builder namespace", function () { expect((actual).definition.length).to.equal(0) }) - it("will fail when building a MANY_SEP Production from a RangeProd in the seperator is not known", function () { + it("will fail when building a MANY_SEP Production from a RangeProd in the seperator is not known", () => { expect(() => buildProdGast({ range: new Range(1, 2), text: "this.MANY_SEP(MISSING...)", @@ -334,7 +334,7 @@ describe("The GAst Builder namespace", function () { }, [])).to.throw("Separator Terminal Token name: MISSING not found") }) - it("can build an AT_LEAST_ONE Production from a RangeProd", function () { + it("can build an AT_LEAST_ONE Production from a RangeProd", () => { let actual = buildProdGast({ range: new Range(1, 2), text: "this.AT_LEAST_ONE(...)", @@ -344,7 +344,7 @@ describe("The GAst Builder namespace", function () { expect((actual).definition.length).to.equal(0) }) - it("can build an OPTION Production from a RangeProd", function () { + it("can build an OPTION Production from a RangeProd", () => { let actual = buildProdGast({ range: new Range(1, 2), text: "this.OPTION(...)", @@ -354,13 +354,13 @@ describe("The GAst Builder namespace", function () { expect((actual).definition.length).to.equal(0) }) - it("can build an OR Production from a RangeProd", function () { + it("can build an OR Production from a RangeProd", () => { let actual = buildProdGast({range: new Range(1, 2), text: "this.OR(...)", type: ProdType.OR}, []) expect(actual).to.be.an.instanceof(Alternation) expect((actual).definition.length).to.equal(0) }) - it("can build The Gast representation of a literalArray Grammar Rule", function () { + it("can build The Gast representation of a literalArray Grammar Rule", () => { let actual = buildTopProduction(literalArrayText, "literalArray", tok) expect(actual.name).to.equal("literalArray") expect(actual.orgText).to.equal(literalArrayText) @@ -394,7 +394,7 @@ describe("The GAst Builder namespace", function () { }) - it("can build The Gast representation of an elementDefinition Grammar Rule", function () { + it("can build The Gast representation of an elementDefinition Grammar Rule", () => { let actual = buildTopProduction(elementDefText, "elementDef", tok) expect(actual.orgText).to.equal(elementDefText) expect(actual.name).to.equal("elementDef") @@ -445,7 +445,7 @@ describe("The GAst Builder namespace", function () { }) - it("can build nested OR grammar successfully", function () { + it("can build nested OR grammar successfully", () => { let input = " let max = this.OR([\n\ {WHEN: isExpression, THEN_DO: ()=> {\n\ diff --git a/test/parse/grammar/checks_spec.ts b/test/parse/grammar/checks_spec.ts index 0e0a7cadd..a5fc1599d 100644 --- a/test/parse/grammar/checks_spec.ts +++ b/test/parse/grammar/checks_spec.ts @@ -22,9 +22,9 @@ import { import {Token, extendToken} from "../../../src/scan/tokens_public" import * as _ from "lodash" -describe("the grammar validations", function () { +describe("the grammar validations", () => { - it("validates every one of the TOP_RULEs in the input", function () { + it("validates every one of the TOP_RULEs in the input", () => { let expectedErrorsNoMsg = [{ "type": ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS, @@ -79,7 +79,7 @@ describe("the grammar validations", function () { expect(expectedErrorsNoMsg).to.deep.include.members(actualErrorsNoMsg) }) - it("does not allow duplicate grammar rule names", function () { + it("does not allow duplicate grammar rule names", () => { let noErrors = validateRuleName("A", ["B", "C"], "className") //noinspection BadExpressionStatementJS expect(noErrors).to.be.empty @@ -92,7 +92,7 @@ describe("the grammar validations", function () { expect(duplicateErr[0]).to.have.property("ruleName", "A") }) - it("only allows a subset of ECMAScript identifiers as rule names", function () { + it("only allows a subset of ECMAScript identifiers as rule names", () => { let res1 = validateRuleName("1baa", [], "className") expect(res1).to.have.lengthOf(1) expect(res1[0]).to.have.property("message") @@ -114,42 +114,42 @@ describe("the grammar validations", function () { }) -describe("identifyProductionForDuplicates function", function () { - it("generates DSL code for a ProdRef", function () { +describe("identifyProductionForDuplicates function", () => { + it("generates DSL code for a ProdRef", () => { let dslCode = identifyProductionForDuplicates(new NonTerminal("ActionDeclaration")) expect(dslCode).to.equal("SUBRULE_#_1_#_ActionDeclaration") }) - it("generates DSL code for a OPTION", function () { + it("generates DSL code for a OPTION", () => { let dslCode = identifyProductionForDuplicates(new Option([], 3)) expect(dslCode).to.equal("OPTION_#_3_#_") }) - it("generates DSL code for a AT_LEAST_ONE", function () { + it("generates DSL code for a AT_LEAST_ONE", () => { let dslCode = identifyProductionForDuplicates(new RepetitionMandatory([])) expect(dslCode).to.equal("AT_LEAST_ONE_#_1_#_") }) - it("generates DSL code for a MANY", function () { + it("generates DSL code for a MANY", () => { let dslCode = identifyProductionForDuplicates(new Repetition([], 5)) expect(dslCode).to.equal("MANY_#_5_#_") }) - it("generates DSL code for a OR", function () { + it("generates DSL code for a OR", () => { let dslCode = identifyProductionForDuplicates(new Alternation([], 1)) expect(dslCode).to.equal("OR_#_1_#_") }) - it("generates DSL code for a Terminal", function () { + it("generates DSL code for a Terminal", () => { let dslCode = identifyProductionForDuplicates(new Terminal(IdentTok, 4)) expect(dslCode).to.equal("CONSUME_#_4_#_IdentTok") }) }) -describe("OccurrenceValidationCollector GASTVisitor class", function () { +describe("OccurrenceValidationCollector GASTVisitor class", () => { - it("collects all the productions relevant to occurrence validation", function () { + it("collects all the productions relevant to occurrence validation", () => { let qualifiedNameVisitor = new OccurrenceValidationCollector() qualifiedName.accept(qualifiedNameVisitor) expect(qualifiedNameVisitor.allProductions.length).to.equal(4) @@ -170,19 +170,19 @@ let dummyRule = new Rule("dummyRule", [new Terminal(DummyToken)]) let dummyRule2 = new Rule("dummyRule2", [new Terminal(DummyToken)]) let dummyRule3 = new Rule("dummyRule3", [new Terminal(DummyToken)]) -describe("the getFirstNoneTerminal function", function () { +describe("the getFirstNoneTerminal function", () => { - it("can find the firstNoneTerminal of an empty sequence", function () { + it("can find the firstNoneTerminal of an empty sequence", () => { expect(getFirstNoneTerminal([])).to.be.empty }) - it("can find the firstNoneTerminal of a sequence with only one item", function () { + it("can find the firstNoneTerminal of a sequence with only one item", () => { let result = getFirstNoneTerminal([new NonTerminal("dummyRule", dummyRule)]) expect(result).to.have.length(1) expect(_.first(result).name).to.equal("dummyRule") }) - it("can find the firstNoneTerminal of a sequence with two items", function () { + it("can find the firstNoneTerminal of a sequence with two items", () => { let sqeuence = [ new NonTerminal("dummyRule", dummyRule), new NonTerminal("dummyRule2", dummyRule2)] @@ -191,7 +191,7 @@ describe("the getFirstNoneTerminal function", function () { expect(_.first(result).name).to.equal("dummyRule") }) - it("can find the firstNoneTerminal of a sequence with two items where the first is optional", function () { + it("can find the firstNoneTerminal of a sequence with two items where the first is optional", () => { let sqeuence = [ new Option([ new NonTerminal("dummyRule", dummyRule) @@ -203,7 +203,7 @@ describe("the getFirstNoneTerminal function", function () { expect(resultRuleNames).to.include.members(["dummyRule", "dummyRule2"]) }) - it("can find the firstNoneTerminal of an alternation", function () { + it("can find the firstNoneTerminal of an alternation", () => { let alternation = [ new Alternation([ new Flat([new NonTerminal("dummyRule", dummyRule)]), @@ -217,7 +217,7 @@ describe("the getFirstNoneTerminal function", function () { expect(resultRuleNames).to.include.members(["dummyRule", "dummyRule2", "dummyRule3"]) }) - it("can find the firstNoneTerminal of an optional repetition", function () { + it("can find the firstNoneTerminal of an optional repetition", () => { let alternation = [ new Repetition([ new Flat([new NonTerminal("dummyRule", dummyRule)]), @@ -231,7 +231,7 @@ describe("the getFirstNoneTerminal function", function () { expect(resultRuleNames).to.include.members(["dummyRule", "dummyRule3"]) }) - it("can find the firstNoneTerminal of a mandatory repetition", function () { + it("can find the firstNoneTerminal of a mandatory repetition", () => { let alternation = [ new RepetitionMandatory([ new Flat([new NonTerminal("dummyRule", dummyRule)]), @@ -321,9 +321,9 @@ class ValidOccurrenceNumUsageParser extends Parser { }) } -describe("The duplicate occurrence validations full flow", function () { +describe("The duplicate occurrence validations full flow", () => { - it("will throw errors on duplicate Terminals consumption in the same top level rule", function () { + it("will throw errors on duplicate Terminals consumption in the same top level rule", () => { expect(() => new ErroneousOccurrenceNumUsageParser1()).to.throw("SUBRULE") expect(() => new ErroneousOccurrenceNumUsageParser1()).to.throw("1") expect(() => new ErroneousOccurrenceNumUsageParser1()).to.throw("duplicateRef") @@ -331,21 +331,21 @@ describe("The duplicate occurrence validations full flow", function () { expect(() => new ErroneousOccurrenceNumUsageParser1()).to.throw("both have the same occurrence index 1") }) - it("will throw errors on duplicate Subrules references in the same top level rule", function () { + it("will throw errors on duplicate Subrules references in the same top level rule", () => { expect(() => new ErroneousOccurrenceNumUsageParser2()).to.throw("CONSUME") expect(() => new ErroneousOccurrenceNumUsageParser2()).to.throw("3") expect(() => new ErroneousOccurrenceNumUsageParser2()).to.throw("PlusTok") expect(() => new ErroneousOccurrenceNumUsageParser2()).to.throw("duplicateTerminal") }) - it("will throw errors on duplicate MANY productions in the same top level rule", function () { + it("will throw errors on duplicate MANY productions in the same top level rule", () => { expect(() => new ErroneousOccurrenceNumUsageParser3()).to.throw("MANY") expect(() => new ErroneousOccurrenceNumUsageParser3()).to.throw("1") expect(() => new ErroneousOccurrenceNumUsageParser3()).to.throw("duplicateMany") expect(() => new ErroneousOccurrenceNumUsageParser3()).to.throw("both have the same occurrence index 1") }) - it("won't detect issues in a Parser using Tokens created by extendToken(...) utility (anonymous)", function () { + it("won't detect issues in a Parser using Tokens created by extendToken(...) utility (anonymous)", () => { //noinspection JSUnusedLocalSymbols let parser = new ValidOccurrenceNumUsageParser() }) @@ -376,16 +376,16 @@ class InvalidRefParser2 extends Parser { }) } -describe("The reference resolver validation full flow", function () { +describe("The reference resolver validation full flow", () => { - it("will throw an error when trying to init a parser with unresolved rule references", function () { + it("will throw an error when trying to init a parser with unresolved rule references", () => { expect(() => new InvalidRefParser()).to.throw("oopsTypo") expect(() => new InvalidRefParser()).to.throw("Parser Definition Errors detected") expect(() => new InvalidRefParser()).to.throw("reference to rule which is not defined") }) it("won't throw an error when trying to init a parser with definition errors but with a flag active to defer handling" + - "of definition errors", function () { + "of definition errors", () => { Parser.DEFER_DEFINITION_ERRORS_HANDLING = true expect(() => new InvalidRefParser2()).to.not.throw() expect(() => new InvalidRefParser2()).to.not.throw() @@ -416,22 +416,22 @@ class InvalidRuleNameParser extends Parser { public one = this.RULE("שלום", () => {}) } -describe("The rule names validation full flow", function () { +describe("The rule names validation full flow", () => { - it("will throw an error when trying to init a parser with duplicate ruleNames", function () { + it("will throw an error when trying to init a parser with duplicate ruleNames", () => { expect(() => new DuplicateRulesParser()).to.throw("is already defined in the grammar") expect(() => new DuplicateRulesParser()).to.throw("DuplicateRulesParser") expect(() => new DuplicateRulesParser()).to.throw("oops_duplicate") }) - it("will throw an error when trying to init a parser with an invalid rule names", function () { + it("will throw an error when trying to init a parser with an invalid rule names", () => { expect(() => new InvalidRuleNameParser()).to.throw("it must match the pattern") expect(() => new InvalidRuleNameParser()).to.throw("Invalid Grammar rule name") expect(() => new InvalidRuleNameParser()).to.throw("שלום") }) it("won't throw an errors when trying to init a parser with definition errors but with a flag active to defer handling" + - "of definition errors (ruleName validation", function () { + "of definition errors (ruleName validation", () => { Parser.DEFER_DEFINITION_ERRORS_HANDLING = true expect(() => new InvalidRuleNameParser()).to.not.throw() expect(() => new InvalidRuleNameParser()).to.not.throw() @@ -491,19 +491,19 @@ class ComplexInDirectlyLeftRecursive extends Parser { }) } -describe("The left recursion detection full flow", function () { +describe("The left recursion detection full flow", () => { - it("will throw an error when trying to init a parser with direct left recursion", function () { + it("will throw an error when trying to init a parser with direct left recursion", () => { expect(() => new DirectlyLeftRecursive()).to.throw("Left Recursion found in grammar") expect(() => new DirectlyLeftRecursive()).to.throw("A --> A") }) - it("will throw an error when trying to init a parser with indirect left recursion", function () { + it("will throw an error when trying to init a parser with indirect left recursion", () => { expect(() => new InDirectlyLeftRecursive()).to.throw("Left Recursion found in grammar") expect(() => new InDirectlyLeftRecursive()).to.throw("A --> B --> A") }) - it("will throw an error when trying to init a parser with indirect left recursion", function () { + it("will throw an error when trying to init a parser with indirect left recursion", () => { expect(() => new ComplexInDirectlyLeftRecursive()).to.throw("Left Recursion found in grammar") expect(() => new ComplexInDirectlyLeftRecursive()).to.throw("A --> B --> A") }) diff --git a/test/parse/grammar/first_spec.ts b/test/parse/grammar/first_spec.ts index b17c19bd5..3bfec84fe 100644 --- a/test/parse/grammar/first_spec.ts +++ b/test/parse/grammar/first_spec.ts @@ -9,10 +9,10 @@ import {first} from "../../../src/parse/grammar/first" import {EntityTok, CommaTok, NamespaceTok, TypeTok, ColonTok, ConstTok} from "./samples" import {setEquality} from "../../utils/matchers" -describe("The Grammar Ast first model", function () { +describe("The Grammar Ast first model", () => { "use strict" - it("can compute the first for a terminal", function () { + it("can compute the first for a terminal", () => { let terminal = new Terminal(EntityTok) let actual = first(terminal) expect(actual.length).to.equal(1) @@ -24,7 +24,7 @@ describe("The Grammar Ast first model", function () { expect(actual2[0]).to.equal(CommaTok) }) - it("can compute the first for a Sequence production ", function () { + it("can compute the first for a Sequence production ", () => { let seqProduction = new Flat([new Terminal(EntityTok)]) let actual = first(seqProduction) expect(actual.length).to.equal(1) @@ -40,7 +40,7 @@ describe("The Grammar Ast first model", function () { expect(actual2[0]).to.equal(EntityTok) }) - it("can compute the first for an alternatives production ", function () { + it("can compute the first for an alternatives production ", () => { let altProduction = new Alternation( [ new Terminal(EntityTok), @@ -56,7 +56,7 @@ describe("The Grammar Ast first model", function () { }) - it("can compute the first for an production with optional prefix", function () { + it("can compute the first for an production with optional prefix", () => { let withOptionalPrefix = new Flat( [ new Option([new Terminal(NamespaceTok)]), diff --git a/test/parse/grammar/follow_spec.ts b/test/parse/grammar/follow_spec.ts index 801ff6227..56e9c49f5 100644 --- a/test/parse/grammar/follow_spec.ts +++ b/test/parse/grammar/follow_spec.ts @@ -12,9 +12,9 @@ import { } from "../../../src/parse/grammar/follow" import {setEquality} from "../../utils/matchers" -describe("The Grammar Ast Follows model", function () { +describe("The Grammar Ast Follows model", () => { - it("can build a followNamePrefix from a Terminal", function () { + it("can build a followNamePrefix from a Terminal", () => { let terminal = new Terminal(IdentTok) let actual = buildInProdFollowPrefix(terminal) expect(actual).to.equal("IdentTok1_~IN~_") @@ -25,7 +25,7 @@ describe("The Grammar Ast Follows model", function () { expect(actual2).to.equal("EntityTok3_~IN~_") }) - it("can build a followName prefix from a TopLevel Production and index", function () { + it("can build a followName prefix from a TopLevel Production and index", () => { let prod = new Rule("bamba", []) let index = 5 @@ -33,7 +33,7 @@ describe("The Grammar Ast Follows model", function () { expect(actual).to.equal("bamba5_~IN~_") }) - it("can compute the follows for Top level production ref in ActionDec", function () { + it("can compute the follows for Top level production ref in ActionDec", () => { let actual:any = new ResyncFollowsWalker(actionDec).startWalking() let actualFollowNames = actual.keys() expect(actualFollowNames.length).to.equal(3) @@ -45,7 +45,7 @@ describe("The Grammar Ast Follows model", function () { setEquality(actual.get("qualifiedName1_~IN~_actionDec"), [SemicolonTok]) }) - it("can compute all follows for a set of top level productions", function () { + it("can compute all follows for a set of top level productions", () => { let actual = computeAllProdsFollows([actionDec]) expect(actual.keys().length).to.equal(3) }) diff --git a/test/parse/grammar/interperter_spec.ts b/test/parse/grammar/interperter_spec.ts index 8bcbc5d69..e56ab5687 100644 --- a/test/parse/grammar/interperter_spec.ts +++ b/test/parse/grammar/interperter_spec.ts @@ -41,12 +41,12 @@ import { } from "../../../src/parse/grammar/interpreter" import {setEquality} from "../../utils/matchers" -describe("The Grammar Interpeter namespace", function () { +describe("The Grammar Interpeter namespace", () => { "use strict" - describe("The NextAfterTokenWalker", function () { + describe("The NextAfterTokenWalker", () => { - it("can compute the next possible token types From ActionDec in scope of ActionDec #1", function () { + it("can compute the next possible token types From ActionDec in scope of ActionDec #1", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -59,7 +59,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(IdentTok) }) - it("can compute the next possible token types From ActionDec in scope of ActionDec #2", function () { + it("can compute the next possible token types From ActionDec in scope of ActionDec #2", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -72,7 +72,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(LParenTok) }) - it("can compute the next possible token types From ActionDec in scope of ActionDec #3", function () { + it("can compute the next possible token types From ActionDec in scope of ActionDec #3", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -85,7 +85,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [IdentTok, RParenTok]) }) - it("can compute the next possible token types From ActionDec in scope of ActionDec #4", function () { + it("can compute the next possible token types From ActionDec in scope of ActionDec #4", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -98,7 +98,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(IdentTok) }) - it("can compute the next possible token types From ActionDec in scope of ActionDec #5", function () { + it("can compute the next possible token types From ActionDec in scope of ActionDec #5", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -111,7 +111,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [SemicolonTok, ColonTok]) }) - it("can compute the next possible token types From ActionDec in scope of ActionDec #6", function () { + it("can compute the next possible token types From ActionDec in scope of ActionDec #6", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -124,7 +124,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(IdentTok) }) - it("can compute the next possible token types From ActionDec in scope of ActionDec #7", function () { + it("can compute the next possible token types From ActionDec in scope of ActionDec #7", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -136,7 +136,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes.length).to.equal(0) }) - it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #1", function () { + it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #1", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -151,7 +151,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(ColonTok) }) - it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #2", function () { + it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #2", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -166,7 +166,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(IdentTok) }) - it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #3", function () { + it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #3", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -181,7 +181,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(RSquareTok) }) - it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #4", function () { + it("can compute the next possible token types From the first paramSpec INSIDE ActionDec #4", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -196,7 +196,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [CommaTok, RParenTok]) }) - it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #1", function () { + it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #1", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -211,7 +211,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(ColonTok) }) - it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #2", function () { + it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #2", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -226,7 +226,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(IdentTok) }) - it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #3", function () { + it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #3", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -241,7 +241,7 @@ describe("The Grammar Interpeter namespace", function () { expect(possibleNextTokTypes[0]).to.equal(RSquareTok) }) - it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #4", function () { + it("can compute the next possible token types From the second paramSpec INSIDE ActionDec #4", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec" @@ -257,7 +257,7 @@ describe("The Grammar Interpeter namespace", function () { }) it("can compute the next possible token types From a fqn inside an actionParamSpec" + - " inside an paramSpec INSIDE ActionDec #1", function () { + " inside an paramSpec INSIDE ActionDec #1", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec", @@ -274,7 +274,7 @@ describe("The Grammar Interpeter namespace", function () { }) it("can compute the next possible token types From a fqn inside an actionParamSpec" + - " inside an paramSpec INSIDE ActionDec #2", function () { + " inside an paramSpec INSIDE ActionDec #2", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec", @@ -291,7 +291,7 @@ describe("The Grammar Interpeter namespace", function () { }) it("can compute the next possible token types From a fqn inside an actionParamSpec" + - " inside an paramSpec INSIDE ActionDec #3", function () { + " inside an paramSpec INSIDE ActionDec #3", () => { let caPath:ITokenGrammarPath = { ruleStack: ["actionDec", "paramSpec", @@ -308,7 +308,7 @@ describe("The Grammar Interpeter namespace", function () { }) it("can compute the next possible token types From a fqn inside an actionParamSpec" + - " inside an paramSpec INSIDE ActionDec #3", function () { + " inside an paramSpec INSIDE ActionDec #3", () => { let caPath:ITokenGrammarPath = { ruleStack: ["paramSpec", "qualifiedName" @@ -324,7 +324,7 @@ describe("The Grammar Interpeter namespace", function () { }) it("can compute the next possible token types From a fqn inside an actionParamSpec" + - " inside an paramSpec INSIDE ActionDec #3", function () { + " inside an paramSpec INSIDE ActionDec #3", () => { let caPath:ITokenGrammarPath = { ruleStack: ["paramSpec", "qualifiedName" @@ -340,7 +340,7 @@ describe("The Grammar Interpeter namespace", function () { }) it("can compute the next possible token types From a fqn inside an actionParamSpec" + - " inside an paramSpec INSIDE ActionDec #3", function () { + " inside an paramSpec INSIDE ActionDec #3", () => { let caPath:ITokenGrammarPath = { ruleStack: ["paramSpec", "qualifiedName" @@ -355,7 +355,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [DotTok, LSquareTok]) }) - it("will fail if we try to compute the next token starting from a rule that does not match the path", function () { + it("will fail if we try to compute the next token starting from a rule that does not match the path", () => { let caPath:ITokenGrammarPath = { ruleStack: ["I_WILL_FAIL_THE_WALKER", "qualifiedName" @@ -371,8 +371,8 @@ describe("The Grammar Interpeter namespace", function () { }) - describe("The NextInsideOptionWalker", function () { - it("can compute the next possible token types inside the OPTION in paramSpec", function () { + describe("The NextInsideOptionWalker", () => { + it("can compute the next possible token types inside the OPTION in paramSpec", () => { let path:IRuleGrammarPath = { ruleStack: ["paramSpec"], occurrenceStack: [1], @@ -383,7 +383,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [LSquareTok]) }) - it("can compute the next possible token types inside the OPTION in paramSpec inside ActionDec", function () { + it("can compute the next possible token types inside the OPTION in paramSpec inside ActionDec", () => { let path:IRuleGrammarPath = { ruleStack: ["actionDec", "paramSpec"], occurrenceStack: [1, 1], @@ -394,7 +394,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [LSquareTok]) }) - it("can compute the next possible token types inside the OPTION in paramSpec inside ActionDec", function () { + it("can compute the next possible token types inside the OPTION in paramSpec inside ActionDec", () => { let path:IRuleGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -406,8 +406,8 @@ describe("The Grammar Interpeter namespace", function () { }) }) - describe("The NextInsideManyWalker", function () { - it("can compute the next possible token types inside the MANY in QualifiedName", function () { + describe("The NextInsideManyWalker", () => { + it("can compute the next possible token types inside the MANY in QualifiedName", () => { let path:IRuleGrammarPath = { ruleStack: ["qualifiedName"], occurrenceStack: [1], @@ -418,7 +418,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [DotTok]) }) - it("can compute the next possible token types inside the MANY in paramSpec inside ActionDec", function () { + it("can compute the next possible token types inside the MANY in paramSpec inside ActionDec", () => { let path:IRuleGrammarPath = { ruleStack: ["actionDec"], occurrenceStack: [1], @@ -429,7 +429,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [CommaTok]) }) - it("can compute the next possible token types inside the MANY in paramSpec inside ParamSpec --> QualifiedName", function () { + it("can compute the next possible token types inside the MANY in paramSpec inside ParamSpec --> QualifiedName", () => { let path:IRuleGrammarPath = { ruleStack: ["paramSpec", "qualifiedName"], occurrenceStack: [1, 1], @@ -440,7 +440,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [DotTok]) }) - it("can compute the next possible token types inside the MANY inside: manyActions --> actionDec ", function () { + it("can compute the next possible token types inside the MANY inside: manyActions --> actionDec ", () => { let path:IRuleGrammarPath = { ruleStack: ["manyActions", "actionDec"], occurrenceStack: [1, 1], @@ -452,8 +452,8 @@ describe("The Grammar Interpeter namespace", function () { }) }) - describe("The NextInsideManySepWalker", function () { - it("can compute the next possible token types inside the MANY_SEP in callArguments", function () { + describe("The NextInsideManySepWalker", () => { + it("can compute the next possible token types inside the MANY_SEP in callArguments", () => { let path:IRuleGrammarPath = { ruleStack: ["callArguments"], occurrenceStack: [1], @@ -464,7 +464,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [IdentTok]) }) - it("can compute the next possible token types inside the MANY_SEP in actionDecSep", function () { + it("can compute the next possible token types inside the MANY_SEP in actionDecSep", () => { let path:IRuleGrammarPath = { ruleStack: ["actionDecSep"], occurrenceStack: [1], @@ -476,8 +476,8 @@ describe("The Grammar Interpeter namespace", function () { }) }) - describe("The NextInsideAtLeastOneWalker", function () { - it("can compute the next possible token types inside the AT_LEAST_ONE in callArguments", function () { + describe("The NextInsideAtLeastOneWalker", () => { + it("can compute the next possible token types inside the AT_LEAST_ONE in callArguments", () => { let path:IRuleGrammarPath = { ruleStack: ["atLeastOneRule"], occurrenceStack: [1], @@ -488,7 +488,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [EntityTok]) }) - it("can compute the next possible token types inside the AT_LEAST_ONE in actionDecSep", function () { + it("can compute the next possible token types inside the AT_LEAST_ONE in actionDecSep", () => { let path:IRuleGrammarPath = { ruleStack: ["atLeastOneRule"], occurrenceStack: [1], @@ -499,7 +499,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [EntityTok]) }) - it("can compute the next possible token types inside the AT_LEAST_ONE in actionDecSep", function () { + it("can compute the next possible token types inside the AT_LEAST_ONE in actionDecSep", () => { let path:IRuleGrammarPath = { ruleStack: ["atLeastOneRule"], occurrenceStack: [1], @@ -511,8 +511,8 @@ describe("The Grammar Interpeter namespace", function () { }) }) - describe("The NextInsideAtLeastOneSepWalker", function () { - it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in atLeastOneSepRule", function () { + describe("The NextInsideAtLeastOneSepWalker", () => { + it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in atLeastOneSepRule", () => { let path:IRuleGrammarPath = { ruleStack: ["atLeastOneSepRule"], occurrenceStack: [1], @@ -523,7 +523,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [EntityTok]) }) - it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in atLeastOneSepRule 2", function () { + it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in atLeastOneSepRule 2", () => { let path:IRuleGrammarPath = { ruleStack: ["atLeastOneSepRule"], occurrenceStack: [1], @@ -534,7 +534,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [EntityTok]) }) - it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in atLeastOneSepRule 3", function () { + it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in atLeastOneSepRule 3", () => { let path:IRuleGrammarPath = { ruleStack: ["atLeastOneSepRule"], occurrenceStack: [1], @@ -545,7 +545,7 @@ describe("The Grammar Interpeter namespace", function () { setEquality(possibleNextTokTypes, [EntityTok]) }) - it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in qualifiedNameSep", function () { + it("can compute the next possible token types inside the AT_LEAST_ONE_SEP in qualifiedNameSep", () => { let path:IRuleGrammarPath = { ruleStack: ["qualifiedNameSep"], occurrenceStack: [1], @@ -558,8 +558,8 @@ describe("The Grammar Interpeter namespace", function () { }) }) -describe("The NextTerminalAfterManyWalker", function () { - it("can compute the next possible token types after the MANY in QualifiedName", function () { +describe("The NextTerminalAfterManyWalker", () => { + it("can compute the next possible token types after the MANY in QualifiedName", () => { let result = new NextTerminalAfterManyWalker(qualifiedName, 1).startWalking() //noinspection BadExpressionStatementJS expect(result.occurrence).to.be.undefined @@ -567,15 +567,15 @@ describe("The NextTerminalAfterManyWalker", function () { expect(result.token).to.be.undefined }) - it("can compute the next possible token types after the MANY in paramSpec inside ActionDec", function () { + it("can compute the next possible token types after the MANY in paramSpec inside ActionDec", () => { let result = new NextTerminalAfterManyWalker(actionDec, 1).startWalking() expect(result.occurrence).to.equal(1) expect(result.token).to.equal(RParenTok) }) }) -describe("The NextTerminalAfterManySepWalker", function () { - it("can compute the next possible token types after the MANY_SEP in QualifiedName", function () { +describe("The NextTerminalAfterManySepWalker", () => { + it("can compute the next possible token types after the MANY_SEP in QualifiedName", () => { let result = new NextTerminalAfterManySepWalker(callArguments, 1).startWalking() //noinspection BadExpressionStatementJS expect(result.occurrence).to.be.undefined @@ -583,15 +583,15 @@ describe("The NextTerminalAfterManySepWalker", function () { expect(result.token).to.be.undefined }) - it("can compute the next possible token types after the MANY in paramSpec inside ActionDec", function () { + it("can compute the next possible token types after the MANY in paramSpec inside ActionDec", () => { let result = new NextTerminalAfterManySepWalker(actionDecSep, 1).startWalking() expect(result.occurrence).to.equal(1) expect(result.token).to.equal(RParenTok) }) }) -describe("The NextTerminalAfterAtLeastOneWalker", function () { - it("can compute the next possible token types after an AT_LEAST_ONE production", function () { +describe("The NextTerminalAfterAtLeastOneWalker", () => { + it("can compute the next possible token types after an AT_LEAST_ONE production", () => { let result = new NextTerminalAfterAtLeastOneWalker(atLeastOneRule, 1).startWalking() expect(result.occurrence).to.equal(2) expect(result.token).to.equal(DotTok) @@ -606,8 +606,8 @@ describe("The NextTerminalAfterAtLeastOneWalker", function () { }) }) -describe("The NextTerminalAfterAtLeastOneSepWalker", function () { - it("can compute the next possible token types after an AT_LEAST_ONE_SEP production", function () { +describe("The NextTerminalAfterAtLeastOneSepWalker", () => { + it("can compute the next possible token types after an AT_LEAST_ONE_SEP production", () => { let result = new NextTerminalAfterAtLeastOneSepWalker(atLeastOneSepRule, 1).startWalking() expect(result.occurrence).to.equal(2) expect(result.token).to.equal(DotTok) @@ -621,7 +621,7 @@ describe("The NextTerminalAfterAtLeastOneSepWalker", function () { expect(result3.token).to.equal(CommaTok) }) - it("can compute the next possible token types after an AT_LEAST_ONE_SEP production EMPTY", function () { + it("can compute the next possible token types after an AT_LEAST_ONE_SEP production EMPTY", () => { let result = new NextTerminalAfterAtLeastOneSepWalker(qualifiedNameSep, 1).startWalking() //noinspection BadExpressionStatementJS expect(result.occurrence).to.be.undefined @@ -630,16 +630,16 @@ describe("The NextTerminalAfterAtLeastOneSepWalker", function () { }) }) -describe("The NextInsideOrWalker", function () { +describe("The NextInsideOrWalker", () => { - it("can compute the First Tokens for all alternatives of an OR", function () { + it("can compute the First Tokens for all alternatives of an OR", () => { let result = new NextInsideOrWalker(cardinality, 1).startWalking() expect(result.length).to.equal(2) setEquality(result[0], [UnsignedIntegerLiteralTok]) setEquality(result[1], [AsteriskTok]) }) - it("can compute the First Tokens for all alternatives of an OR (complex)", function () { + it("can compute the First Tokens for all alternatives of an OR (complex)", () => { let result1 = new NextInsideOrWalker(lotsOfOrs, 1).startWalking() expect(result1.length).to.equal(2) setEquality(result1[0], [CommaTok, KeyTok]) diff --git a/test/parse/grammar/lookahead_spec.ts b/test/parse/grammar/lookahead_spec.ts index 2db19b00c..bc1f44502 100644 --- a/test/parse/grammar/lookahead_spec.ts +++ b/test/parse/grammar/lookahead_spec.ts @@ -45,31 +45,31 @@ class ActionParserMock extends Parser { } } -describe("The Grammar Lookahead namespace", function () { +describe("The Grammar Lookahead namespace", () => { "use strict" - it("can compute the lookahead function for the first OPTION in ActionDec", function () { + it("can compute the lookahead function for the first OPTION in ActionDec", () => { let laFunc = buildLookaheadForOption(1, actionDec) expect(laFunc.call(new ColonParserMock([], []))).to.equal(false) expect(laFunc.call(new IdentParserMock([], []))).to.equal(true) }) - it("can compute the lookahead function for the second OPTION in ActionDec", function () { + it("can compute the lookahead function for the second OPTION in ActionDec", () => { let laFunc = buildLookaheadForOption(2, actionDec) expect(laFunc.call(new ColonParserMock([], []))).to.equal(true) expect(laFunc.call(new IdentParserMock([], []))).to.equal(false) }) - it("can compute the lookahead function for the first MANY in ActionDec", function () { + it("can compute the lookahead function for the first MANY in ActionDec", () => { let laFunc = buildLookaheadForMany(1, actionDec) expect(laFunc.call(new CommaParserMock([], []))).to.equal(true) expect(laFunc.call(new IdentParserMock([], []))).to.equal(false) }) - it("can compute the lookahead function for lots of ORs sample", function () { + it("can compute the lookahead function for lots of ORs sample", () => { let laFunc = buildLookaheadForOr(1, lotsOfOrs) expect(laFunc.call(new CommaParserMock([], []))).to.equal(0) @@ -78,7 +78,7 @@ describe("The Grammar Lookahead namespace", function () { expect(laFunc.call(new ColonParserMock([], []))).to.equal(-1) }) - it("can compute the lookahead function for EMPTY OR sample", function () { + it("can compute the lookahead function for EMPTY OR sample", () => { let laFunc = buildLookaheadForOr(1, emptyAltOr) expect(laFunc.call(new KeyParserMock([], []))).to.equal(0) @@ -87,14 +87,14 @@ describe("The Grammar Lookahead namespace", function () { expect(laFunc.call(new CommaParserMock([], []))).to.equal(2) }) - it("can compute the lookahead function for a Top Level Rule", function () { + it("can compute the lookahead function for a Top Level Rule", () => { let laFunc = buildLookaheadForTopLevel(actionDec) expect(laFunc.call(new ActionParserMock([], []))).to.equal(true) expect(laFunc.call(new IdentParserMock([], []))).to.equal(false) }) - it("can compute the lookahead function for a Top Level Rule #2", function () { + it("can compute the lookahead function for a Top Level Rule #2", () => { let laFunc = buildLookaheadForTopLevel(lotsOfOrs) expect(laFunc.call(new CommaParserMock([], []))).to.equal(true) @@ -110,9 +110,9 @@ class C extends Token {} class D extends Token {} class E extends Token {} -describe("The Grammar Lookahead namespace", function () { +describe("The Grammar Lookahead namespace", () => { - it("can detect ambiguities when calculating lookahead functions for OR alternatives", function () { + it("can detect ambiguities when calculating lookahead functions for OR alternatives", () => { let input = [[A, B], [C, D], [E, C]] let ambiguities = checkAlternativesAmbiguities(input) expect(ambiguities.length).to.equal(1) diff --git a/test/parse/grammar/resolver_spec.ts b/test/parse/grammar/resolver_spec.ts index 46cbd6354..e248f72e6 100644 --- a/test/parse/grammar/resolver_spec.ts +++ b/test/parse/grammar/resolver_spec.ts @@ -3,9 +3,9 @@ import {HashTable} from "../../../src/lang/lang_extensions" import {GastRefResolverVisitor} from "../../../src/parse/grammar/resolver" import {ParserDefinitionErrorType} from "../../../src/parse/parser_public" -describe("The RefResolverVisitor", function () { +describe("The RefResolverVisitor", () => { - it("will fail when trying to resolve a ref to a grammar rule that does not exist", function () { + it("will fail when trying to resolve a ref to a grammar rule that does not exist", () => { let ref = new gast.NonTerminal("missingRule") let topLevel = new gast.Rule("TOP", [ref]) let topLevelRules = new HashTable() diff --git a/test/parse/recognizer_lookahead_spec.ts b/test/parse/recognizer_lookahead_spec.ts index 68acdb595..dc4085167 100644 --- a/test/parse/recognizer_lookahead_spec.ts +++ b/test/parse/recognizer_lookahead_spec.ts @@ -143,45 +143,45 @@ function isFiveTok():boolean { return this.NEXT_TOKEN() instanceof FiveTok } -describe("The implicit lookahead calculation functionality of the Recognizer For OPTION", function () { +describe("The implicit lookahead calculation functionality of the Recognizer For OPTION", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new OptionsImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can automatically compute lookahead for OPTION1", function () { + it("can automatically compute lookahead for OPTION1", () => { let input = [new OneTok()] let parser = new OptionsImplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("1") }) - it("can automatically compute lookahead for OPTION2", function () { + it("can automatically compute lookahead for OPTION2", () => { let input = [new TwoTok()] let parser = new OptionsImplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("2") }) - it("can automatically compute lookahead for OPTION3", function () { + it("can automatically compute lookahead for OPTION3", () => { let input = [new ThreeTok()] let parser = new OptionsImplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("3") }) - it("can automatically compute lookahead for OPTION4", function () { + it("can automatically compute lookahead for OPTION4", () => { let input = [new FourTok()] let parser = new OptionsImplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("4") }) - it("can automatically compute lookahead for OPTION5", function () { + it("can automatically compute lookahead for OPTION5", () => { let input = [new FiveTok()] let parser = new OptionsImplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("5") }) - it("will cache the generatedLookAhead functions AFTER (check cache is filled)", function () { + it("will cache the generatedLookAhead functions AFTER (check cache is filled)", () => { let parser = new OptionsImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(5) @@ -189,39 +189,39 @@ describe("The implicit lookahead calculation functionality of the Recognizer For }) -describe("The Explicit lookahead functionality of the Recognizer for OPTION", function () { +describe("The Explicit lookahead functionality of the Recognizer for OPTION", () => { - it("can accept lookahead function param for OPTION1", function () { + it("can accept lookahead function param for OPTION1", () => { let input = [new OneTok()] let parser = new OptionsExplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("1") }) - it("can accept lookahead function param for OPTION2", function () { + it("can accept lookahead function param for OPTION2", () => { let input = [new TwoTok()] let parser = new OptionsExplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("2") }) - it("can accept lookahead function param for OPTION3", function () { + it("can accept lookahead function param for OPTION3", () => { let input = [new ThreeTok()] let parser = new OptionsExplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("3") }) - it("can accept lookahead function param for OPTION4", function () { + it("can accept lookahead function param for OPTION4", () => { let input = [new FourTok()] let parser = new OptionsExplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("4") }) - it("can accept lookahead function param for OPTION5", function () { + it("can accept lookahead function param for OPTION5", () => { let input = [new FiveTok()] let parser = new OptionsExplicitLookAheadParser(input) expect(parser.manyOptionsRule()).to.equal("5") }) - it("Will not cache any ImplicitLookahead functions", function () { + it("Will not cache any ImplicitLookahead functions", () => { let parser = new OptionsExplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) @@ -319,51 +319,51 @@ class ManyExplicitLookAheadParser extends Parser { } } -describe("The implicit lookahead calculation functionality of the Recognizer For MANY", function () { +describe("The implicit lookahead calculation functionality of the Recognizer For MANY", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new ManyImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can automatically compute lookahead for MANY1", function () { + it("can automatically compute lookahead for MANY1", () => { let input = [new OneTok()] let parser = new ManyImplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("1") }) - it("can automatically compute lookahead for MANY2", function () { + it("can automatically compute lookahead for MANY2", () => { let input = [new TwoTok()] let parser = new ManyImplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("2") }) - it("can automatically compute lookahead for MANY3", function () { + it("can automatically compute lookahead for MANY3", () => { let input = [new ThreeTok()] let parser = new ManyImplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("3") }) - it("can automatically compute lookahead for MANY4", function () { + it("can automatically compute lookahead for MANY4", () => { let input = [new FourTok()] let parser = new ManyImplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("4") }) - it("can automatically compute lookahead for MANY5", function () { + it("can automatically compute lookahead for MANY5", () => { let input = [new FiveTok()] let parser = new ManyImplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("5") }) - it("can accept lookahead function param for flow mixing several MANYs", function () { + it("can accept lookahead function param for flow mixing several MANYs", () => { let input = [new OneTok(), new OneTok(), new ThreeTok(), new ThreeTok(), new ThreeTok(), new FiveTok()] let parser = new ManyImplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("113335") }) - it("will cache the generatedLookAhead functions AFTER (check cache is filled)", function () { + it("will cache the generatedLookAhead functions AFTER (check cache is filled)", () => { let parser = new ManyImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(5) @@ -371,45 +371,45 @@ describe("The implicit lookahead calculation functionality of the Recognizer For }) -describe("The Explicit lookahead functionality of the Recognizer for MANY", function () { +describe("The Explicit lookahead functionality of the Recognizer for MANY", () => { - it("can accept lookahead function param for MANY1", function () { + it("can accept lookahead function param for MANY1", () => { let input = [new OneTok()] let parser = new ManyExplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("1") }) - it("can accept lookahead function param for MANY2", function () { + it("can accept lookahead function param for MANY2", () => { let input = [new TwoTok()] let parser = new ManyExplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("2") }) - it("can accept lookahead function param for MANY3", function () { + it("can accept lookahead function param for MANY3", () => { let input = [new ThreeTok()] let parser = new ManyExplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("3") }) - it("can accept lookahead function param for MANY4", function () { + it("can accept lookahead function param for MANY4", () => { let input = [new FourTok()] let parser = new ManyExplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("4") }) - it("can accept lookahead function param for MANY5", function () { + it("can accept lookahead function param for MANY5", () => { let input = [new FiveTok()] let parser = new ManyExplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("5") }) - it("can accept lookahead function param for flow mixing several MANYs", function () { + it("can accept lookahead function param for flow mixing several MANYs", () => { let input = [new OneTok(), new OneTok(), new ThreeTok(), new ThreeTok(), new ThreeTok(), new FiveTok()] let parser = new ManyExplicitLookAheadParser(input) expect(parser.manyRule()).to.equal("113335") }) - it("Will not cache any ImplicitLookahead functions when provided with explicit versions", function () { + it("Will not cache any ImplicitLookahead functions when provided with explicit versions", () => { let parser = new ManyExplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) @@ -509,45 +509,45 @@ class ManySepExplicitLookAheadParser extends Parser { } } -describe("The implicit lookahead calculation functionality of the Recognizer For MANY_SEP", function () { +describe("The implicit lookahead calculation functionality of the Recognizer For MANY_SEP", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new ManySepImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can automatically compute lookahead for MANY_SEP1", function () { + it("can automatically compute lookahead for MANY_SEP1", () => { let input = [new OneTok()] let parser = new ManySepImplicitLookAheadParser(input) expect(parser.manySepRule().total).to.equal("1") }) - it("can automatically compute lookahead for MANY_SEP2", function () { + it("can automatically compute lookahead for MANY_SEP2", () => { let input = [new TwoTok()] let parser = new ManySepImplicitLookAheadParser(input) expect(parser.manySepRule().total).to.equal("2") }) - it("can automatically compute lookahead for MANY_SEP3", function () { + it("can automatically compute lookahead for MANY_SEP3", () => { let input = [new ThreeTok()] let parser = new ManySepImplicitLookAheadParser(input) expect(parser.manySepRule().total).to.equal("3") }) - it("can automatically compute lookahead for MANY_SEP4", function () { + it("can automatically compute lookahead for MANY_SEP4", () => { let input = [new FourTok()] let parser = new ManySepImplicitLookAheadParser(input) expect(parser.manySepRule().total).to.equal("4") }) - it("can automatically compute lookahead for MANY_SEP5", function () { + it("can automatically compute lookahead for MANY_SEP5", () => { let input = [new FiveTok()] let parser = new ManySepImplicitLookAheadParser(input) expect(parser.manySepRule().total).to.equal("5") }) - it("can accept lookahead function param for flow mixing several MANY_SEPs", function () { + it("can accept lookahead function param for flow mixing several MANY_SEPs", () => { let input = [new OneTok(), new Comma(), new OneTok(), new ThreeTok(), new Comma(), new ThreeTok(), new Comma(), new ThreeTok(), new FiveTok()] let parser = new ManySepImplicitLookAheadParser(input) @@ -557,7 +557,7 @@ describe("The implicit lookahead calculation functionality of the Recognizer For expect(result.separators).to.deep.equal([new Comma(), new Comma(), new Comma()]) }) - it("will cache the generatedLookAhead functions AFTER (check cache is filled)", function () { + it("will cache the generatedLookAhead functions AFTER (check cache is filled)", () => { let parser = new ManySepImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(5) @@ -565,46 +565,46 @@ describe("The implicit lookahead calculation functionality of the Recognizer For }) -describe("The Explicit lookahead functionality of the Recognizer for MANY", function () { +describe("The Explicit lookahead functionality of the Recognizer for MANY", () => { - it("can accept lookahead function param for MANY1", function () { + it("can accept lookahead function param for MANY1", () => { let input = [new OneTok()] let parser = new ManySepExplicitLookAheadParser(input) expect(parser.manySepRule()).to.equal("1") }) - it("can accept lookahead function param for MANY2", function () { + it("can accept lookahead function param for MANY2", () => { let input = [new TwoTok()] let parser = new ManySepExplicitLookAheadParser(input) expect(parser.manySepRule()).to.equal("2") }) - it("can accept lookahead function param for MANY3", function () { + it("can accept lookahead function param for MANY3", () => { let input = [new ThreeTok()] let parser = new ManySepExplicitLookAheadParser(input) expect(parser.manySepRule()).to.equal("3") }) - it("can accept lookahead function param for MANY4", function () { + it("can accept lookahead function param for MANY4", () => { let input = [new FourTok()] let parser = new ManySepExplicitLookAheadParser(input) expect(parser.manySepRule()).to.equal("4") }) - it("can accept lookahead function param for MANY5", function () { + it("can accept lookahead function param for MANY5", () => { let input = [new FiveTok()] let parser = new ManySepExplicitLookAheadParser(input) expect(parser.manySepRule()).to.equal("5") }) - it("can accept lookahead function param for flow mixing several MANYs", function () { + it("can accept lookahead function param for flow mixing several MANYs", () => { let input = [new OneTok(), new Comma(), new OneTok(), new ThreeTok(), new Comma(), new ThreeTok(), new Comma(), new ThreeTok(), new FiveTok()] let parser = new ManySepExplicitLookAheadParser(input) expect(parser.manySepRule()).to.equal("113335") }) - it("Will not cache any ImplicitLookahead functions when provided with explicit versions", function () { + it("Will not cache any ImplicitLookahead functions when provided with explicit versions", () => { let parser = new ManySepExplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) @@ -702,50 +702,50 @@ class AtLeastOneExplicitLookAheadParser extends Parser { } } -describe("The implicit lookahead calculation functionality of the Recognizer For AT_LEAST_ONE", function () { +describe("The implicit lookahead calculation functionality of the Recognizer For AT_LEAST_ONE", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new AtLeastOneImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can accept lookahead function param for AT_LEAST_ONE1-5", function () { + it("can accept lookahead function param for AT_LEAST_ONE1-5", () => { let input = [new OneTok(), new TwoTok(), new TwoTok(), new ThreeTok(), new FourTok(), new FourTok(), new FiveTok()] let parser = new AtLeastOneImplicitLookAheadParser(input) expect(parser.atLeastOneRule()).to.equal("1223445") }) - it("will fail when zero occurrences of AT_LEAST_ONE in input", function () { + it("will fail when zero occurrences of AT_LEAST_ONE in input", () => { let input = [new OneTok(), new TwoTok(), /*new ThreeTok(),*/ new FourTok(), new FiveTok()] let parser = new AtLeastOneImplicitLookAheadParser(input) expect(parser.atLeastOneRule()).to.equal("-666") }) - it("will cache the generatedLookAhead functions AFTER (check cache is filled)", function () { + it("will cache the generatedLookAhead functions AFTER (check cache is filled)", () => { let parser = new AtLeastOneImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(5) }) }) -describe("The Explicit lookahead functionality of the Recognizer for AT_LEAST_ONE", function () { +describe("The Explicit lookahead functionality of the Recognizer for AT_LEAST_ONE", () => { - it("can accept lookahead function param for AT_LEAST_ONE1-5", function () { + it("can accept lookahead function param for AT_LEAST_ONE1-5", () => { let input = [new OneTok(), new TwoTok(), new TwoTok(), new ThreeTok(), new FourTok(), new FourTok(), new FiveTok()] let parser = new AtLeastOneExplicitLookAheadParser(input) expect(parser.atLeastOneRule()).to.equal("1223445") }) - it("will fail when zero occurrences of AT_LEAST_ONE in input", function () { + it("will fail when zero occurrences of AT_LEAST_ONE in input", () => { let input = [new OneTok(), new TwoTok(), /*new ThreeTok(),*/ new FourTok(), new FiveTok()] let parser = new AtLeastOneExplicitLookAheadParser(input) expect(parser.atLeastOneRule()).to.equal("-666") }) - it("Will not cache any ImplicitLookahead functions when provided with explicit versions", function () { + it("Will not cache any ImplicitLookahead functions when provided with explicit versions", () => { let parser = new AtLeastOneExplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) @@ -849,15 +849,15 @@ class AtLeastOneSepExplicitLookAheadParser extends Parser { } } -describe("The implicit lookahead calculation functionality of the Recognizer For AT_LEAST_ONE_SEP", function () { +describe("The implicit lookahead calculation functionality of the Recognizer For AT_LEAST_ONE_SEP", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new AtLeastOneSepImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can accept lookahead function param for AT_LEAST_ONE_SEP1-5", function () { + it("can accept lookahead function param for AT_LEAST_ONE_SEP1-5", () => { let input = [new OneTok(), new TwoTok(), new Comma(), new TwoTok(), new ThreeTok(), new FourTok(), new Comma(), new FourTok(), new FiveTok()] let parser = new AtLeastOneSepImplicitLookAheadParser(input) @@ -866,35 +866,35 @@ describe("The implicit lookahead calculation functionality of the Recognizer For expect(parseResult.separators).to.deep.equal([new Comma(), new Comma()]) }) - it("will fail when zero occurrences of AT_LEAST_ONE_SEP in input", function () { + it("will fail when zero occurrences of AT_LEAST_ONE_SEP in input", () => { let input = [new OneTok(), new TwoTok(), /*new ThreeTok(),*/ new FourTok(), new FiveTok()] let parser = new AtLeastOneSepImplicitLookAheadParser(input) expect(parser.atLeastOneSepRule().total).to.equal("-666") }) - it("will cache the generatedLookAhead functions AFTER (check cache is filled)", function () { + it("will cache the generatedLookAhead functions AFTER (check cache is filled)", () => { let parser = new AtLeastOneSepImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(5) }) }) -describe("The Explicit lookahead functionality of the Recognizer for AT_LEAST_ONE_SEP", function () { +describe("The Explicit lookahead functionality of the Recognizer for AT_LEAST_ONE_SEP", () => { - it("can accept lookahead function param for AT_LEAST_ONE_SEP1-5", function () { + it("can accept lookahead function param for AT_LEAST_ONE_SEP1-5", () => { let input = [new OneTok(), new TwoTok(), new Comma(), new TwoTok(), new ThreeTok(), new FourTok(), new Comma(), new FourTok(), new FiveTok()] let parser = new AtLeastOneSepExplicitLookAheadParser(input) expect(parser.atLeastOneSepRule()).to.equal("1223445") }) - it("will fail when zero occurrences of AT_LEAST_ONE_SEP in input", function () { + it("will fail when zero occurrences of AT_LEAST_ONE_SEP in input", () => { let input = [new OneTok(), new TwoTok(), /*new ThreeTok(),*/ new FourTok(), new FiveTok()] let parser = new AtLeastOneSepExplicitLookAheadParser(input) expect(parser.atLeastOneSepRule()).to.equal("-666") }) - it("Will not cache any ImplicitLookahead functions when provided with explicit versions", function () { + it("Will not cache any ImplicitLookahead functions when provided with explicit versions", () => { let parser = new AtLeastOneSepExplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) @@ -1039,27 +1039,27 @@ class OrImplicitLookAheadParser extends Parser { } } -describe("The implicit lookahead calculation functionality of the Recognizer For OR", function () { +describe("The implicit lookahead calculation functionality of the Recognizer For OR", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new OrImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can compute the lookahead automatically for OR1-5", function () { + it("can compute the lookahead automatically for OR1-5", () => { let input = [new OneTok(), new TwoTok(), new ThreeTok(), new FourTok(), new FiveTok()] let parser = new OrImplicitLookAheadParser(input) expect(parser.orRule()).to.equal("A1B2C3D4E5") }) - it("will fail when none of the alternatives match", function () { + it("will fail when none of the alternatives match", () => { let input = [new SixTok()] let parser = new OrImplicitLookAheadParser(input) expect(parser.orRule()).to.equal("-666") }) - it("will cache the generatedLookAhead functions AFTER (check cache is filled)", function () { + it("will cache the generatedLookAhead functions AFTER (check cache is filled)", () => { let parser = new OrImplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(5) @@ -1111,27 +1111,27 @@ class OrExplicitLookAheadParser extends Parser { } } -describe("The Explicit lookahead functionality of the Recognizer for OR", function () { +describe("The Explicit lookahead functionality of the Recognizer for OR", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new OrExplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can accept the lookahead param explicitly for OR", function () { + it("can accept the lookahead param explicitly for OR", () => { let input = [new TwoTok()] let parser = new OrExplicitLookAheadParser(input) expect(parser.orRule()).to.equal("2") }) - it("will fail when none of the alternatives match", function () { + it("will fail when none of the alternatives match", () => { let input = [new SixTok()] let parser = new OrExplicitLookAheadParser(input) expect(parser.orRule()).to.equal("-666") }) - it("will NOT cache the generatedLookAhead functions in explicit mode", function () { + it("will NOT cache the generatedLookAhead functions in explicit mode", () => { let parser = new OrExplicitLookAheadParser() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) @@ -1170,9 +1170,9 @@ class OrAmbiguityLookAheadParser extends Parser { } } -describe("OR production ambiguity detection when using implicit lookahead calculation", function () { +describe("OR production ambiguity detection when using implicit lookahead calculation", () => { - it("will throw an error when two alternatives have the same single token (lookahead 1) prefix", function () { + it("will throw an error when two alternatives have the same single token (lookahead 1) prefix", () => { let parser = new OrAmbiguityLookAheadParser() expect(() => parser.ambiguityRule()).to.throw("Ambiguous alternatives") }) @@ -1311,27 +1311,27 @@ class OrImplicitLookAheadParserIgnoreAmbiguities extends Parser { } } -describe("The implicit lookahead calculation functionality of the Recognizer For OR (with IGNORE_AMBIGUITIES)", function () { +describe("The implicit lookahead calculation functionality of the Recognizer For OR (with IGNORE_AMBIGUITIES)", () => { - it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", function () { + it("will cache the generatedLookAhead functions BEFORE (check cache is clean)", () => { let parser = new OrImplicitLookAheadParserIgnoreAmbiguities() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(0) }) - it("can compute the lookahead automatically for OR1-5", function () { + it("can compute the lookahead automatically for OR1-5", () => { let input = [new OneTok(), new TwoTok(), new ThreeTok(), new FourTok(), new FiveTok()] let parser = new OrImplicitLookAheadParserIgnoreAmbiguities(input) expect(parser.orRule()).to.equal("A1B2C3D4E5") }) - it("will fail when none of the alternatives match", function () { + it("will fail when none of the alternatives match", () => { let input = [new SixTok()] let parser = new OrImplicitLookAheadParserIgnoreAmbiguities(input) expect(parser.orRule()).to.equal("-666") }) - it("will cache the generatedLookAhead functions AFTER (check cache is filled)", function () { + it("will cache the generatedLookAhead functions AFTER (check cache is filled)", () => { let parser = new OrImplicitLookAheadParserIgnoreAmbiguities() let lookaheadCache = parser.getLookAheadCache() expect(lookaheadCache.keys().length).to.equal(5) diff --git a/test/parse/recognizer_spec.ts b/test/parse/recognizer_spec.ts index dd2566da6..c1a94d05c 100644 --- a/test/parse/recognizer_spec.ts +++ b/test/parse/recognizer_spec.ts @@ -251,16 +251,16 @@ class CustomLookaheadParser extends Parser { }) } -describe("The Parsing DSL", function () { +describe("The Parsing DSL", () => { - it("provides a production SUBRULE1-5 that invokes another rule", function () { + it("provides a production SUBRULE1-5 that invokes another rule", () => { let input = [new PlusTok(), new PlusTok(), new PlusTok(), new PlusTok(), new PlusTok()] let parser = new SubRuleTestParser(input) let result = parser.topRule() expect(result).to.equal("12345") }) - it("provides a production SUBRULE1-5 that can accept arguments from its caller", function () { + it("provides a production SUBRULE1-5 that can accept arguments from its caller", () => { let input = [new PlusTok(), new PlusTok(), new PlusTok(), new PlusTok(), new PlusTok()] let parser = new SubRuleArgsParser(input) let result = parser.topRule() @@ -268,7 +268,7 @@ describe("The Parsing DSL", function () { expect(result.numbers).to.equal("54321") }) - it("allows using automatic lookahead even as part of custom lookahead functions valid", function () { + it("allows using automatic lookahead even as part of custom lookahead functions valid", () => { let input1 = [new PlusTok()] let parser = new CustomLookaheadParser(input1) let result = parser.topRule() @@ -280,7 +280,7 @@ describe("The Parsing DSL", function () { expect(result2).to.equal("minus") }) - it("allows using automatic lookahead even as part of custom lookahead functions invalid", function () { + it("allows using automatic lookahead even as part of custom lookahead functions invalid", () => { let input1 = [new PlusTok()] let parser = new CustomLookaheadParser(input1) parser.plusAllowed = false @@ -322,7 +322,7 @@ describe("The Parsing DSL", function () { } } - it("can match an non-empty alternative in an OR with an empty alternative", function () { + it("can match an non-empty alternative in an OR with an empty alternative", () => { let input = [new PlusTok()] let parser = new EmptyAltParser(input) expect(parser.orRule()).to.equal("+") @@ -344,9 +344,9 @@ describe("The Parsing DSL", function () { }) }) -describe("The Error Recovery functionality of the IntrospectionParser", function () { +describe("The Error Recovery functionality of the IntrospectionParser", () => { - it("can CONSUME tokens with an index specifying the occurrence for the specific token in the current rule", function () { + it("can CONSUME tokens with an index specifying the occurrence for the specific token in the current rule", () => { let parser:any = new Parser([], ALL_TOKENS) parser.reset() let testInput = [new IntToken("1"), new PlusTok(), @@ -361,13 +361,13 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.NEXT_TOKEN()).to.be.an.instanceof(EOF) }) - it("will not perform inRepetition recovery while in backtracking mode", function () { + it("will not perform inRepetition recovery while in backtracking mode", () => { let parser:any = new Parser([], {}) parser.isBackTrackingStack.push(1) expect(parser.shouldInRepetitionRecoveryBeTried(MinusTok, 1)).to.equal(false) }) - it("can perform in-repetition recovery for MANY grammar rule", function () { + it("can perform in-repetition recovery for MANY grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -376,7 +376,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(1) }) - it("can disable in-repetition recovery for MANY grammar rule", function () { + it("can disable in-repetition recovery for MANY grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -385,7 +385,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(1) }) - it("can perform in-repetition recovery for MANY_SEP grammar rule", function () { + it("can perform in-repetition recovery for MANY_SEP grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -394,7 +394,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(1) }) - it("can disable in-repetition recovery for MANY_SEP grammar rule", function () { + it("can disable in-repetition recovery for MANY_SEP grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -403,7 +403,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(1) }) - it("can perform in-repetition recovery for MANY_SEP grammar rule #2", function () { + it("can perform in-repetition recovery for MANY_SEP grammar rule #2", () => { // a.b..c...d let input = [new IdentTok("a"), new DotTok(), new DotTok(), new IdentTok("b"), new DotTok(), new IdentTok("c"), new DotTok(), new DotTok(), new DotTok(), new IdentTok("d")] @@ -412,7 +412,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(3) }) - it("can perform in-repetition recovery for AT_LEAST_ONE grammar rule", function () { + it("can perform in-repetition recovery for AT_LEAST_ONE grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -421,7 +421,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(1) }) - it("can disable in-repetition recovery for AT_LEAST_ONE grammar rule", function () { + it("can disable in-repetition recovery for AT_LEAST_ONE grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -430,7 +430,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(1) }) - it("can perform in-repetition recovery for AT_LEAST_ONE_SEP grammar rule", function () { + it("can perform in-repetition recovery for AT_LEAST_ONE_SEP grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -439,7 +439,7 @@ describe("The Error Recovery functionality of the IntrospectionParser", function expect(parser.errors.length).to.equal(1) }) - it("can disable in-repetition recovery for AT_LEAST_ONE_SEP grammar rule", function () { + it("can disable in-repetition recovery for AT_LEAST_ONE_SEP grammar rule", () => { // a.b+.c let input = [new IdentTok("a"), new DotTok(), new IdentTok("b"), new PlusTok(), new DotTok(), new IdentTok("c")] @@ -449,22 +449,22 @@ describe("The Error Recovery functionality of the IntrospectionParser", function }) }) -describe("The BaseRecognizer", function () { +describe("The BaseRecognizer", () => { - it("can be initialized without supplying an input vector", function () { + it("can be initialized without supplying an input vector", () => { let parser = new Parser([], []) expect(parser.input).to.deep.equal([]) expect(parser.input).to.be.an.instanceof(Array) }) - it("can only SAVE_ERROR for recognition exceptions", function () { + it("can only SAVE_ERROR for recognition exceptions", () => { let parser:any = new Parser([], []) expect(() => parser.SAVE_ERROR(new Error("I am some random Error"))) .to.throw("trying to save an Error which is not a RecognitionException") expect(parser.input).to.be.an.instanceof(Array) }) - it("when it runs out of input EOF will be returned", function () { + it("when it runs out of input EOF will be returned", () => { let parser:any = new Parser([new IntToken("1"), new PlusTok()], []) parser.CONSUME(IntToken) parser.CONSUME(PlusTok) @@ -476,7 +476,7 @@ describe("The BaseRecognizer", function () { // see: http://en.wikipedia.org/wiki/Tony_Hoare#Apologies_and_retractions }) - it("invoking an OPTION will return true/false depending if it succeeded or not", function () { + it("invoking an OPTION will return true/false depending if it succeeded or not", () => { let parser:any = new Parser([new IntToken("1"), new PlusTok()], {}) let successfulOption = parser.OPTION(function () { return this.NEXT_TOKEN() instanceof IntToken }, () => { @@ -493,7 +493,7 @@ describe("The BaseRecognizer", function () { }) it("will return false if a RecognitionException is thrown during " + - "backtracking and rethrow any other kind of Exception", function () { + "backtracking and rethrow any other kind of Exception", () => { let parser:any = new Parser([], []) let backTrackingThrows = parser.BACKTRACK(() => {throw new Error("division by zero, boom")}, () => { return true }) expect(() => backTrackingThrows()).to.throw("division by zero, boom") @@ -505,9 +505,9 @@ describe("The BaseRecognizer", function () { }) -describe("The BaseRecognizer", function () { +describe("The BaseRecognizer", () => { - it("can be initialized with a vector of Tokens", function () { + it("can be initialized with a vector of Tokens", () => { let parser:any = new Parser([], [PlusTok, MinusTok, IntToken]) let tokensMap = (parser).tokensMap expect(tokensMap.PlusTok).to.equal(PlusTok) @@ -515,7 +515,7 @@ describe("The BaseRecognizer", function () { expect(tokensMap.IntToken).to.equal(IntToken) }) - it("can be initialized with a Dictionary of Tokens", function () { + it("can be initialized with a Dictionary of Tokens", () => { let initTokenDictionary = {PlusTok: PlusTok, MinusTok: MinusTok, IntToken: IntToken} let parser:any = new Parser([], { PlusTok: PlusTok, @@ -530,7 +530,7 @@ describe("The BaseRecognizer", function () { expect(tokensMap.IntToken).to.equal(IntToken) }) - it("cannot be initialized with other parameters", function () { + it("cannot be initialized with other parameters", () => { expect(() => { return new Parser([], null) }).to.throw() diff --git a/test/scan/lexer_spec.ts b/test/scan/lexer_spec.ts index 112bb365b..63ae70b62 100644 --- a/test/scan/lexer_spec.ts +++ b/test/scan/lexer_spec.ts @@ -30,9 +30,9 @@ let patterns:RegExp[] = _.collect(_.values(patternsToClass), "PATTERN") let testLexer = new Lexer([BambaTok, IntegerTok, IdentifierTok]) -describe("The Chevrotain Simple Lexer", function () { +describe("The Chevrotain Simple Lexer", () => { - it("can create a token from a string with priority to the First Token class with the longest match #1", function () { + it("can create a token from a string with priority to the First Token class with the longest match #1", () => { // this can match either IdentifierTok or BambaTok but should match BambaTok has its pattern is defined before IdentifierTok let input = "bamba" let result = testLexer.tokenize(input) @@ -42,7 +42,7 @@ describe("The Chevrotain Simple Lexer", function () { expect(result.tokens[0].startColumn).to.equal(1) }) - it("can create a token from a string with priority to the First Token class with the longest match #2", function () { + it("can create a token from a string with priority to the First Token class with the longest match #2", () => { let input = "bambaMIA" let result = testLexer.tokenize(input) expect(result.tokens[0]).to.be.an.instanceof(IdentifierTok) @@ -51,7 +51,7 @@ describe("The Chevrotain Simple Lexer", function () { expect(result.tokens[0].startColumn).to.equal(1) }) - it("can create a token from a string", function () { + it("can create a token from a string", () => { let input = "6666543221231" let result = testLexer.tokenize(input) expect(result.tokens[0]).to.be.an.instanceof(IntegerTok) @@ -113,16 +113,16 @@ class InvalidGroupNumber extends Token { static GROUP = 666 } -describe("The Simple Lexer Validations", function () { +describe("The Simple Lexer Validations", () => { - it("won't detect valid patterns as missing", function () { + it("won't detect valid patterns as missing", () => { let result = findMissingPatterns([BambaTok, IntegerTok, IdentifierTok]) //noinspection BadExpressionStatementJS expect(result.errors).to.be.empty expect(result.validTokenClasses).to.deep.equal([BambaTok, IntegerTok, IdentifierTok]) }) - it("will detect missing patterns", function () { + it("will detect missing patterns", () => { let tokenClasses = [ValidNaPattern, MissingPattern] let result = findMissingPatterns(tokenClasses) expect(result.errors.length).to.equal(1) @@ -132,14 +132,14 @@ describe("The Simple Lexer Validations", function () { expect(result.validTokenClasses).to.deep.equal([ValidNaPattern]) }) - it("won't detect valid patterns as invalid", function () { + it("won't detect valid patterns as invalid", () => { let result = findInvalidPatterns([BambaTok, IntegerTok, IdentifierTok, ValidNaPattern]) //noinspection BadExpressionStatementJS expect(result.errors).to.be.empty expect(result.validTokenClasses).to.deep.equal([BambaTok, IntegerTok, IdentifierTok, ValidNaPattern]) }) - it("will detect invalid patterns as invalid", function () { + it("will detect invalid patterns as invalid", () => { let tokenClasses = [ValidNaPattern, InvalidPattern] let result = findInvalidPatterns(tokenClasses) expect(result.errors.length).to.equal(1) @@ -149,13 +149,13 @@ describe("The Simple Lexer Validations", function () { expect(result.validTokenClasses).to.deep.equal([ValidNaPattern]) }) - it("won't detect valid patterns as using unsupported flags", function () { + it("won't detect valid patterns as using unsupported flags", () => { let errors = findUnsupportedFlags([BambaTok, IntegerTok, IdentifierTok, CaseInsensitivePattern]) //noinspection BadExpressionStatementJS expect(errors).to.be.empty }) - it("will detect patterns using unsupported multiline flag", function () { + it("will detect patterns using unsupported multiline flag", () => { let tokenClasses = [ValidNaPattern, MultiLinePattern] let errors = findUnsupportedFlags(tokenClasses) expect(errors.length).to.equal(1) @@ -164,7 +164,7 @@ describe("The Simple Lexer Validations", function () { expect(errors[0].message).to.contain("MultiLinePattern") }) - it("will detect patterns using unsupported global flag", function () { + it("will detect patterns using unsupported global flag", () => { let tokenClasses = [ValidNaPattern, GlobalPattern] let errors = findUnsupportedFlags(tokenClasses) expect(errors.length).to.equal(1) @@ -173,19 +173,19 @@ describe("The Simple Lexer Validations", function () { expect(errors[0].message).to.contain("GlobalPattern") }) - it("won't detect valid patterns as duplicates", function () { + it("won't detect valid patterns as duplicates", () => { let errors = findDuplicatePatterns([MultiLinePattern, IntegerValid]) //noinspection BadExpressionStatementJS expect(errors).to.be.empty }) - it("won't detect NA patterns as duplicates", function () { + it("won't detect NA patterns as duplicates", () => { let errors = findDuplicatePatterns([ValidNaPattern, ValidNaPattern2]) //noinspection BadExpressionStatementJS expect(errors).to.be.empty }) - it("will detect patterns using unsupported end of input anchor", function () { + it("will detect patterns using unsupported end of input anchor", () => { let tokenClasses = [ValidNaPattern, EndOfInputAnchor] let errors = findEndOfInputAnchor(tokenClasses) expect(errors.length).to.equal(1) @@ -194,13 +194,13 @@ describe("The Simple Lexer Validations", function () { expect(errors[0].message).to.contain("EndOfInputAnchor") }) - it("won't detect valid patterns as using unsupported end of input anchor", function () { + it("won't detect valid patterns as using unsupported end of input anchor", () => { let errors = findEndOfInputAnchor([IntegerTok, IntegerValid]) //noinspection BadExpressionStatementJS expect(errors).to.be.empty }) - it("will detect identical patterns for different classes", function () { + it("will detect identical patterns for different classes", () => { let tokenClasses = [DecimalInvalid, IntegerValid] let errors = findDuplicatePatterns(tokenClasses) expect(errors.length).to.equal(1) @@ -210,13 +210,13 @@ describe("The Simple Lexer Validations", function () { expect(errors[0].message).to.contain("DecimalInvalid") }) - it("won't detect valid groups as unsupported", function () { + it("won't detect valid groups as unsupported", () => { let errors = findInvalidGroupType([IntegerTok, Skipped, Special]) //noinspection BadExpressionStatementJS expect(errors).to.be.empty }) - it("will detect unsupported group types", function () { + it("will detect unsupported group types", () => { let tokenClasses = [InvalidGroupNumber] let errors = findInvalidGroupType(tokenClasses) expect(errors.length).to.equal(1) @@ -261,23 +261,23 @@ class WhitespaceOrAmp extends Token { } -describe("The Simple Lexer transformations", function () { +describe("The Simple Lexer transformations", () => { - it("can transform a pattern to one with startOfInput mark ('^') #1 (NO OP)", function () { + it("can transform a pattern to one with startOfInput mark ('^') #1 (NO OP)", () => { let orgSource = BambaTok.PATTERN.source let transPattern = addStartOfInput(BambaTok.PATTERN) expect(transPattern.source).to.equal("^(?:" + orgSource + ")") expect(_.startsWith(transPattern.source, "^")).to.equal(true) }) - it("can transform a pattern to one with startOfInput mark ('^') #2", function () { + it("can transform a pattern to one with startOfInput mark ('^') #2", () => { let orgSource = PatternNoStart.PATTERN.source let transPattern = addStartOfInput(PatternNoStart.PATTERN) expect(transPattern.source).to.equal("^(?:" + orgSource + ")") expect(_.startsWith(transPattern.source, "^")).to.equal(true) }) - it("can transform/analyze an array of Token Classes into matched/ignored/patternToClass", function () { + it("can transform/analyze an array of Token Classes into matched/ignored/patternToClass", () => { let tokenClasses = [Keyword, If, Else, Return, Integer, Punctuation, LParen, RParen, Whitespace, NewLine] let analyzeResult = analyzeTokenClasses(tokenClasses) expect(analyzeResult.allPatterns.length).to.equal(8) @@ -299,16 +299,16 @@ describe("The Simple Lexer transformations", function () { expect(patternIdxToClass[7]).to.equal(NewLine); }) - it("can count the number of line terminators in a string", function () { + it("can count the number of line terminators in a string", () => { expect(countLineTerminators("bamba\r\nbisli\r")).to.equal(2) expect(countLineTerminators("\r\r\r1234\r\n")).to.equal(4) expect(countLineTerminators("aaaa\raaa\n\r1234\n")).to.equal(4) }) }) -describe("The Simple Lexer Full flow", function () { +describe("The Simple Lexer Full flow", () => { - it("can create a simple Lexer from a List of Token Classes", function () { + it("can create a simple Lexer from a List of Token Classes", () => { let ifElseLexer = new Lexer([Keyword, If, Else, Return, Integer, Punctuation, LParen, RParen, Whitespace, NewLine]) //noinspection BadExpressionStatementJS expect(ifElseLexer.lexerDefinitionErrors).to.be.empty @@ -326,12 +326,12 @@ describe("The Simple Lexer Full flow", function () { // new NewLine(1, 18, "\n"), new Whitespace(2, 1, "\t"), new Whitespace(2, 6, " "), new Whitespace(2, 13, " ")]) }) - it("Will throw an error during the creation of a Lexer if the Lexer's definition is invalid", function () { + it("Will throw an error during the creation of a Lexer if the Lexer's definition is invalid", () => { expect(() => new Lexer([EndOfInputAnchor, If, Else])).to.throw(/Errors detected in definition of Lexer/) expect(() => new Lexer([EndOfInputAnchor, If, Else])).to.throw(/EndOfInputAnchor/) }) - it("can defer the throwing of errors during the creation of a Lexer if the Lexer's definition is invalid", function () { + it("can defer the throwing of errors during the creation of a Lexer if the Lexer's definition is invalid", () => { expect(() => new Lexer([EndOfInputAnchor, If, Else], true)).to.not.throw(/Errors detected in definition of Lexer/) expect(() => new Lexer([EndOfInputAnchor, If, Else], true)).to.not.throw(/EndOfInputAnchor/) @@ -343,7 +343,7 @@ describe("The Simple Lexer Full flow", function () { expect(() => lexerWithErrs.tokenize("else")).to.throw(/EndOfInputAnchor/) }) - it("can skip invalid character inputs and only report one error per sequence of characters skipped", function () { + it("can skip invalid character inputs and only report one error per sequence of characters skipped", () => { let ifElseLexer = new Lexer([Keyword, If, Else, Return, Integer, Punctuation, LParen, RParen, Whitespace, NewLine]) @@ -365,7 +365,7 @@ describe("The Simple Lexer Full flow", function () { // new NewLine(1, 24, "\n"), new Whitespace(2, 1, "\t"), new Whitespace(2, 6, " "), new Whitespace(2, 13, " ")]) }) - it("won't go into infinite loops when skipping at end of input", function () { + it("won't go into infinite loops when skipping at end of input", () => { let ifElseLexer = new Lexer([Keyword, If, Else, Return, Integer, Punctuation, LParen, RParen, Whitespace, NewLine]) let input = "if&&&&&&&&&&&&&&&&&&&&&&&&&&&&" @@ -378,7 +378,7 @@ describe("The Simple Lexer Full flow", function () { expect(lexResult.tokens).to.deep.equal([new If("if", 0, 1, 1)]) }) - it("can deal with line terminators during resync", function () { + it("can deal with line terminators during resync", () => { let ifElseLexer = new Lexer([If, Else]) // no newLine tokens those will be resynced let input = "if\r\nelse\rif\r" @@ -401,7 +401,7 @@ describe("The Simple Lexer Full flow", function () { expect(lexResult.tokens).to.deep.equal([new If("if", 0, 1, 1), new Else("else", 4, 2, 1), new If("if", 9, 3, 1)]) }) - it("can deal with line terminators inside multi-line Tokens", function () { + it("can deal with line terminators inside multi-line Tokens", () => { let ifElseLexer = new Lexer([If, Else, WhitespaceNotSkipped]) let input = "if\r\r\telse\rif\n" @@ -417,7 +417,7 @@ describe("The Simple Lexer Full flow", function () { ]) }) - it("can deal with Tokens which may or may not be a lineTerminator", function () { + it("can deal with Tokens which may or may not be a lineTerminator", () => { let ifElseLexer = new Lexer([If, Else, WhitespaceOrAmp]) let input = "if\r\r\telse&if" @@ -432,7 +432,7 @@ describe("The Simple Lexer Full flow", function () { ]) }) - it("supports Token groups", function () { + it("supports Token groups", () => { let ifElseLexer = new Lexer([If, Else, Comment]) let input = "if//else" diff --git a/test/scan/token_spec.ts b/test/scan/token_spec.ts index 6bdf1822b..392678f5c 100644 --- a/test/scan/token_spec.ts +++ b/test/scan/token_spec.ts @@ -3,10 +3,10 @@ import {extendToken, tokenName, Token} from "../../src/scan/tokens_public" let TrueLiteral = extendToken("TrueLiteral") class FalseLiteral extends Token {} -describe("The Chevrotain Tokens namespace", function () { +describe("The Chevrotain Tokens namespace", () => { "use strict" - it("exports a utility function that returns a token's name", function () { + it("exports a utility function that returns a token's name", () => { // FalseLiteral was created with an anonymous function as its constructor yet tokenName(...) // should still work correctly on it if the 'tokenName' property has been set on its constructor. expect(tokenName(FalseLiteral)).to.equal("FalseLiteral") @@ -20,7 +20,7 @@ describe("The Chevrotain Tokens namespace", function () { let C = extendToken("C", /\d+/, B) let D = extendToken("D", /\w+/, B) - it("provides an extendToken utility - creating an instance", function () { + it("provides an extendToken utility - creating an instance", () => { let aInstance = new A("Hello", 0, 1, 1) expect(aInstance.image).to.equal("Hello") expect(aInstance.offset).to.equal(0) @@ -30,7 +30,7 @@ describe("The Chevrotain Tokens namespace", function () { expect(aInstance.endColumn).to.equal(5) }) - it("provides an extendToken utility - creating a subclass instance", function () { + it("provides an extendToken utility - creating a subclass instance", () => { let aInstance = new C("world", 0, 1, 1) expect(aInstance.image).to.equal("world") expect(aInstance.offset).to.equal(0) @@ -40,7 +40,7 @@ describe("The Chevrotain Tokens namespace", function () { expect(aInstance.endColumn).to.equal(5) }) - it("provides an extendToken utility - inheritance chain", function () { + it("provides an extendToken utility - inheritance chain", () => { let dInstance = new D("world", 0, 1, 1) expect(dInstance).to.be.an.instanceof(A) expect(dInstance).to.be.an.instanceof(B) @@ -54,7 +54,7 @@ describe("The Chevrotain Tokens namespace", function () { expect(bInstance).to.be.an.instanceof(A) }) - it("provides an extendToken utility - static properties inheritance", function () { + it("provides an extendToken utility - static properties inheritance", () => { expect(D.GROUP).to.equal("Special") expect(C.GROUP).to.equal("Special") }) diff --git a/test/text/range_spec.ts b/test/text/range_spec.ts index 1a0031359..800afdfc3 100644 --- a/test/text/range_spec.ts +++ b/test/text/range_spec.ts @@ -1,13 +1,13 @@ import {Range} from "../../src/text/range" -describe("The Chevrotain Range namespace", function () { +describe("The Chevrotain Range namespace", () => { - it("an invalid range can not be created", function () { + it("an invalid range can not be created", () => { expect(() => { return new Range(5, 1)}).to.throw("INVALID RANGE") expect(() => { return new Range(-1, 2)}).to.throw("INVALID RANGE") }) - it("can check if a number is contained in a give range", function () { + it("can check if a number is contained in a give range", () => { let r = new Range(90, 110) expect(r.contains(-4)).to.equal(false) expect(r.contains(30)).to.equal(false) @@ -20,7 +20,7 @@ describe("The Chevrotain Range namespace", function () { expect(r.contains(999)).to.equal(false) }) - it("can check if it is contained in another range", function () { + it("can check if it is contained in another range", () => { let _10_50 = new Range(10, 50) let _1_6 = new Range(1, 6) let _5_15 = new Range(5, 15) @@ -36,7 +36,7 @@ describe("The Chevrotain Range namespace", function () { expect(_51_100.isContainedInRange(_10_50)).to.equal(false) }) - it("can check if it is strictly contained in another range", function () { + it("can check if it is strictly contained in another range", () => { let _10_50 = new Range(10, 50) let _1_6 = new Range(1, 6)