How to use expectAst method in stryker-parent

Best JavaScript code snippet using stryker-parent

index.spec.ts

Source:index.spec.ts Github

copy

Full Screen

1import { ExpressionParse } from "../src";2import * as D from "../src/data";3test("init unaryOps,binaryOps,literals, init simple expression", () => {4 const instance = new ExpressionParse({5 expression: "@@@@@1 ##### empty",6 unaryOps: ["@@@@@"],7 binaryOps: {8 "#####": 59 },10 literals: {11 empty: "empty"12 }13 });14 const unaryOps = instance.getUnaryOps();15 const binaryOps = instance.getBinaryOps();16 const literals = instance.getLiterals();17 expect(unaryOps).toEqual(["@@@@@"]);18 expect(binaryOps).toEqual({19 "#####": 520 });21 expect(literals).toEqual({22 empty: "empty"23 });24 const expectAst = {25 type: D.BINARY_EXPRESSION,26 left: {27 type: D.UNARY_EXPRESSION,28 operate: { type: D.UNARY_OPERATOR, value: "@@@@@", start: 0, end: 5 },29 argument: { type: D.LITERAL, value: 1, start: 5, end: 6, raw: "1" }30 },31 operator: { type: D.BINARY_OPERATOR, value: "#####", start: 7, end: 12 },32 right: { type: D.LITERAL, start: 13, end: 18, value: "empty", raw: "empty" }33 };34 expect(instance.getAst()).toEqual(expectAst);35});36test("add unaryOps,binaryOps,literals, init simple expression", () => {37 const instance = new ExpressionParse({38 expression: "@@@@@1 ##### empty + 1"39 });40 const ast = instance41 .addBinaryOps({42 "#####": 543 })44 .addUnaryOps(["@@@@@"])45 .addLiterals({46 empty: "empty"47 })48 .getAst();49 const expectAst = {50 type: D.BINARY_EXPRESSION,51 left: {52 type: D.UNARY_EXPRESSION,53 operate: {54 type: D.UNARY_OPERATOR,55 value: "@@@@@",56 start: 0,57 end: 558 },59 argument: {60 type: D.LITERAL,61 value: 1,62 start: 5,63 end: 6,64 raw: "1"65 }66 },67 operator: {68 type: D.BINARY_OPERATOR,69 value: "#####",70 start: 7,71 end: 1272 },73 right: {74 type: D.BINARY_EXPRESSION,75 left: {76 type: D.LITERAL,77 start: 13,78 end: 18,79 value: "empty",80 raw: "empty"81 },82 operator: {83 type: D.BINARY_OPERATOR,84 value: "+",85 start: 19,86 end: 2087 },88 right: {89 type: D.LITERAL,90 value: 1,91 start: 21,92 end: 22,93 raw: "1"94 }95 }96 };97 expect(ast).toEqual(expectAst);98});99test("delete unaryOps,binaryOps,literals, catch error", () => {100 const instance = new ExpressionParse({101 expression: "-1+1*false"102 });103 instance104 .removeBinaryOps(["+"])105 .removeUnaryOps(["-"])106 .removeLiterals(["false"]);107 expect(() => {108 instance.getAst();109 }).toThrow();110});111describe("test decimal point", () => {112 test("Correct decimal point ", () => {113 const instance = new ExpressionParse({114 expression: ".6+2.7"115 });116 const expectAst = {117 type: "BinaryExpression",118 left: { type: "Literal", value: 0.6, start: 0, end: 2, raw: ".6" },119 operator: { type: "BinaryOperator", value: "+", start: 2, end: 3 },120 right: { type: "Literal", value: 2.7, start: 3, end: 6, raw: "2.7" }121 };122 expect(instance.getAst()).toEqual(expectAst);123 });124 test("Wrong decimal point ", () => {125 const instance = new ExpressionParse({126 expression: ".6.5+3.1b"127 });128 expect(() => {129 instance.getAst();130 }).toThrow();131 });132});133test("empty expression", () => {134 const instance = new ExpressionParse({135 expression: ""136 });137 expect(instance.getAst()).toBeNull;138});139test("function", () => {140 const instance = new ExpressionParse({141 expression: "empty(getxx(),haha())"142 });143 const expectAst = {144 type: "CallExpression",145 callee: {146 type: "Identifier",147 start: 0,148 end: 5,149 name: "empty"150 },151 arguments: [152 {153 type: "CallExpression",154 callee: {155 type: "Identifier",156 start: 6,157 end: 11,158 name: "getxx"159 },160 arguments: []161 },162 {163 type: "CallExpression",164 callee: {165 type: "Identifier",166 start: 14,167 end: 18,168 name: "haha"169 },170 arguments: []171 }172 ]173 };174 expect(instance.getAst()).toEqual(expectAst);175});176describe("object", () => {177 test("computed true", () => {178 const instance = new ExpressionParse({179 expression: "a.b[c.d]"180 });181 const expectAst = {182 type: "MemberExpression",183 computed: true,184 object: {185 type: "MemberExpression",186 computed: false,187 object: {188 type: "Identifier",189 start: 0,190 end: 1,191 name: "a"192 },193 property: {194 type: "Identifier",195 start: 2,196 end: 3,197 name: "b"198 }199 },200 property: {201 type: "MemberExpression",202 computed: false,203 object: {204 type: "Identifier",205 start: 4,206 end: 5,207 name: "c"208 },209 property: {210 type: "Identifier",211 start: 6,212 end: 7,213 name: "d"214 }215 }216 };217 expect(instance.getAst()).toEqual(expectAst);218 });219 test("computed false", () => {220 const instance = new ExpressionParse({221 expression: "a.b.c"222 });223 const expectAst = {224 type: "MemberExpression",225 computed: false,226 object: {227 type: "MemberExpression",228 computed: false,229 object: {230 type: "Identifier",231 start: 0,232 end: 1,233 name: "a"234 },235 property: {236 type: "Identifier",237 start: 2,238 end: 3,239 name: "b"240 }241 },242 property: {243 type: "Identifier",244 start: 4,245 end: 5,246 name: "c"247 }248 };249 expect(instance.getAst()).toEqual(expectAst);250 });251});252test("Binary expression parsing error", () => {253 const instance = new ExpressionParse({254 expression: "a+"255 });256 expect(() => {257 instance.getAst();258 }).toThrow();259});260describe("test ternary expression", () => {261 test("normal ternary expression", () => {262 const instance = new ExpressionParse({263 expression: "a?b:c"264 });265 const expectAst = {266 type: D.CONDITIONAL_EXPRESSION,267 test: { type: D.IDENTIFIER, start: 0, end: 1, name: "a" },268 consequent: { type: D.IDENTIFIER, start: 2, end: 3, name: "b" },269 alternate: { type: D.IDENTIFIER, start: 4, end: 5, name: "c" }270 };271 expect(instance.getAst()).toEqual(expectAst);272 });273 test("missing consequent", () => {274 const instance = new ExpressionParse({275 expression: "a?b:"276 });277 expect(() => {278 instance.getAst();279 }).toThrow();280 });281 test("missing symbol", () => {282 const instance = new ExpressionParse({283 expression: "a?b"284 });285 expect(() => {286 instance.getAst();287 }).toThrow();288 });289 test("missing alternate", () => {290 const instance = new ExpressionParse({291 expression: "a?"292 });293 expect(() => {294 instance.getAst();295 }).toThrow();296 });297});298test("Test multiple expressions", () => {299 const instance = new ExpressionParse({300 expression: "a+b;c?a:b"301 });302 const expectAst = [303 {304 type: "BinaryExpression",305 left: {306 type: "Identifier",307 start: 0,308 end: 1,309 name: "a"310 },311 operator: {312 type: "BinaryOperator",313 value: "+",314 start: 1,315 end: 2316 },317 right: {318 type: "Identifier",319 start: 2,320 end: 3,321 name: "b"322 }323 },324 {325 type: "ConditionalExpression",326 test: {327 type: "Identifier",328 start: 4,329 end: 5,330 name: "c"331 },332 consequent: {333 type: "Identifier",334 start: 6,335 end: 7,336 name: "a"337 },338 alternate: {339 type: "Identifier",340 start: 8,341 end: 9,342 name: "b"343 }344 }345 ];346 expect(instance.getAst()).toEqual(expectAst);347});348test("test complex expression", () => {349 const instance = new ExpressionParse({350 expression: `fn(a@@@b,c@@d,e)?this:isEmpty('2')?this:(@#$1+2*3@@@##4)||(-1&&g===j)||'a\n\r\t\b\f'||[a.b,a[c],a.c.d]`351 });352 const ast = instance353 .addBinaryOps({354 "@@@": 5,355 "@@": 6356 })357 .addUnaryOps(["@#$", "##"])358 .addLiterals({359 empty: "empty",360 this: "that"361 })362 .getAst();363 const expectAst = {364 type: "ConditionalExpression",365 test: {366 type: "CallExpression",367 callee: {368 type: "Identifier",369 start: 0,370 end: 2,371 name: "fn"372 },373 arguments: [374 {375 type: "BinaryExpression",376 left: {377 type: "Identifier",378 start: 3,379 end: 4,380 name: "a"381 },382 operator: {383 type: "BinaryOperator",384 value: "@@@",385 start: 4,386 end: 7387 },388 right: {389 type: "Identifier",390 start: 7,391 end: 8,392 name: "b"393 }394 },395 {396 type: "BinaryExpression",397 left: {398 type: "Identifier",399 start: 9,400 end: 10,401 name: "c"402 },403 operator: {404 type: "BinaryOperator",405 value: "@@",406 start: 10,407 end: 12408 },409 right: {410 type: "Identifier",411 start: 12,412 end: 13,413 name: "d"414 }415 },416 {417 type: "Identifier",418 start: 14,419 end: 15,420 name: "e"421 }422 ]423 },424 consequent: {425 type: "Literal",426 start: 17,427 end: 21,428 value: "that",429 raw: "this"430 },431 alternate: {432 type: "ConditionalExpression",433 test: {434 type: "CallExpression",435 callee: {436 type: "Identifier",437 start: 22,438 end: 29,439 name: "isEmpty"440 },441 arguments: [442 {443 type: "Literal",444 value: "2",445 start: 30,446 end: 33,447 raw: "'2'"448 }449 ]450 },451 consequent: {452 type: "Literal",453 start: 35,454 end: 39,455 value: "that",456 raw: "this"457 },458 alternate: {459 type: "BinaryExpression",460 left: {461 type: "BinaryExpression",462 left: {463 type: "BinaryExpression",464 left: {465 type: "BinaryExpression",466 left: {467 type: "BinaryExpression",468 left: {469 type: "UnaryExpression",470 operate: {471 type: "UnaryOperator",472 value: "@#$",473 start: 41,474 end: 44475 },476 argument: {477 type: "Literal",478 value: 1,479 start: 44,480 end: 45,481 raw: "1"482 }483 },484 operator: {485 type: "BinaryOperator",486 value: "+",487 start: 45,488 end: 46489 },490 right: {491 type: "BinaryExpression",492 left: {493 type: "Literal",494 value: 2,495 start: 46,496 end: 47,497 raw: "2"498 },499 operator: {500 type: "BinaryOperator",501 value: "*",502 start: 47,503 end: 48504 },505 right: {506 type: "Literal",507 value: 3,508 start: 48,509 end: 49,510 raw: "3"511 }512 }513 },514 operator: {515 type: "BinaryOperator",516 value: "@@@",517 start: 49,518 end: 52519 },520 right: {521 type: "UnaryExpression",522 operate: {523 type: "UnaryOperator",524 value: "##",525 start: 52,526 end: 54527 },528 argument: {529 type: "Literal",530 value: 4,531 start: 54,532 end: 55,533 raw: "4"534 }535 }536 },537 operator: {538 type: "BinaryOperator",539 value: "||",540 start: 56,541 end: 58542 },543 right: {544 type: "BinaryExpression",545 left: {546 type: "UnaryExpression",547 operate: {548 type: "UnaryOperator",549 value: "-",550 start: 59,551 end: 60552 },553 argument: {554 type: "Literal",555 value: 1,556 start: 60,557 end: 61,558 raw: "1"559 }560 },561 operator: {562 type: "BinaryOperator",563 value: "&&",564 start: 61,565 end: 63566 },567 right: {568 type: "BinaryExpression",569 left: {570 type: "Identifier",571 start: 63,572 end: 64,573 name: "g"574 },575 operator: {576 type: "BinaryOperator",577 value: "===",578 start: 64,579 end: 67580 },581 right: {582 type: "Identifier",583 start: 67,584 end: 68,585 name: "j"586 }587 }588 }589 },590 operator: {591 type: "BinaryOperator",592 value: "||",593 start: 69,594 end: 71595 },596 right: {597 type: "Literal",598 value: "a\n\r\t\b\f",599 start: 71,600 end: 79,601 raw: "'a\n\r\t\b\f'"602 }603 },604 operator: {605 type: "BinaryOperator",606 value: "||",607 start: 79,608 end: 81609 },610 right: {611 type: "ArrayExpression",612 arguments: [613 {614 type: "MemberExpression",615 computed: false,616 object: {617 type: "Identifier",618 start: 82,619 end: 83,620 name: "a"621 },622 property: {623 type: "Identifier",624 start: 84,625 end: 85,626 name: "b"627 }628 },629 {630 type: "MemberExpression",631 computed: true,632 object: {633 type: "Identifier",634 start: 86,635 end: 87,636 name: "a"637 },638 property: {639 type: "Identifier",640 start: 88,641 end: 89,642 name: "c"643 }644 },645 {646 type: "MemberExpression",647 computed: false,648 object: {649 type: "MemberExpression",650 computed: false,651 object: {652 type: "Identifier",653 start: 91,654 end: 92,655 name: "a"656 },657 property: {658 type: "Identifier",659 start: 93,660 end: 94,661 name: "c"662 }663 },664 property: {665 type: "Identifier",666 start: 95,667 end: 96,668 name: "d"669 }670 }671 ]672 }673 }674 }675 };676 expect(ast).toEqual(expectAst);...

Full Screen

Full Screen

flare.test.js

Source:flare.test.js Github

copy

Full Screen

1const {2 select,3 ast,4 lt,5 gte,6 gt,7 ne,8 and,9 or,10 all,11 any,12 event,13 filter,14 during15} = require('../index.js').default.flare;16const { Stream } = require('../src/api.js');17function stream(name, filters) {18 return new Stream(null, name, {}, filters);19}20const expectAST = (a) => expect(JSON.parse(ast(a)));21test('select span', () => {22 const s = stream('S');23 expectAST(select()(s.when({ x: true }))).toEqual({24 select: {25 type: 'span',26 op: '==',27 stream: { name: 'S' },28 path: ['event', 'x'],29 arg: { type: 'bool', val: true }30 }31 });32});33test('any comparisons', () => {34 const moose = stream('moose');35 expectAST(36 any(37 moose.when({ x: lt(0) }),38 moose.when({ x: gte(3.141592653589793) }),39 moose.when({ b: ne(false) })40 )41 ).toEqual({42 type: 'any',43 conds: [44 {45 stream: { name: 'moose' },46 arg: { type: 'double', val: 0 },47 path: ['event', 'x'],48 type: 'span',49 op: '<'50 },51 {52 stream: { name: 'moose' },53 arg: { type: 'double', val: 3.141592653589793 },54 path: ['event', 'x'],55 type: 'span',56 op: '>='57 },58 {59 stream: { name: 'moose' },60 arg: { type: 'bool', val: false },61 path: ['event', 'b'],62 type: 'span',63 op: '!='64 }65 ]66 });67});68test('stream access', () => {69 const s = stream('S');70 expectAST(71 select()(72 s73 .when({ even: true })74 .then(s.when({ event: true }))75 .then(s.when({ event: { event: true } }))76 .then(s.when({ id: true }))77 .then(s.when({ '.id': true }))78 .then(s.when({ '.id': { '': true } }))79 .then(s.when({ true: { 真实: true } }))80 )81 ).toEqual({82 select: {83 type: 'serial',84 conds: [85 {86 type: 'span',87 op: '==',88 arg: { type: 'bool', val: true },89 path: ['event', 'even'],90 stream: { name: 'S' }91 },92 {93 type: 'span',94 op: '==',95 arg: { type: 'bool', val: true },96 path: ['event', 'event'],97 stream: { name: 'S' }98 },99 {100 type: 'span',101 op: '==',102 arg: { type: 'bool', val: true },103 path: ['event', 'event', 'event'],104 stream: { name: 'S' }105 },106 {107 type: 'span',108 op: '==',109 arg: { type: 'bool', val: true },110 path: ['event', 'id'],111 stream: { name: 'S' }112 },113 {114 type: 'span',115 op: '==',116 arg: { type: 'bool', val: true },117 path: ['event', '.id'],118 stream: { name: 'S' }119 },120 {121 type: 'span',122 op: '==',123 arg: { type: 'bool', val: true },124 path: ['event', '.id', ''],125 stream: { name: 'S' }126 },127 {128 type: 'span',129 op: '==',130 arg: { type: 'bool', val: true },131 path: ['event', 'true', '\u771f\u5b9e'],132 stream: { name: 'S' }133 }134 ]135 }136 });137});138test('all and any in serial', () => {139 const foo = stream('foo');140 const bar = stream('bar');141 const baz = stream('baz');142 const qux = stream('qux');143 const quux = stream('quux');144 expectAST(145 select()(146 any(foo.when({ x: true }), bar.when({ y: true }))147 .then(baz.when({ z: true }))148 .then(all(qux.when({ α: true }), quux.when({ β: true })))149 )150 ).toEqual({151 select: {152 type: 'serial',153 conds: [154 {155 type: 'any',156 conds: [157 {158 op: '==',159 stream: { name: 'foo' },160 path: ['event', 'x'],161 type: 'span',162 arg: { type: 'bool', val: true }163 },164 {165 op: '==',166 stream: { name: 'bar' },167 path: ['event', 'y'],168 type: 'span',169 arg: { type: 'bool', val: true }170 }171 ]172 },173 {174 op: '==',175 stream: { name: 'baz' },176 path: ['event', 'z'],177 type: 'span',178 arg: { type: 'bool', val: true }179 },180 {181 type: 'all',182 conds: [183 {184 op: '==',185 stream: { name: 'qux' },186 path: ['event', 'α'],187 type: 'span',188 arg: { type: 'bool', val: true }189 },190 {191 op: '==',192 stream: { name: 'quux' },193 path: ['event', 'β'],194 type: 'span',195 arg: { type: 'bool', val: true }196 }197 ]198 }199 ]200 }201 });202});203test('or', () => {204 const s = stream('s');205 const t = stream('t');206 expectAST(select()(or(s.when({ x: true }), t.when({ x: true })))).toEqual({207 select: {208 expr: '||',209 args: [210 {211 type: 'span',212 op: '==',213 stream: { name: 's' },214 path: ['event', 'x'],215 arg: { type: 'bool', val: true }216 },217 {218 type: 'span',219 op: '==',220 stream: { name: 't' },221 path: ['event', 'x'],222 arg: { type: 'bool', val: true }223 }224 ]225 }226 });227});228test('relative span', () => {229 const s = stream('s');230 const t = stream('t');231 expectAST(232 select()(233 or(234 s.when({ x: true }).min({ years: 1, months: 1 }),235 t.when({ x: true }).after({ minutes: 11 }).within({ seconds: 13 })236 ).max({ weeks: 1 })237 )238 ).toEqual({239 select: {240 expr: '||',241 args: [242 {243 type: 'span',244 op: '==',245 stream: { name: 's' },246 path: ['event', 'x'],247 arg: { type: 'bool', val: true },248 for: { 'at-least': { years: 1, months: 1 } }249 },250 {251 type: 'span',252 op: '==',253 stream: { name: 't' },254 path: ['event', 'x'],255 arg: { type: 'bool', val: true },256 after: { minutes: 11 },257 within: { seconds: 13 }258 }259 ],260 for: { 'at-most': { weeks: 1 } }261 }262 });263});264test('nested relative spans', () => {265 const s = stream('S');266 expectAST(267 select()(268 s.when({ x: lt(0) }).then(269 s270 .when({ x: 0 })271 .then(s.when({ x: gt(0) }).within({ seconds: 1 }))272 .within({ seconds: 2 })273 )274 )275 ).toEqual({276 select: {277 type: 'serial',278 conds: [279 {280 type: 'span',281 op: '<',282 stream: { name: 'S' },283 path: ['event', 'x'],284 arg: { type: 'double', val: 0 }285 },286 {287 type: 'serial',288 conds: [289 {290 type: 'span',291 op: '==',292 stream: { name: 'S' },293 path: ['event', 'x'],294 arg: { type: 'double', val: 0 }295 },296 {297 type: 'span',298 op: '>',299 stream: { name: 'S' },300 path: ['event', 'x'],301 arg: { type: 'double', val: 0 },302 within: { seconds: 1 }303 }304 ],305 within: { seconds: 2 }306 }307 ]308 }309 });310});311test('switches', () => {312 const s = stream('S');313 expectAST(select()(s.when(event({ x: lt(0.1) }).then({ x: gt(0) })))).toEqual(314 {315 select: {316 type: 'switch',317 stream: { name: 'S' },318 conds: [319 {320 op: '<',321 arg: { type: 'double', val: 0.1 },322 type: 'span',323 path: ['event', 'x']324 },325 {326 op: '>',327 arg: { type: 'double', val: 0 },328 type: 'span',329 path: ['event', 'x']330 }331 ]332 }333 }334 );335});336test('stream filters', () => {337 const s = stream('S', { season: 'summer' });338 expectAST(339 select()(and(s.when({ temperature: gte(77.5) }), s.when({ sunny: true })))340 ).toEqual({341 select: {342 expr: '&&',343 args: [344 {345 type: 'span',346 op: '>=',347 stream: {348 name: 'S',349 filter: {350 op: '==',351 path: ['event', 'season'],352 arg: { type: 'string', val: 'summer' }353 }354 },355 path: ['event', 'temperature'],356 arg: { type: 'double', val: 77.5 }357 },358 {359 type: 'span',360 op: '==',361 stream: {362 name: 'S',363 filter: {364 op: '==',365 path: ['event', 'season'],366 arg: { type: 'string', val: 'summer' }367 }368 },369 path: ['event', 'sunny'],370 arg: { type: 'bool', val: true }371 }372 ]373 }374 });375});376test('or stream filters', () => {377 const s = stream(378 'S',379 or(filter({ season: 'summer' }), filter({ season: 'winter' }))380 );381 expectAST(select()(s.when({ sunny: true }))).toEqual({382 select: {383 type: 'span',384 op: '==',385 arg: { type: 'bool', val: true },386 path: ['event', 'sunny'],387 stream: {388 name: 'S',389 filter: {390 expr: '||',391 args: [392 {393 op: '==',394 arg: { type: 'string', val: 'summer' },395 path: ['event', 'season']396 },397 {398 op: '==',399 arg: { type: 'string', val: 'winter' },400 path: ['event', 'season']401 }402 ]403 }404 }405 }406 });407});408test('multiple conditions is shorthand for &&', () => {409 const s = stream('S');410 const t = stream('T');411 expectAST(select()(s.when({ sunny: true }), t.when({ happy: true }))).toEqual(412 select()(and(s.when({ sunny: true }), t.when({ happy: true }))).ast413 );414});415test('specifying start and end', () => {416 const s = stream('S');417 const cond = s.when({ sunny: true });418 const base = cond.ast;419 const start = '2017-06-01T00:00:00+00:00';420 const end = '2017-06-12T00:00:00+00:00';421 expectAST(select({ start, end })(cond)).toEqual({422 between: [start, end],423 select: base424 });425 expectAST(select({ start })(cond)).toEqual({426 after: start,427 select: base428 });429 expectAST(select({ end })(cond)).toEqual({430 before: end,431 select: base432 });433});434test('during', () => {435 const s = stream('S');436 expectAST(437 select()(during(s.when({ foo: 'bar' }), s.when({ baz: gt(1.5) })))438 ).toEqual({439 select: {440 type: 'during',441 conds: [442 {443 op: '==',444 arg: {445 type: 'string',446 val: 'bar'447 },448 type: 'span',449 path: ['event', 'foo'],450 stream: {451 name: 'S'452 }453 },454 {455 op: '>',456 arg: {457 type: 'double',458 val: 1.5459 },460 type: 'span',461 path: ['event', 'baz'],462 stream: {463 name: 'S'464 }465 }466 ]467 }468 });...

Full Screen

Full Screen

parser.spec.ts

Source:parser.spec.ts Github

copy

Full Screen

1import { Tokenizer } from "../src/tokenizer";2import { Parser } from "../src/parser";3import { BinOpAST } from "../src/ast/bin-op.ast";4import { NumberAST } from "../src/ast/number.ast";5import { PlusToken } from "../src/tokens/plus.token";6import { UnaryOpAST } from "../src/ast/unary-op.ast";7import { MinusToken } from "../src/tokens/minus.token";8import { IntegerConstToken } from "../src/tokens/integer-const.token";9describe.skip('Parser tests', () => {10 test('Add op AST', () => {11 const parser = new Parser(new Tokenizer('1 + 2'));12 const expectAST = new BinOpAST(13 new NumberAST(new IntegerConstToken(1)),14 new PlusToken(),15 new NumberAST(new IntegerConstToken(2)),16 );17 const result = parser.parse();18 expect(typeof result).toBe('object');19 expect(result).toEqual(expectAST);20 });21 test('Add op with unary AST', () => {22 const parser = new Parser(new Tokenizer('1 + - 2'));23 const expectAST = new BinOpAST(24 new NumberAST(new IntegerConstToken(1)),25 new PlusToken(),26 new UnaryOpAST(27 new MinusToken(),28 new NumberAST(new IntegerConstToken(2)),29 ),30 );31 const result = parser.parse();32 expect(typeof result).toBe('object');33 expect(result).toEqual(expectAST);34 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var expectAst = require('stryker-parent').expectAst;2var expectAst = require('stryker').expectAst;3var expectAst = require('stryker-parent').expectAst;4var expectAst = require('stryker').expectAst;5var expectAst = require('stryker-parent').expectAst;6var expectAst = require('stryker').expectAst;7var expectAst = require('stryker-parent').expectAst;8var expectAst = require('stryker').expectAst;9var expectAst = require('stryker-parent').expectAst;10var expectAst = require('stryker').expectAst;11var expectAst = require('stryker-parent').expectAst;12var expectAst = require('stryker').expectAst;13var expectAst = require('stryker-parent').expectAst;14var expectAst = require('stryker').expectAst;15var expectAst = require('stryker-parent').expectAst;16var expectAst = require('stryker').expectAst;17var expectAst = require('stryker-parent').expectAst;18var expectAst = require('stryker').expectAst;

Full Screen

Using AI Code Generation

copy

Full Screen

1var expectAst = require('stryker-parent').expectAst;2expectAst('var x = 1;');3var expectAst = require('stryker-parent').expectAst;4expectAst('var x = 1;');5var expectAst = require('stryker-parent').expectAst;6expectAst('var x = 1;');7var expectAst = require('stryker-parent').expectAst;8expectAst('var x = 1;');9var expectAst = require('stryker-parent').expectAst;10expectAst('var x = 1;');11var expectAst = require('stryker-parent').expectAst;12expectAst('var x = 1;');13var expectAst = require('stryker-parent').expectAst;14expectAst('var x = 1;');15var expectAst = require('stryker-parent').expectAst;16expectAst('var x = 1;');17var expectAst = require('stryker-parent').expectAst;18expectAst('var x = 1;');19var expectAst = require('stryker-parent').expectAst;20expectAst('var x = 1;');21var expectAst = require('stryker-parent').expectAst;22expectAst('var x = 1;');23var expectAst = require('stryker-parent').expectAst;24expectAst('var x = 1;');

Full Screen

Using AI Code Generation

copy

Full Screen

1const expectAst = require('stryker-parent/expectAst');2expectAst('var foo = "bar";', 'var foo = "bar";');3expectAst('var foo = "bar";', 'var foo = "bar";', { foo: 'bar' });4expectAst('var foo = "bar";', 'var foo = "bar";', { foo: 'bar' }, { foo: 'bar' });5expectAst('var foo = "bar";', 'var foo = "bar";', { foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' });6const expectAst = require('stryker-parent/expectAst');7expectAst('var foo = "bar";', 'var foo = "bar";');8expectAst('var foo = "bar";', 'var foo = "bar";', { foo: 'bar' });9expectAst('var foo = "bar";', 'var foo = "bar";', { foo: 'bar' }, { foo: 'bar' });10expectAst('var foo = "bar";', 'var foo = "bar";', { foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' });11expectAst(actualCode: string, expectedCode: string, ...expected: Partial<Program>[]): void;12expectAstWithSourceMap(actualCode: string, expectedCode: string, ...expected: Partial<Program>[]): void;13expectAstWithSourceMapAndComments(actualCode: string, expectedCode: string, ...expected: Partial<Program>[]): void;14expectTransformedCode(actualCode: string, expectedCode: string): void;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { expectAst } = require('stryker-parent');2describe('a test', () => {3 it('should do something', () => {4 const actual = 'actual code';5 const expected = 'expected code';6 expectAst(actual).to.equal(expected);7 });8});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { expectAst } = require('stryker-parent');2const { parse } = require('acorn');3const code = 'const foo = "bar";';4const ast = parse(code);5expectAst(ast).toMatchSnapshot();6const { expectAst } = require('stryker-parent');7const { parse } = require('acorn');8const code = 'const foo = "bar";';9const ast = parse(code);10expectAst(ast).toMatchSnapshot();11const { expectAst } = require('stryker-parent');12const { parse } = require('acorn');13const code = 'const foo = "bar";';14const ast = parse(code);15expectAst(ast).toMatchSnapshot();16const { expectAst } = require('stryker-parent');17const { parse } = require('acorn');18const code = 'const foo = "bar";';19const ast = parse(code);20expectAst(ast).toMatchSnapshot();21const { expectAst } = require('stryker-parent');22const { parse } = require('acorn');23const code = 'const foo = "bar";';24const ast = parse(code);25expectAst(ast).toMatchSnapshot();26const { expectAst } = require('stryker-parent');27const { parse } = require('acorn');28const code = 'const foo = "bar";';29const ast = parse(code);30expectAst(ast).toMatchSnapshot();31const { expectAst } = require('stryker-parent');32const { parse } = require('acorn');33const code = 'const foo = "bar";';34const ast = parse(code);35expectAst(ast).toMatchSnapshot();36const { expectAst } = require('stryker-parent');37const { parse } = require('acorn');38const code = 'const foo = "bar";';39const ast = parse(code);40expectAst(ast).toMatchSnapshot();

Full Screen

Using AI Code Generation

copy

Full Screen

1const expectAst = require('stryker-parent').expectAst;2describe('my test', () => {3 it('should do something', () => {4 const code = 'let x = 1';5 expectAst(code).toMatchSnapshot();6 });7});8expectAst(code).toMatchAst({9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const expectAst = require('stryker-parent').expectAst;2const add = require('./add');3describe('add', () => {4 it('should add two numbers', () => {5 expect(add(1, 2)).toBe(3);6 });7 it('should add two numbers using AST', () => {8 expectAst(add).toMutate({9 original: {10 },11 replacement: {12 }13 });14 });15});16module.exports = function add(a, b) {17 return a + b;18};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { expectAst } = require('stryker-parent');2const { myFunction } = require('./myFunction');3const { myOtherFunction } = require('./myOtherFunction');4describe('myFunction', () => {5 it('should return a value', () => {6 expect(myFunction()).toEqual('a value');7 });8});9describe('myOtherFunction', () => {10 it('should return a value', () => {11 expect(myOtherFunction()).toEqual('a value');12 });13});14describe('myOtherFunction', () => {15 it('should return a value', () => {16 const ast = expectAst(myOtherFunction);17 ast.toHaveExpression('a value');18 });19});20module.exports.myFunction = () => {21 return 'a value';22};23module.exports.myOtherFunction = () => {24 return 'a value';25};26const { expectAst } = require('stryker-parent');27const { myFunction } = require('./myFunction');28describe('myFunction', () => {29 it('should return a value', () => {30 const ast = expectAst(myFunction);31 ast.toHaveExpression('a value');32 });33});34const { expectAst } = require('stryker-parent');35const { myOtherFunction } = require('./myOtherFunction');36describe('myOtherFunction', () => {37 it('should return a value', () => {38 const ast = expectAst(myOtherFunction);39 ast.toHaveExpression('a value');40 });41});42const { expectAst } = require('stryker-parent');43const { myFunction } = require('./myFunction');44describe('myFunction', () => {45 it('should return a value', () => {46 const ast = expectAst(myFunction);47 ast.toHaveExpression('a value');48 });49});50const { expectAst } = require('stryker-parent');51const { myOtherFunction } = require('./myOtherFunction');52describe('myOtherFunction', () => {53 it('should return a value', () => {54 const ast = expectAst(myOtherFunction);55 ast.toHaveExpression('a value');56 });57});

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