diff options
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/cacheir/string-fromCharCode-double.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/cacheir/string-fromCharCode-double.js b/js/src/jit-test/tests/cacheir/string-fromCharCode-double.js new file mode 100644 index 0000000000..4db1787148 --- /dev/null +++ b/js/src/jit-test/tests/cacheir/string-fromCharCode-double.js @@ -0,0 +1,17 @@ +// Test inlining String.fromCharCode with Double instead of Int32 inputs. + +function test() { + for (let i = 0; i < 0xffff; ++i) { + let expected = String.fromCharCode(i); + + // Ensure the Double input is truncated to Int32. + assertEq(String.fromCharCode(i + 0.5), expected); + + // The input is converted using ToUint16. + assertEq(String.fromCharCode(i + 0.5 + 0x10_000), expected); + + // Test ToUint16 conversion when adding INT32_MAX + 1. + assertEq(String.fromCharCode(i + 0x8000_0000), expected); + } +} +for (let i = 0; i < 2; ++i) test(); |