Skip to content

Commit 5b1d059

Browse files
authored
fix(get-static-value): fix for Math.random() (#79)
1 parent 2441fa7 commit 5b1d059

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Diff for: src/get-static-value.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const callAllowed = new Set(
7979
isNaN,
8080
isPrototypeOf,
8181
...Object.getOwnPropertyNames(Math)
82+
.filter((k) => k !== "random")
8283
.map((k) => Math[k])
8384
.filter((f) => typeof f === "function"),
8485
Number,

Diff for: test/get-static-value.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ describe("The 'getStaticValue' function", () => {
4343
{ code: "foo(7)", expected: null },
4444
{ code: "obj.foo(7)", expected: null },
4545
{ code: "Math.round(a)", expected: null },
46+
{ code: "Math.random()", expected: null },
47+
{ code: "Math['random']()", expected: null },
4648
{ code: "true ? 1 : c", expected: { value: 1 } },
4749
{ code: "false ? b : 2", expected: { value: 2 } },
4850
{ code: "a ? 1 : 2", expected: null },

0 commit comments

Comments
 (0)