Increase the code coverage for traverse evaluation (#5363)
* When applied this commit will increase the code coverage for evaluation.js * Fixing linting issues
This commit is contained in:
parent
11b7db05fb
commit
412180e203
@ -61,6 +61,27 @@ describe("evaluation", function () {
|
||||
);
|
||||
});
|
||||
|
||||
it("should evaluate template literals", function () {
|
||||
assert.strictEqual(
|
||||
getPath("var x = 8; var y = 1; var z = `value is ${x >>> y}`")
|
||||
.get("body.2.declarations.0.init").evaluate().value,
|
||||
"value is 4"
|
||||
);
|
||||
});
|
||||
|
||||
it("should evaluate member expressions", function () {
|
||||
assert.strictEqual(
|
||||
getPath("var x = 'foo'.length")
|
||||
.get("body.0.declarations.0.init").evaluate().value,
|
||||
3
|
||||
);
|
||||
const member_expr = getPath("var x = Math.min(2,Math.max(3,4));var y = Math.random();");
|
||||
const eval_member_expr = member_expr.get("body.0.declarations.0.init").evaluate();
|
||||
const eval_invalid_call = member_expr.get("body.1.declarations.0.init").evaluate();
|
||||
assert.strictEqual(eval_member_expr.value, 2);
|
||||
assert.strictEqual(eval_invalid_call.confident, false);
|
||||
});
|
||||
|
||||
it("it should not deopt vars in different scope", function () {
|
||||
const input = "var a = 5; function x() { var a = 5; var b = a + 1; } var b = a + 2";
|
||||
assert.strictEqual(
|
||||
@ -88,6 +109,12 @@ describe("evaluation", function () {
|
||||
getPath(constExample).get("body.1.consequent.body.1").evaluate().value,
|
||||
false
|
||||
);
|
||||
const test_alternate = "var y = (3 < 4)? 3 + 4: 3 + 4;";
|
||||
assert.strictEqual(
|
||||
getPath(test_alternate)
|
||||
.get("body.0.declarations.0.init.alternate").evaluate().value,
|
||||
7
|
||||
);
|
||||
});
|
||||
|
||||
it("should deopt ids that are referenced before the bindings", function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user