diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/basic/valuetosource.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/basic/valuetosource.js')
-rw-r--r-- | js/src/jit-test/tests/basic/valuetosource.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/valuetosource.js b/js/src/jit-test/tests/basic/valuetosource.js new file mode 100644 index 0000000000..739b385056 --- /dev/null +++ b/js/src/jit-test/tests/basic/valuetosource.js @@ -0,0 +1,38 @@ +// |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 { + constructor() { + super("msg", "file", 1); + this.name = "X"; + } + }`, `(new X("msg", "file", 1))`], + [`/a(b)c/`, `/a(b)c/`], + [`/abc/gi`, `/abc/gi`], + [`new Boolean(false)`, `new Boolean(false)`], + [`Object(false)`, `new Boolean(false)`], + [`new String("abc")`, `new String("abc")`], + [`Object("abc")`, `new String("abc")`], + [`new Number(42)`, `new Number(42)`], + [`Object(42)`, `new Number(42)`], + [`new Date(1579447335)`, `new Date(1579447335)`], +] + +let g = newGlobal({newCompartment: true}); +for (let [actual, expected] of TEST_CASES) { + assertEq(valueToSource(eval(actual)), expected); + assertEq(valueToSource(g.eval(actual)), expected); +} |