Skip to content

Commit

Permalink
fix(get-static-value): fix for Math.random() (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Mar 17, 2023
1 parent 2441fa7 commit 5b1d059
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/get-static-value.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const callAllowed = new Set(
isNaN,
isPrototypeOf,
...Object.getOwnPropertyNames(Math)
.filter((k) => k !== "random")
.map((k) => Math[k])
.filter((f) => typeof f === "function"),
Number,
Expand Down
2 changes: 2 additions & 0 deletions test/get-static-value.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ describe("The 'getStaticValue' function", () => {
{ code: "foo(7)", expected: null },
{ code: "obj.foo(7)", expected: null },
{ code: "Math.round(a)", expected: null },
{ code: "Math.random()", expected: null },
{ code: "Math['random']()", expected: null },
{ code: "true ? 1 : c", expected: { value: 1 } },
{ code: "false ? b : 2", expected: { value: 2 } },
{ code: "a ? 1 : 2", expected: null },
Expand Down

0 comments on commit 5b1d059

Please sign in to comment.