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/parser/fold-constant-index-access.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/parser/fold-constant-index-access.js')
-rw-r--r-- | js/src/jit-test/tests/parser/fold-constant-index-access.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/parser/fold-constant-index-access.js b/js/src/jit-test/tests/parser/fold-constant-index-access.js new file mode 100644 index 0000000000..eabe2c5787 --- /dev/null +++ b/js/src/jit-test/tests/parser/fold-constant-index-access.js @@ -0,0 +1,47 @@ +// Constant folding optimizes the element access with string that contains +// 32-bit unsignned integer. +// The result shouldn't be visible to the script, and the optimization shouldn't +// change the behavior. + +// Asserts that the property name and the value are same. +var validator = new Proxy({}, { + set(that, prop, value) { + assertEq(prop, value); + } +}); + +// Optimizable cases. +validator["0"] = "0"; +validator["1"] = "1"; +validator["10"] = "10"; +validator["123"] = "123"; + +// Not optimizable cases. + +// More than UINT32_MAX. +validator["4294967296"] = "4294967296"; +validator["10000000000000"] = "10000000000000"; + +// Leading 0. +validator["01"] = "01"; +validator["0000001"] = "0000001"; + +// Sign. +validator["+1"] = "+1"; +validator["-1"] = "-1"; + +// Non-decimal +validator["0b1"] = "0b1"; +validator["0o1"] = "0o1"; +validator["0x1"] = "0x1"; + +// Non-integer. +validator["1.1"] = "1.1"; +validator["1."] = "1."; +validator[".1"] = ".1"; +validator["0.1"] = "0.1"; + +// Extra character. +validator["1a"] = "1a"; +validator["1 "] = "1 "; +validator[" 1"] = " 1"; |