Debian Codegraph @

js/src/jit-test/tests/cacheir/string-fromCharCode-double.js

raw
1 // Test inlining String.fromCharCode with Double instead of Int32 inputs.
2
3 function test() {
4 for (let i = 0; i < 0xffff; ++i) {
5 let expected = String.fromCharCode(i);
6
7 // Ensure the Double input is truncated to Int32.
8 assertEq(String.fromCharCode(i + 0.5), expected);
9
10 // The input is converted using ToUint16.
11 assertEq(String.fromCharCode(i + 0.5 + 0x10_000), expected);
12
13 // Test ToUint16 conversion when adding INT32_MAX + 1.
14 assertEq(String.fromCharCode(i + 0x8000_0000), expected);
15 }
16 }
17 for (let i = 0; i < 2; ++i) test();