forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1606084 - ValueToSource should be able to handle wrapped objects.…
… r=jwalden Differential Revision: https://phabricator.services.mozilla.com/D60312 --HG-- extra : moz-landing-system : lando
- Loading branch information
Showing
5 changed files
with
52 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
// |jit-test| --disable-tosource | ||
|
||
const TEST_CASES = [ | ||
[undefined, "(void 0)"], | ||
[null, "null"], | ||
[true, "true"], | ||
[Symbol("abc"), `Symbol("abc")`], | ||
[15, "15"], | ||
[-0, "-0"], | ||
["abc", `"abc"`], | ||
[function a() { return 1; }, `(function a() { return 1; })`], | ||
[[1, 2, 3], `[1, 2, 3]`], | ||
[[1, {a: 0, b: 0}, 2], `[1, {a:0, b:0}, 2]`], | ||
[{a: [1, 2, 3]}, `({a:[1, 2, 3]})`], | ||
[new Error("msg", "file", 1), `(new Error("msg", "file", 1))`], | ||
[new TypeError("msg", "file", 1), `(new TypeError("msg", "file", 1))`], | ||
[new class X extends Error { | ||
[`undefined`, "(void 0)"], | ||
[`null`, "null"], | ||
[`true`, "true"], | ||
[`Symbol("abc")`, `Symbol("abc")`], | ||
[`15`, "15"], | ||
[`-0`, "-0"], | ||
[`"abc"`, `"abc"`], | ||
[`(function a() { return 1; })`, `(function a() { return 1; })`], | ||
[`[1, 2, 3]`, `[1, 2, 3]`], | ||
[`[1, {a: 0, b: 0}, 2]`, `[1, {a:0, b:0}, 2]`], | ||
[`({a: [1, 2, 3]})`, `({a:[1, 2, 3]})`], | ||
[`new Error("msg", "file", 1)`, `(new Error("msg", "file", 1))`], | ||
[`new TypeError("msg", "file", 1)`, `(new TypeError("msg", "file", 1))`], | ||
[`new class X extends Error { | ||
constructor() { | ||
super("msg", "file", 1); | ||
this.name = "X"; | ||
} | ||
}, `(new X("msg", "file", 1))`], | ||
[/a(b)c/, `/a(b)c/`], | ||
[/abc/gi, `/abc/gi`], | ||
}`, `(new X("msg", "file", 1))`], | ||
[`/a(b)c/`, `/a(b)c/`], | ||
[`/abc/gi`, `/abc/gi`], | ||
] | ||
|
||
let g = newGlobal({newCompartment: true}); | ||
for (let [actual, expected] of TEST_CASES) { | ||
assertEq(valueToSource(actual), expected); | ||
assertEq(valueToSource(eval(actual)), expected); | ||
assertEq(valueToSource(g.eval(actual)), expected); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters