Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
chore: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioduarte committed Dec 1, 2022
1 parent c7a2e1f commit 87bca70
Show file tree
Hide file tree
Showing 12 changed files with 1,259 additions and 784 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ Math.pow(a, b);
(Math).pow(a, b);

// able to catch some workarounds
Math['pow'](a, b);
Math["pow"](a, b);
Math[`pow`](a, b);
(Math)['pow'](a, b);
(Math)["pow"](a, b);
Expand All @@ -18,9 +16,35 @@ switch(foo){ case Math.pow(a, b): break; }
function foo(bar, baz = Math.pow(a, b), quux){}
`${Math.pow(a, b)}`

// non-expression parents that do require parens
class C extends Math.pow(a, b) {}

// already parenthesised, shouldn't insert extra parens
+(Math.pow(a, b))
(Math.pow(a, b)).toString()
(class extends (Math.pow(a, b)) {})
class C extends (Math.pow(a, b)) {}

// '**' is right-associative, that applies to both parent and child nodes
a ** Math.pow(b, c);
Math.pow(a, b) ** c;
Math.pow(a, b ** c);
Math.pow(a ** b, c);
a ** Math.pow(b ** c, d ** e) ** f;

// doesn't remove already existing unnecessary parens around the whole expression
(Math.pow(a, b));
foo + (Math.pow(a, b));
(Math.pow(a, b)) + foo;
`${(Math.pow(a, b))}`;

// doesn't preserve unnecessary parens around base and exponent
Math.pow((a), (b))
Math.pow(((a)), ((b)))
Math.pow((a.foo), b)
Math.pow(a, (b.foo))
Math.pow((a()), b)
Math.pow(a, (b()))

// Optional chaining
Math.pow?.(a, b)
Expand Down
Loading

0 comments on commit 87bca70

Please sign in to comment.