How to use binaryExpression method in stryker-parent

Best JavaScript code snippet using stryker-parent

ParserTest.ts

Source:ParserTest.ts Github

copy

Full Screen

1import { expect } from "chai";2import { Expr } from "../CodeAnalysis/Syntax/Expression";3import { Parser } from "../CodeAnalysis/Syntax/Parser";4import { Stmt } from "../CodeAnalysis/Syntax/Statement";5import { SyntaxType as Syntax } from "../CodeAnalysis/Syntax/SyntaxType";6describe("Parser", () => {7 describe("Binary operator test", () => {8 (() => {9 const parser = new Parser("true & false;");10 const statements: Stmt.Statement[] = parser.Parse();11 const binaryExprStatement = statements[0] as Stmt.Expression;12 const binaryExpression = binaryExprStatement.Expression as Expr.Logical;13 it("should produce a logical expression", () => {14 expect(binaryExpression).to.not.be.an("undefined");15 expect(binaryExpression).to.have.property("Left");16 expect(binaryExpression).to.have.property("Right");17 expect(binaryExpression).to.have.property("Operator");18 });19 it("should have the left evaluate to true and right to false", () => {20 expect(binaryExpression.Left).to.not.be.an("undefined");21 expect(binaryExpression.Right).to.not.be.an("undefined");22 expect(binaryExpression.Left as Expr.Literal).to.have.property("Value");23 expect(binaryExpression.Right as Expr.Literal).to.have.property("Value");24 expect((binaryExpression.Left as Expr.Literal).Value).to.equal(true);25 expect((binaryExpression.Right as Expr.Literal).Value).to.equal(false);26 })27 it("should have a & operator token", () => {28 expect(binaryExpression.Operator).to.not.be.an("undefined");29 expect(binaryExpression.Operator).to.have.property("Type");30 expect(binaryExpression.Operator).to.have.property("Lexeme");31 expect(binaryExpression.Operator).to.have.property("Line");32 expect(binaryExpression.Operator).to.have.property("Literal");33 expect(binaryExpression.Operator.Type).to.equal(Syntax.AND)34 });35 })();36 (() => {37 const parser = new Parser("false | true;");38 const statements: Stmt.Statement[] = parser.Parse();39 const binaryExprStatement = statements[0] as Stmt.Expression;40 const binaryExpression = binaryExprStatement.Expression as Expr.Logical;41 it("should produce a logical expression", () => {42 expect(binaryExpression).to.not.be.an("undefined");43 expect(binaryExpression).to.have.property("Left");44 expect(binaryExpression).to.have.property("Right");45 expect(binaryExpression).to.have.property("Operator");46 });47 it("should have the left evaluate to false and right to true", () => {48 expect(binaryExpression.Left).to.not.be.an("undefined");49 expect(binaryExpression.Right).to.not.be.an("undefined");50 expect(binaryExpression.Left as Expr.Literal).to.have.property("Value");51 expect(binaryExpression.Right as Expr.Literal).to.have.property("Value");52 expect((binaryExpression.Left as Expr.Literal).Value).to.equal(false);53 expect((binaryExpression.Right as Expr.Literal).Value).to.equal(true);54 })55 it("should have a | operator token", () => {56 expect(binaryExpression.Operator).to.not.be.an("undefined");57 expect(binaryExpression.Operator).to.have.property("Type");58 expect(binaryExpression.Operator).to.have.property("Lexeme");59 expect(binaryExpression.Operator).to.have.property("Line");60 expect(binaryExpression.Operator).to.have.property("Literal");61 expect(binaryExpression.Operator.Type).to.equal(Syntax.OR)62 });63 })();64 (() => {65 const parser = new Parser("2 + 4;");66 const statements: Stmt.Statement[] = parser.Parse();67 const binaryExprStatement = statements[0] as Stmt.Expression;68 const binaryExpression = binaryExprStatement.Expression as Expr.Binary;69 it("should produce a binary expression", () => {70 expect(binaryExpression).to.not.be.an("undefined");71 expect(binaryExpression).to.have.property("Left");72 expect(binaryExpression).to.have.property("Right");73 expect(binaryExpression).to.have.property("Operator");74 });75 it("should have the left evaluate to 2 and right to 4", () => {76 expect(binaryExpression.Left).to.not.be.an("undefined");77 expect(binaryExpression.Right).to.not.be.an("undefined");78 expect(binaryExpression.Left as Expr.Literal).to.have.property("Value");79 expect(binaryExpression.Right as Expr.Literal).to.have.property("Value");80 expect((binaryExpression.Left as Expr.Literal).Value).to.equal(2);81 expect((binaryExpression.Right as Expr.Literal).Value).to.equal(4);82 })83 it("should have a + operator token", () => {84 expect(binaryExpression.Operator).to.not.be.an("undefined");85 expect(binaryExpression.Operator).to.have.property("Type");86 expect(binaryExpression.Operator).to.have.property("Lexeme");87 expect(binaryExpression.Operator).to.have.property("Line");88 expect(binaryExpression.Operator).to.have.property("Literal");89 expect(binaryExpression.Operator.Type).to.equal(Syntax.PLUS)90 });91 })();92 (() => {93 const parser = new Parser("6 - 3 * 2;");94 const statements: Stmt.Statement[] = parser.Parse();95 const binaryExprStatement = statements[0] as Stmt.Expression;96 const binaryExpression = binaryExprStatement.Expression as Expr.Binary;97 it("should produce a binary expression", () => {98 expect(binaryExpression).to.not.be.an("undefined");99 expect(binaryExpression).to.have.property("Left");100 expect(binaryExpression).to.have.property("Right");101 expect(binaryExpression).to.have.property("Operator");102 });103 it("should have the left evaluate to 6 and right to binary(3 * 2)", () => {104 expect(binaryExpression.Left).to.not.be.an("undefined");105 expect(binaryExpression.Right).to.not.be.an("undefined");106 expect(binaryExpression.Left as Expr.Literal).to.have.property("Value");107 expect(binaryExpression.Right as Expr.Binary).to.have.property("Left");108 expect(binaryExpression.Right as Expr.Binary).to.have.property("Right");109 expect(binaryExpression.Right as Expr.Binary).to.have.property("Operator");110 expect((binaryExpression.Left as Expr.Literal).Value).to.equal(6);111 expect(((binaryExpression.Right as Expr.Binary).Left as Expr.Literal).Value).to.equal(3);112 expect(((binaryExpression.Right as Expr.Binary).Right as Expr.Literal).Value).to.equal(2);113 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Type");114 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Lexeme");115 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Line");116 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Literal");117 expect((binaryExpression.Right as Expr.Binary).Operator.Type).to.equal(Syntax.STAR);118 })119 it("should have a - operator token", () => {120 expect(binaryExpression.Operator).to.not.be.an("undefined");121 expect(binaryExpression.Operator).to.have.property("Type");122 expect(binaryExpression.Operator).to.have.property("Lexeme");123 expect(binaryExpression.Operator).to.have.property("Line");124 expect(binaryExpression.Operator).to.have.property("Literal");125 expect(binaryExpression.Operator.Type).to.equal(Syntax.MINUS)126 });127 })();128 (() => {129 const parser = new Parser("4 % 2 ^ 2;");130 const statements: Stmt.Statement[] = parser.Parse();131 const binaryExprStatement = statements[0] as Stmt.Expression;132 const binaryExpression = binaryExprStatement.Expression as Expr.Binary;133 it("should produce a binary expression", () => {134 expect(binaryExpression).to.not.be.an("undefined");135 expect(binaryExpression).to.have.property("Left");136 expect(binaryExpression).to.have.property("Right");137 expect(binaryExpression).to.have.property("Operator");138 });139 it("should have the left evaluate to 4 and right to binary(2 ^ 2)", () => {140 expect(binaryExpression.Left).to.not.be.an("undefined");141 expect(binaryExpression.Right).to.not.be.an("undefined");142 expect(binaryExpression.Left as Expr.Literal).to.have.property("Value");143 expect(binaryExpression.Right as Expr.Binary).to.have.property("Left");144 expect(binaryExpression.Right as Expr.Binary).to.have.property("Right");145 expect(binaryExpression.Right as Expr.Binary).to.have.property("Operator");146 expect((binaryExpression.Left as Expr.Literal).Value).to.equal(4);147 expect(((binaryExpression.Right as Expr.Binary).Left as Expr.Literal).Value).to.equal(2);148 expect(((binaryExpression.Right as Expr.Binary).Right as Expr.Literal).Value).to.equal(2);149 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Type");150 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Lexeme");151 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Line");152 expect((binaryExpression.Right as Expr.Binary).Operator).to.have.property("Literal");153 expect((binaryExpression.Right as Expr.Binary).Operator.Type).to.equal(Syntax.CARAT);154 })155 it("should have a % operator token", () => {156 expect(binaryExpression.Operator).to.not.be.an("undefined");157 expect(binaryExpression.Operator).to.have.property("Type");158 expect(binaryExpression.Operator).to.have.property("Lexeme");159 expect(binaryExpression.Operator).to.have.property("Line");160 expect(binaryExpression.Operator).to.have.property("Literal");161 expect(binaryExpression.Operator.Type).to.equal(Syntax.PERCENT)162 });163 })();164 });165 describe("Unary operator test", () => {166 (() => {167 const parser = new Parser("!true;");168 const statements: Stmt.Statement[] = parser.Parse();169 const unaryExprStatement = statements[0] as Stmt.Expression;170 const unaryExpression = unaryExprStatement.Expression as Expr.Unary;171 it("should produce a unary expression", () => {172 expect(unaryExpression).to.not.be.an("undefined");173 expect(unaryExpression).to.have.property("Right");174 expect(unaryExpression).to.have.property("Operator");175 });176 it("should have the operand evaluate to true", () => {177 expect(unaryExpression.Right).to.not.be.an("undefined");178 expect(unaryExpression.Right as Expr.Literal).to.have.property("Value");179 expect((unaryExpression.Right as Expr.Literal).Value).to.equal(true);180 })181 it("should have a ! operator token", () => {182 expect(unaryExpression.Operator).to.not.be.an("undefined");183 expect(unaryExpression.Operator).to.have.property("Type");184 expect(unaryExpression.Operator).to.have.property("Lexeme");185 expect(unaryExpression.Operator).to.have.property("Line");186 expect(unaryExpression.Operator).to.have.property("Literal");187 expect(unaryExpression.Operator.Type).to.equal(Syntax.BANG)188 });189 })();190 (() => {191 const parser = new Parser("-42;");192 const statements: Stmt.Statement[] = parser.Parse();193 const unaryExprStatement = statements[0] as Stmt.Expression;194 const unaryExpression = unaryExprStatement.Expression as Expr.Unary;195 it("should produce a unary expression", () => {196 expect(unaryExpression).to.not.be.an("undefined");197 expect(unaryExpression).to.have.property("Right");198 expect(unaryExpression).to.have.property("Operator");199 });200 it("should have the operand evaluate to 42", () => {201 expect(unaryExpression.Right).to.not.be.an("undefined");202 expect(unaryExpression.Right as Expr.Literal).to.have.property("Value");203 expect((unaryExpression.Right as Expr.Literal).Value).to.equal(42);204 })205 it("should have a - operator token", () => {206 expect(unaryExpression.Operator).to.not.be.an("undefined");207 expect(unaryExpression.Operator).to.have.property("Type");208 expect(unaryExpression.Operator).to.have.property("Lexeme");209 expect(unaryExpression.Operator).to.have.property("Line");210 expect(unaryExpression.Operator).to.have.property("Literal");211 expect(unaryExpression.Operator.Type).to.equal(Syntax.MINUS)212 });213 })();214 (() => {215 const parser = new Parser("+76;");216 const statements: Stmt.Statement[] = parser.Parse();217 const unaryExprStatement = statements[0] as Stmt.Expression;218 const unaryExpression = unaryExprStatement.Expression as Expr.Unary;219 it("should produce a unary expression", () => {220 expect(unaryExpression).to.not.be.an("undefined");221 expect(unaryExpression).to.have.property("Right");222 expect(unaryExpression).to.have.property("Operator");223 });224 it("should have the operand evaluate to 76", () => {225 expect(unaryExpression.Right).to.not.be.an("undefined");226 expect(unaryExpression.Right as Expr.Literal).to.have.property("Value");227 expect((unaryExpression.Right as Expr.Literal).Value).to.equal(76);228 })229 it("should have a + operator token", () => {230 expect(unaryExpression.Operator).to.not.be.an("undefined");231 expect(unaryExpression.Operator).to.have.property("Type");232 expect(unaryExpression.Operator).to.have.property("Lexeme");233 expect(unaryExpression.Operator).to.have.property("Line");234 expect(unaryExpression.Operator).to.have.property("Literal");235 expect(unaryExpression.Operator.Type).to.equal(Syntax.PLUS)236 });237 })();238 });239 describe("Error reporting test", () => {240 (() => {241 const parser = new Parser("print 5"); // Missing semicolon242 it("should raise an expected ';' error", () =>243 expect(parser.Parse).to.throw()244 );245 })();246 (() => {247 const parser = new Parser("raise 'Raised error';");248 it("should raise a 'Raised error' error", () =>249 expect(parser.Parse).to.throw()250 );251 })();252 (() => {253 const parser = new Parser("if (true)");254 it("should raise an expected '{' error", () =>255 expect(parser.Parse).to.throw()256 );257 })();258 (() => {259 const parser = new Parser("-false;");260 it("should raise a runtime error", () =>261 expect(parser.Parse).to.throw()262 );263 })();264 (() => {265 const parser = new Parser("return;");266 it("should raise a runtime error", () =>267 expect(parser.Parse).to.throw()268 );269 })();270 (() => {271 const parser = new Parser("method hello(name) { print 'hello ' + name ");272 it("should raise an expected '}' error", () =>273 expect(parser.Parse).to.throw()274 );275 })();276 (() => {277 const parser = new Parser("for (let i; i < 2) {}");278 it("should raise an expected ';' error", () =>279 expect(parser.Parse).to.throw()280 );281 })();282 });...

Full Screen

Full Screen

ParserTest.js

Source:ParserTest.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3const chai_1 = require("chai");4const Parser_1 = require("../CodeAnalysis/Syntax/Parser");5const SyntaxType_1 = require("../CodeAnalysis/Syntax/SyntaxType");6describe("Parser", () => {7 describe("Binary operator test", () => {8 (() => {9 const parser = new Parser_1.Parser("true & false;");10 const statements = parser.Parse();11 const binaryExprStatement = statements[0];12 const binaryExpression = binaryExprStatement.Expression;13 it("should produce a logical expression", () => {14 chai_1.expect(binaryExpression).to.not.be.an("undefined");15 chai_1.expect(binaryExpression).to.have.property("Left");16 chai_1.expect(binaryExpression).to.have.property("Right");17 chai_1.expect(binaryExpression).to.have.property("Operator");18 });19 it("should have the left evaluate to true and right to false", () => {20 chai_1.expect(binaryExpression.Left).to.not.be.an("undefined");21 chai_1.expect(binaryExpression.Right).to.not.be.an("undefined");22 chai_1.expect(binaryExpression.Left).to.have.property("Value");23 chai_1.expect(binaryExpression.Right).to.have.property("Value");24 chai_1.expect(binaryExpression.Left.Value).to.equal(true);25 chai_1.expect(binaryExpression.Right.Value).to.equal(false);26 });27 it("should have a & operator token", () => {28 chai_1.expect(binaryExpression.Operator).to.not.be.an("undefined");29 chai_1.expect(binaryExpression.Operator).to.have.property("Type");30 chai_1.expect(binaryExpression.Operator).to.have.property("Lexeme");31 chai_1.expect(binaryExpression.Operator).to.have.property("Line");32 chai_1.expect(binaryExpression.Operator).to.have.property("Literal");33 chai_1.expect(binaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.AND);34 });35 })();36 (() => {37 const parser = new Parser_1.Parser("false | true;");38 const statements = parser.Parse();39 const binaryExprStatement = statements[0];40 const binaryExpression = binaryExprStatement.Expression;41 it("should produce a logical expression", () => {42 chai_1.expect(binaryExpression).to.not.be.an("undefined");43 chai_1.expect(binaryExpression).to.have.property("Left");44 chai_1.expect(binaryExpression).to.have.property("Right");45 chai_1.expect(binaryExpression).to.have.property("Operator");46 });47 it("should have the left evaluate to false and right to true", () => {48 chai_1.expect(binaryExpression.Left).to.not.be.an("undefined");49 chai_1.expect(binaryExpression.Right).to.not.be.an("undefined");50 chai_1.expect(binaryExpression.Left).to.have.property("Value");51 chai_1.expect(binaryExpression.Right).to.have.property("Value");52 chai_1.expect(binaryExpression.Left.Value).to.equal(false);53 chai_1.expect(binaryExpression.Right.Value).to.equal(true);54 });55 it("should have a | operator token", () => {56 chai_1.expect(binaryExpression.Operator).to.not.be.an("undefined");57 chai_1.expect(binaryExpression.Operator).to.have.property("Type");58 chai_1.expect(binaryExpression.Operator).to.have.property("Lexeme");59 chai_1.expect(binaryExpression.Operator).to.have.property("Line");60 chai_1.expect(binaryExpression.Operator).to.have.property("Literal");61 chai_1.expect(binaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.OR);62 });63 })();64 (() => {65 const parser = new Parser_1.Parser("2 + 4;");66 const statements = parser.Parse();67 const binaryExprStatement = statements[0];68 const binaryExpression = binaryExprStatement.Expression;69 it("should produce a binary expression", () => {70 chai_1.expect(binaryExpression).to.not.be.an("undefined");71 chai_1.expect(binaryExpression).to.have.property("Left");72 chai_1.expect(binaryExpression).to.have.property("Right");73 chai_1.expect(binaryExpression).to.have.property("Operator");74 });75 it("should have the left evaluate to 2 and right to 4", () => {76 chai_1.expect(binaryExpression.Left).to.not.be.an("undefined");77 chai_1.expect(binaryExpression.Right).to.not.be.an("undefined");78 chai_1.expect(binaryExpression.Left).to.have.property("Value");79 chai_1.expect(binaryExpression.Right).to.have.property("Value");80 chai_1.expect(binaryExpression.Left.Value).to.equal(2);81 chai_1.expect(binaryExpression.Right.Value).to.equal(4);82 });83 it("should have a + operator token", () => {84 chai_1.expect(binaryExpression.Operator).to.not.be.an("undefined");85 chai_1.expect(binaryExpression.Operator).to.have.property("Type");86 chai_1.expect(binaryExpression.Operator).to.have.property("Lexeme");87 chai_1.expect(binaryExpression.Operator).to.have.property("Line");88 chai_1.expect(binaryExpression.Operator).to.have.property("Literal");89 chai_1.expect(binaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.PLUS);90 });91 })();92 (() => {93 const parser = new Parser_1.Parser("6 - 3 * 2;");94 const statements = parser.Parse();95 const binaryExprStatement = statements[0];96 const binaryExpression = binaryExprStatement.Expression;97 it("should produce a binary expression", () => {98 chai_1.expect(binaryExpression).to.not.be.an("undefined");99 chai_1.expect(binaryExpression).to.have.property("Left");100 chai_1.expect(binaryExpression).to.have.property("Right");101 chai_1.expect(binaryExpression).to.have.property("Operator");102 });103 it("should have the left evaluate to 6 and right to binary(3 * 2)", () => {104 chai_1.expect(binaryExpression.Left).to.not.be.an("undefined");105 chai_1.expect(binaryExpression.Right).to.not.be.an("undefined");106 chai_1.expect(binaryExpression.Left).to.have.property("Value");107 chai_1.expect(binaryExpression.Right).to.have.property("Left");108 chai_1.expect(binaryExpression.Right).to.have.property("Right");109 chai_1.expect(binaryExpression.Right).to.have.property("Operator");110 chai_1.expect(binaryExpression.Left.Value).to.equal(6);111 chai_1.expect(binaryExpression.Right.Left.Value).to.equal(3);112 chai_1.expect(binaryExpression.Right.Right.Value).to.equal(2);113 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Type");114 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Lexeme");115 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Line");116 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Literal");117 chai_1.expect(binaryExpression.Right.Operator.Type).to.equal(SyntaxType_1.SyntaxType.STAR);118 });119 it("should have a - operator token", () => {120 chai_1.expect(binaryExpression.Operator).to.not.be.an("undefined");121 chai_1.expect(binaryExpression.Operator).to.have.property("Type");122 chai_1.expect(binaryExpression.Operator).to.have.property("Lexeme");123 chai_1.expect(binaryExpression.Operator).to.have.property("Line");124 chai_1.expect(binaryExpression.Operator).to.have.property("Literal");125 chai_1.expect(binaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.MINUS);126 });127 })();128 (() => {129 const parser = new Parser_1.Parser("4 % 2 ^ 2;");130 const statements = parser.Parse();131 const binaryExprStatement = statements[0];132 const binaryExpression = binaryExprStatement.Expression;133 it("should produce a binary expression", () => {134 chai_1.expect(binaryExpression).to.not.be.an("undefined");135 chai_1.expect(binaryExpression).to.have.property("Left");136 chai_1.expect(binaryExpression).to.have.property("Right");137 chai_1.expect(binaryExpression).to.have.property("Operator");138 });139 it("should have the left evaluate to 4 and right to binary(2 ^ 2)", () => {140 chai_1.expect(binaryExpression.Left).to.not.be.an("undefined");141 chai_1.expect(binaryExpression.Right).to.not.be.an("undefined");142 chai_1.expect(binaryExpression.Left).to.have.property("Value");143 chai_1.expect(binaryExpression.Right).to.have.property("Left");144 chai_1.expect(binaryExpression.Right).to.have.property("Right");145 chai_1.expect(binaryExpression.Right).to.have.property("Operator");146 chai_1.expect(binaryExpression.Left.Value).to.equal(4);147 chai_1.expect(binaryExpression.Right.Left.Value).to.equal(2);148 chai_1.expect(binaryExpression.Right.Right.Value).to.equal(2);149 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Type");150 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Lexeme");151 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Line");152 chai_1.expect(binaryExpression.Right.Operator).to.have.property("Literal");153 chai_1.expect(binaryExpression.Right.Operator.Type).to.equal(SyntaxType_1.SyntaxType.CARAT);154 });155 it("should have a % operator token", () => {156 chai_1.expect(binaryExpression.Operator).to.not.be.an("undefined");157 chai_1.expect(binaryExpression.Operator).to.have.property("Type");158 chai_1.expect(binaryExpression.Operator).to.have.property("Lexeme");159 chai_1.expect(binaryExpression.Operator).to.have.property("Line");160 chai_1.expect(binaryExpression.Operator).to.have.property("Literal");161 chai_1.expect(binaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.PERCENT);162 });163 })();164 });165 describe("Unary operator test", () => {166 (() => {167 const parser = new Parser_1.Parser("!true;");168 const statements = parser.Parse();169 const unaryExprStatement = statements[0];170 const unaryExpression = unaryExprStatement.Expression;171 it("should produce a unary expression", () => {172 chai_1.expect(unaryExpression).to.not.be.an("undefined");173 chai_1.expect(unaryExpression).to.have.property("Right");174 chai_1.expect(unaryExpression).to.have.property("Operator");175 });176 it("should have the operand evaluate to true", () => {177 chai_1.expect(unaryExpression.Right).to.not.be.an("undefined");178 chai_1.expect(unaryExpression.Right).to.have.property("Value");179 chai_1.expect(unaryExpression.Right.Value).to.equal(true);180 });181 it("should have a ! operator token", () => {182 chai_1.expect(unaryExpression.Operator).to.not.be.an("undefined");183 chai_1.expect(unaryExpression.Operator).to.have.property("Type");184 chai_1.expect(unaryExpression.Operator).to.have.property("Lexeme");185 chai_1.expect(unaryExpression.Operator).to.have.property("Line");186 chai_1.expect(unaryExpression.Operator).to.have.property("Literal");187 chai_1.expect(unaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.BANG);188 });189 })();190 (() => {191 const parser = new Parser_1.Parser("-42;");192 const statements = parser.Parse();193 const unaryExprStatement = statements[0];194 const unaryExpression = unaryExprStatement.Expression;195 it("should produce a unary expression", () => {196 chai_1.expect(unaryExpression).to.not.be.an("undefined");197 chai_1.expect(unaryExpression).to.have.property("Right");198 chai_1.expect(unaryExpression).to.have.property("Operator");199 });200 it("should have the operand evaluate to 42", () => {201 chai_1.expect(unaryExpression.Right).to.not.be.an("undefined");202 chai_1.expect(unaryExpression.Right).to.have.property("Value");203 chai_1.expect(unaryExpression.Right.Value).to.equal(42);204 });205 it("should have a - operator token", () => {206 chai_1.expect(unaryExpression.Operator).to.not.be.an("undefined");207 chai_1.expect(unaryExpression.Operator).to.have.property("Type");208 chai_1.expect(unaryExpression.Operator).to.have.property("Lexeme");209 chai_1.expect(unaryExpression.Operator).to.have.property("Line");210 chai_1.expect(unaryExpression.Operator).to.have.property("Literal");211 chai_1.expect(unaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.MINUS);212 });213 })();214 (() => {215 const parser = new Parser_1.Parser("+76;");216 const statements = parser.Parse();217 const unaryExprStatement = statements[0];218 const unaryExpression = unaryExprStatement.Expression;219 it("should produce a unary expression", () => {220 chai_1.expect(unaryExpression).to.not.be.an("undefined");221 chai_1.expect(unaryExpression).to.have.property("Right");222 chai_1.expect(unaryExpression).to.have.property("Operator");223 });224 it("should have the operand evaluate to 76", () => {225 chai_1.expect(unaryExpression.Right).to.not.be.an("undefined");226 chai_1.expect(unaryExpression.Right).to.have.property("Value");227 chai_1.expect(unaryExpression.Right.Value).to.equal(76);228 });229 it("should have a + operator token", () => {230 chai_1.expect(unaryExpression.Operator).to.not.be.an("undefined");231 chai_1.expect(unaryExpression.Operator).to.have.property("Type");232 chai_1.expect(unaryExpression.Operator).to.have.property("Lexeme");233 chai_1.expect(unaryExpression.Operator).to.have.property("Line");234 chai_1.expect(unaryExpression.Operator).to.have.property("Literal");235 chai_1.expect(unaryExpression.Operator.Type).to.equal(SyntaxType_1.SyntaxType.PLUS);236 });237 })();238 });239 describe("Error reporting test", () => {240 (() => {241 const parser = new Parser_1.Parser("print 5"); // Missing semicolon242 it("should raise an expected ';' error", () => chai_1.expect(parser.Parse).to.throw());243 })();244 (() => {245 const parser = new Parser_1.Parser("raise 'Raised error';");246 it("should raise a 'Raised error' error", () => chai_1.expect(parser.Parse).to.throw());247 })();248 (() => {249 const parser = new Parser_1.Parser("if (true)");250 it("should raise an expected '{' error", () => chai_1.expect(parser.Parse).to.throw());251 })();252 (() => {253 const parser = new Parser_1.Parser("-false;");254 it("should raise a runtime error", () => chai_1.expect(parser.Parse).to.throw());255 })();256 (() => {257 const parser = new Parser_1.Parser("return;");258 it("should raise a runtime error", () => chai_1.expect(parser.Parse).to.throw());259 })();260 (() => {261 const parser = new Parser_1.Parser("method hello(name) { print 'hello ' + name ");262 it("should raise an expected '}' error", () => chai_1.expect(parser.Parse).to.throw());263 })();264 (() => {265 const parser = new Parser_1.Parser("for (let i; i < 2) {}");266 it("should raise an expected ';' error", () => chai_1.expect(parser.Parse).to.throw());267 })();268 });...

Full Screen

Full Screen

parenthesizing.ts

Source:parenthesizing.ts Github

copy

Full Screen

1test(BinaryExpression('+',2 IntegerLiteral(1),3 BinaryExpression('*',4 IntegerLiteral(2),5 IntegerLiteral(3))6), [7 '1 + 2 * 3',8]);9test(BinaryExpression('*',10 IntegerLiteral(1),11 BinaryExpression('+',12 IntegerLiteral(2),13 IntegerLiteral(3))14), [15 '1 * (2 + 3)',16]);17test(CallExpression(18 Identifier('foo'),19 [SequenceExpression([20 IntegerLiteral(2),21 IntegerLiteral(3)])]22), [23 'foo((2, 3))',24]);25test(CallExpression(26 AssignmentExpression('=',27 Identifier('foo'),28 IntegerLiteral(2)),29 [IntegerLiteral(3)]30), [31 '(foo = 2)(3)',32]);33test(MemberExpression('.',34 AssignmentExpression('=',35 Identifier('foo'),36 IntegerLiteral(2)),37 Identifier('foo')38), [39 '(foo = 2).foo',40]);41test(BinaryExpression('->*',42 MemberExpression('.',43 Identifier('a'),44 Identifier('b')),45 MemberExpression('.',46 Identifier('c'),47 Identifier('d'))48), [49 'a.b->*c.d',50]);51test(UnaryExpression('-', true,52 BinaryExpression('+',53 IntegerLiteral(1),54 IntegerLiteral(2))55), [56 '-(1 + 2)',57]);58test(UnaryExpression('-', true,59 UnaryExpression('-', true,60 IntegerLiteral(1))61), [62 '- -1',63]);64test(UnaryExpression('+', true,65 UnaryExpression('+', true,66 IntegerLiteral(1))67), [68 '+ +1',69]);70test(UnaryExpression('+', true,71 UnaryExpression('-', true,72 IntegerLiteral(1))73), [74 '+-1',75]);76test(UnaryExpression('-', true,77 UnaryExpression('+', true,78 IntegerLiteral(1))79), [80 '-+1',81]);82test(UnaryExpression('sizeof', true,83 Identifier('foo')84), [85 'sizeof foo',86]);87test(UnaryExpression('sizeof', true,88 MemberExpression('::',89 Identifier('foo'),90 Identifier('bar'))91), [92 'sizeof foo::bar',93]);94test(MemberExpression('::',95 UnaryExpression('sizeof', true, Identifier('foo')),96 Identifier('bar')97), [98 '(sizeof foo)::bar',99]);100test(UnaryExpression('++', true,101 UnaryExpression('--', false,102 Identifier('foo'))103), [104 '++foo--',105]);106test(UnaryExpression('--', false,107 UnaryExpression('++', true,108 Identifier('foo'))109), [110 '(++foo)--',111]);112test(UnaryExpression('--', true,113 UnaryExpression('--', true,114 Identifier('foo'))115), [116 '-- --foo',117]);118test(UnaryExpression('++', false,119 UnaryExpression('++', false,120 Identifier('foo'))121), [122 'foo++ ++',123]);124test(CallExpression(125 BinaryExpression('.*',126 Identifier('a'),127 Identifier('b')), [128 IntegerLiteral(1)]129), [130 '(a.*b)(1)',131]);132test(CallExpression(133 BinaryExpression('->*',134 Identifier('a'),135 Identifier('b')), [136 IntegerLiteral(1)]137), [138 '(a->*b)(1)',139]);140test(BinaryExpression('.*',141 Identifier('a'),142 CallExpression(Identifier('b'), [])143), [144 'a.*b()',145]);146test(BinaryExpression('->*',147 Identifier('a'),148 CallExpression(Identifier('b'), [])149), [150 'a->*b()',151]);152test(SpecializeTemplate(153 Identifier('a'), [154 BinaryExpression('>',155 Identifier('b'),156 Identifier('c'))]157), [158 'a<(b > c)>',159]);160test(SpecializeTemplate(161 Identifier('a'), [162 BinaryExpression('>=',163 Identifier('b'),164 Identifier('c'))]165), [166 'a<b >= c>',167]);168test(SpecializeTemplate(169 Identifier('a'), [170 SpecializeTemplate(171 Identifier('b'), [172 BinaryExpression('>',173 Identifier('c'),174 Identifier('d'))])]175), [176 'a<b<(c > d)> >',177]);178test(SpecializeTemplate(179 Identifier('a'), [180 BinaryExpression('&',181 Identifier('b'),182 BinaryExpression('>',183 Identifier('c'),184 Identifier('d')))]185), [186 'a<(b & c > d)>',187]);188test(SpecializeTemplate(189 Identifier('a'), [190 BinaryExpression('[]',191 Identifier('b'),192 BinaryExpression('>',193 Identifier('c'),194 Identifier('d')))]195), [196 'a<b[c > d]>',197]);198test(SpecializeTemplate(199 Identifier('a'), [200 BinaryExpression('*',201 Identifier('b'),202 BinaryExpression('+',203 Identifier('c'),204 BinaryExpression('>',205 Identifier('d'),206 Identifier('e'))))]207), [208 'a<b * (c + (d > e))>',209]);210test(SpecializeTemplate(211 Identifier('a'), [212 BinaryExpression('&',213 StringLiteral('('),214 BinaryExpression('>',215 Identifier('b'),216 Identifier('c')))]217), [218 'a<("(" & b > c)>',219]);220test(BinaryExpression('||',221 BooleanLiteral(false),222 BinaryExpression('&&',223 BooleanLiteral(true),224 BooleanLiteral(false))225), [226 'false || true && false',227]);228test(BinaryExpression('&&',229 BooleanLiteral(false),230 BinaryExpression('||',231 BooleanLiteral(true),232 BooleanLiteral(false))233), [234 'false && (true || false)',235]);236test(BinaryExpression('||',237 BinaryExpression('&&',238 BooleanLiteral(true),239 BooleanLiteral(false)),240 BooleanLiteral(false)241), [242 'true && false || false',243]);244test(BinaryExpression('&&',245 BinaryExpression('||',246 BooleanLiteral(true),247 BooleanLiteral(false)),248 BooleanLiteral(false)249), [250 '(true || false) && false',251]);252// Turn on flag for subsequent tests253parenthesizeAndInsideOr = true;254test(BinaryExpression('||',255 BooleanLiteral(false),256 BinaryExpression('&&',257 BooleanLiteral(true),258 BooleanLiteral(false))259), [260 'false || (true && false)',261]);262test(BinaryExpression('&&',263 BooleanLiteral(false),264 BinaryExpression('||',265 BooleanLiteral(true),266 BooleanLiteral(false))267), [268 'false && (true || false)',269]);270test(BinaryExpression('||',271 BinaryExpression('&&',272 BooleanLiteral(true),273 BooleanLiteral(false)),274 BooleanLiteral(false)275), [276 '(true && false) || false',277]);278test(BinaryExpression('&&',279 BinaryExpression('||',280 BooleanLiteral(true),281 BooleanLiteral(false)),282 BooleanLiteral(false)283), [284 '(true || false) && false',285]);286// Reset flag for subsequent tests...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { binaryExpression } from 'stryker-parent';2binaryExpression(1, 2, 3);3import { binaryExpression } from 'stryker-parent';4binaryExpression(1, 2, 3);5import { binaryExpression } from 'stryker-parent';6binaryExpression(1, 2, 3);7import { binaryExpression } from 'stryker-parent';8binaryExpression(1, 2, 3);9import { binaryExpression } from 'stryker-parent';10binaryExpression(1, 2, 3);11import { binaryExpression } from 'stryker-parent';12binaryExpression(1, 2, 3);13import { binaryExpression } from 'stryker-parent';14binaryExpression(1, 2, 3);15import { binaryExpression } from 'stryker-parent';16binaryExpression(1, 2, 3);17import { binaryExpression } from 'stryker-parent';18binaryExpression(1, 2, 3);19import { binaryExpression } from 'stryker-parent';20binaryExpression(1, 2, 3);21import { binaryExpression } from 'stryker-parent';22binaryExpression(1, 2, 3);23import { binaryExpression } from 'stryker-parent';24binaryExpression(1, 2, 3);25import { binaryExpression } from '

Full Screen

Using AI Code Generation

copy

Full Screen

1const { binaryExpression } = require('stryker-parent');2const left = 1;3const right = 2;4const result = binaryExpression(left, right);5console.log(result);6const { binaryExpression } = require('stryker-child');7const left = 1;8const right = 2;9const result = binaryExpression(left, right);10console.log(result);11module.exports = function(config) {12 config.set({13 commandRunner: {14 }15 });16};17[2018-05-28 16:10:40.087] [INFO] SandboxPool - Creating 1 test runners (based on CPU count)18[2018-05-28 16:10:40.088] [INFO] InitialTestExecutor - Initial test run succeeded. Ran 1 tests in 0 seconds (net 0 ms, overhead

Full Screen

Using AI Code Generation

copy

Full Screen

1var BinaryExpression = require("stryker-parent").BinaryExpression;2var bi = new BinaryExpression();3bi.binaryExpression(1,2);4var BinaryExpression = require("./lib/BinaryExpression");5module.exports = BinaryExpression;6function BinaryExpression() {}7BinaryExpression.prototype.binaryExpression = function(a,b) {8 return a + b;9}10module.exports = BinaryExpression;11function foo(a, b) {12 return a + b;13}14function foo(a, b) {15 return a - b;16}17var _ = require('lodash');18var estraverse = require('estraverse');19var escodegen = require('escodegen');20var esprima = require('esprima');21var util = require('util');22var Mutator = require('stryker-api/mutant').Mutator;23function BinaryExpressionMutator() {24 Mutator.call(this);25}26util.inherits(BinaryExpressionMutator, Mutator);27BinaryExpressionMutator.prototype.name = 'BinaryExpression';28BinaryExpressionMutator.prototype.mutate = function(node) {29 var self = this;30 var mutants = [];31 estraverse.replace(node, {32 enter: function (node) {33 if (self.canMutate(node)) {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { binaryExpression } = require('stryker-parent');2console.log(binaryExpression(1, 2, '+'));3const { binaryExpression } = require('stryker-parent');4console.log(binaryExpression(1, 2, '+'));5module.exports = function(config) {6 config.set({7 thresholds: { high: 80, low: 60, break: 50 },8 strykerOptions: {9 binaryExpression: binaryExpression(1, 2, '+'),10 },11 });12};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful