diff options
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"; |