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/function/function-displayName-computed.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/function/function-displayName-computed.js')
-rw-r--r-- | js/src/jit-test/tests/function/function-displayName-computed.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/function/function-displayName-computed.js b/js/src/jit-test/tests/function/function-displayName-computed.js new file mode 100644 index 0000000000..9a19fe1a4f --- /dev/null +++ b/js/src/jit-test/tests/function/function-displayName-computed.js @@ -0,0 +1,69 @@ +// |jit-test| skip-if: isLcovEnabled() +// Guessed Atoms tests. +// Test String literals +var obj = { + ["func"]: function() {return function() {} }, + ["arrowFunc"]: ()=>{return function() {} }, + ["method"]() {return function() {} }, + ["nonAnonymousFunc"]: function F() {return function() {} }, + get ["getter"]() {return function() {} }, +}; + + +assertEq(displayName(obj.func()), "func/<"); +assertEq(displayName(obj.arrowFunc()), "arrowFunc/<"); +assertEq(displayName(obj.method()), "method/<"); +assertEq(displayName(obj.nonAnonymousFunc()), "F/<"); + +// We don't support guessed name for accessor +assertEq(displayName(obj.getter), ""); + +let dummy = class { + ["func"]() {return function() {} } + ["arrowFunc"] = ()=>{return function() {} }; + ["method"]() {return function() {} } + get ["getter"]() {return function() {} } +}; + +dum = new dummy(); +assertEq(displayName(dum.func()), "func/<"); +// We don't support guessed name for class field with computed name +assertEq(displayName(dum.arrowFunc()), "dummy</</<"); +assertEq(displayName(dum.method()), "method/<"); +// We don't support guessed name for accessor +assertEq(displayName(dummy.prototype.getter), "dummy</<"); + + +// Test numeric literals +var objN = { + [1]: function() {return function() {}}, + [5]: ()=>{return function() {}}, + [7] () {return function() {}}, + [8]: class {}, + [9]: function F() {return function() {}}, + [10]: class C{}, + get [11]() {return function() {}}, +}; +assertEq(displayName(objN[1]()), "1/<"); +assertEq(displayName(objN[5]()), "5/<"); +assertEq(displayName(objN[7]()), "7/<"); +assertEq(displayName(objN[8]), "8"); +assertEq(displayName(objN[9]()), "F/<"); +assertEq(displayName(objN[10]), "C"); +// We don't support guessed name for accessor +assertEq(displayName(objN[11]), "objN/<"); + +let foo = class { + [1] () {return function() {} } + [5] = ()=>{return function() {} }; + [7] () {return function() {} } + get [11]() {return function() {} } +}; + +f = new foo(); + +assertEq(displayName(f[1]()), "1/<"); +// We don't support guessed name for class field with computed name +assertEq(displayName(f[5]()), "foo</</<"); +assertEq(displayName(f[7]()), "7/<"); +assertEq(displayName(f[11]), "foo</<"); |