Fix parenthesis for nullish coalescing (#10269)

* ♻️ added condition to check for left and right of nullish coalescing operator and if any is a logical expression without a paren then throw an error

* 🐛 bugs fixed and test cases updated for babel parser

* ♻️ code comments added

* 🐛 spell error rectified

* ♻️ failing test updated

* 🐛 push tests after make build

* Skip nullish-coalescing flow precedence tests

They're now incorrect

* ♻️ error message updated, binop priority of other logical operators +1 from ?? and

* ♻️ increaed the binOp for in and instanceOf, added logic to print the brackets in an ?? && || expression, test cases added

* 🐛 failing test fixed and comments updated

* ♻️ new lines added between tests

* ♻️ basic tests for checking the binOp of instanceOf, in and relational operators to be equal added

* ♻️ new lines added in between tests
This commit is contained in:
Vivek Nayyar
2019-09-06 22:35:44 +07:00
committed by Nicolò Ribaudo
parent 3e8a5c5e28
commit b02e35c19a
26 changed files with 282 additions and 142 deletions

View File

@@ -0,0 +1,15 @@
import { types } from "../../../src/tokenizer/types";
describe("token types", () => {
it("should check if the binOp for relational === in", () => {
expect(types.relational.binop).toEqual(types._in.binop);
});
it("should check if the binOp for relational === instanceOf", () => {
expect(types.relational.binop).toEqual(types._instanceof.binop);
});
it("should check if the binOp for in === instanceOf", () => {
expect(types._in.binop).toEqual(types._instanceof.binop);
});
});