diff --git a/tests/data/playground/sql/case-when.json b/tests/data/playground/sql/case-when.json deleted file mode 100644 index f2b9d42..0000000 --- a/tests/data/playground/sql/case-when.json +++ /dev/null @@ -1,326 +0,0 @@ -{ - "ast": { - "eClass": "https://strumenta.com/kolasu/v1#//Result", - "root": { - "eClass": "#//Script", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 1, - "column": 0 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 10, - "column": 0 - } - }, - "statements": [ - { - "eClass": "#//SelectStatement", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 1, - "column": 0 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 7, - "column": 6 - } - }, - "query": { - "eClass": "#//SelectQuery", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 1, - "column": 0 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 7, - "column": 6 - } - }, - "projections": [ - { - "eClass": "#//ExpressionProjection", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 0 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 4 - } - }, - "expression": { - "eClass": "#//ColumnExpression", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 0 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 4 - } - }, - "name": "ROOT" - } - }, - { - "eClass": "#//ExpressionProjection", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 5 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 8 - } - }, - "expression": { - "eClass": "#//ColumnExpression", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 5 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 8 - } - }, - "name": "LEV" - } - }, - { - "eClass": "#//ExpressionProjection", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 9 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 12 - } - }, - "expression": { - "eClass": "#//ColumnExpression", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 9 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 12 - } - }, - "name": "OBJ" - } - }, - { - "eClass": "#//ExpressionProjection", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 13 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 17 - } - }, - "expression": { - "eClass": "#//ColumnExpression", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 13 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 17 - } - }, - "name": "LinK" - } - }, - { - "eClass": "#//ExpressionProjection", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 18 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 22 - } - }, - "expression": { - "eClass": "#//ColumnExpression", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 18 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 22 - } - }, - "name": "PaTH" - } - }, - { - "eClass": "#//ExpressionProjection", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 23 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 28 - } - }, - "expression": { - "eClass": "#//ColumnExpression", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 23 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 2, - "column": 28 - } - }, - "name": "cycle" - } - }, - { - "eClass": "#//ExpressionProjection", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 3, - "column": 4 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 6, - "column": 15 - } - }, - "expression": { - "eClass": "#null/ErrorNode", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 3, - "column": 4 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 6, - "column": 15 - } - } - } - } - ], - "relations": [ - { - "eClass": "#//TableRelation", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 7, - "column": 5 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 7, - "column": 6 - } - }, - "table": { - "eClass": "#//TableRef", - "position": { - "eClass": "https://strumenta.com/kolasu/v1#//Position", - "start": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 7, - "column": 5 - }, - "end": { - "eClass": "https://strumenta.com/kolasu/v1#//Point", - "line": 7, - "column": 6 - } - }, - "name": "T" - } - } - ] - } - } - ] - } - }, - "code": "select \nROOT,LEV,OBJ,LinK,PaTH,cycle,\n case\n when (LEV - LEaD(LEV) over (order by orD)) < 0 then 0\n else 1\n end is_LEaF\nfrom T\n\n\n", - "name": "case-when", - "astBuildingTime": 181.41455999016762, - "parsingTime": 165.1825089752674 -} diff --git a/tests/strumenta-playground.test.ts b/tests/strumenta-playground.test.ts index 28e0b0e..2e74d6c 100644 --- a/tests/strumenta-playground.test.ts +++ b/tests/strumenta-playground.test.ts @@ -56,53 +56,6 @@ describe('Strumenta Playground', function() { }); }); }); - - it("SQL case-when", - function () { - this.timeout(0); - - const path = "tests/data/playground/sql/metamodel.json"; - const metamodel = - JSON.parse(fs.readFileSync(path).toString()); - const loader = new ParserTraceLoader({ - name: "sql", - uri: `file://${path}`, - metamodel: metamodel - }); - let code = fs.readFileSync( - "tests/data/playground/sql/case-when.json").toString(); - let trace = loader.loadParserTrace(code, "sql"); - - const rootNode = trace.rootNode; - expect(rootNode.getType()).to.eql("com.strumenta.sas.ast.SourceFile"); - expect(rootNode.getSimpleType()).to.eql("SourceFile"); - expect(rootNode.getPosition()).to.eql(pos(12, 0,369, 0)); - let foundNode = findByPosition(rootNode, pos(12, 0,369, 0)) as ParserNode; - expect(foundNode.eo == rootNode.eo).to.be.true; - const descNode = rootNode.children[10].children[7] as ParserNode; - foundNode = findByPosition(descNode, descNode.position!) as ParserNode; - expect(foundNode.eo == descNode.eo).to.be.true; - expect(rootNode.getChildren().length).to.equal(18); - expect(rootNode.getChildren("statementsAndDeclarations").length).to.equal(18); - // foundNode = findByPosition(rootNode, pos(20, 28, 20, 29)) as ParserNode; - // expect(foundNode).not.to.be.undefined; - const child = rootNode.getChildren("statementsAndDeclarations")[0]; - expect(child.getRole()).to.equal("statementsAndDeclarations"); - expect(child.getAttributes()).to.eql({ name: "importSheets" }); - expect(trace.issues.length).to.equal(1); - expect(trace.issues[0].type).to.equal(IssueType.SEMANTIC); - expect(trace.issues[0].message).to.equal("Unparsed macro code: `filename `"); - expect(trace.issues[0].severity).to.equal(IssueSeverity.WARNING); - expect(trace.issues[0].position).to.eql(pos(43, 8,43, 17)); - - code = fs.readFileSync( - "tests/data/playground/sas/open-source_sas-cert-prep-data_professional-prep-guide_cre8permdata.sas.json").toString(); - trace = loader.loadParserTrace(code, "sas"); - expect(trace).not.to.be.undefined; - expect(trace.rootNode).not.to.be.undefined; - expect(trace.rootNode.position).to.eql(pos(15, 0, 10161, 0)); - expect(trace.issues).to.eql([]); - }); }); class TestParser extends EcoreEnabledParser {