Skip to content

Commit 9706dc0

Browse files
authored
Add $convertI32PairToI53Checked in library_int53.js. (#16866)
* Add $convertI32PairToI53Checked in library_int53.js. And add a test. * Address review * Use tools.utils.write_file to rebaseline library_int53.js tests
1 parent a62c811 commit 9706dc0

File tree

4 files changed

+249
-2
lines changed

4 files changed

+249
-2
lines changed

src/library_int53.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ mergeInto(LibraryManager.library, {
106106
return (lo >>> 0) + hi * 4294967296;
107107
},
108108

109+
// Converts the given signed 32-bit low-high pair to a JavaScript Number that can
110+
// represent 53 bits of precision. Returns a NaN if the number exceeds the safe
111+
// integer range representable by a Number (x > 9007199254740992 || x < -9007199254740992)
112+
$convertI32PairToI53Checked: function(lo, hi) {
113+
#if ASSERTIONS
114+
assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
115+
assert(hi === (hi|0)); // hi should be a i32
116+
#endif
117+
return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
118+
},
119+
109120
// Converts the given unsigned 32-bit low-high pair to a JavaScript Number that can
110121
// represent 53 bits of precision.
111122
// TODO: Add $convertU32PairToI53Signaling() variant.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#ifdef __EMSCRIPTEN__
2+
#include <emscripten.h>
3+
#endif
4+
5+
#include "test_int53.h"
6+
7+
#include <stdio.h>
8+
#include <stdlib.h>
9+
10+
// Uncomment to compute the expected results without testing:
11+
//#define GENERATE_ANSWERS
12+
13+
double test(int64_t val) {
14+
int32_t lo = (uint32_t)val;
15+
int32_t hi = (uint64_t)val >> 32;
16+
printf("input=%lld / 0x%llx: convertI32PairToI53Checked(lo=%d hi=%d)=", val, val, lo, hi);
17+
#ifdef GENERATE_ANSWERS
18+
int64_t v = (uint64_t)(uint32_t)lo;
19+
v |= ((uint64_t)(uint32_t)hi) << 32;
20+
double out = v > 9007199254740992ll || v < -9007199254740992ll ? (double)NAN : v;
21+
#else
22+
double out = EM_ASM_DOUBLE(return convertI32PairToI53Checked($0, $1), lo, hi);
23+
#endif
24+
printf("%f\n", out);
25+
return out;
26+
}
27+
28+
int main() {
29+
printf("Testing library_int53.js function $convertI32PairToI53Checked():\n\n");
30+
31+
printf("Testing positive losslessIntegers:\n");
32+
for (uint64_t num : losslessIntegers) {
33+
double ret = test(num);
34+
if (ret != num) return 1;
35+
}
36+
37+
printf("\nTesting negative losslessIntegers:\n");
38+
for (uint64_t num : losslessIntegers) {
39+
int64_t neg = -(int64_t)num;
40+
double ret = test(neg);
41+
if (ret != neg) return 1;
42+
}
43+
44+
printf("\nTesting preciseUnsignedIntegers:\n");
45+
for (uint64_t num : preciseUnsignedIntegers) {
46+
double ret = test(num);
47+
if (!isnan(ret)) return 1;
48+
}
49+
50+
printf("\nTesting preciseNegativeIntegers:\n");
51+
for (uint64_t num : preciseNegativeIntegers) {
52+
double ret = test(num);
53+
if (!isnan(ret)) return 1;
54+
}
55+
56+
printf("\nTesting impreciseUnsignedIntegers:\n");
57+
for (uint64_t num : impreciseUnsignedIntegers) {
58+
test(num);
59+
}
60+
61+
printf("\nTesting impreciseNegativeIntegers:\n");
62+
for (uint64_t num : impreciseNegativeIntegers) {
63+
double ret = test(num);
64+
if (!isnan(ret)) return 1;
65+
}
66+
67+
printf("\nTesting otherDoubles:\n");
68+
for (int sign = 0; sign < 2; ++sign) {
69+
for (double d : otherDoubles) {
70+
double num = sign ? -d : d;
71+
uint64_t u = *(uint64_t*)&num;
72+
printf("Double: %f -> ", num);
73+
test(u);
74+
}
75+
}
76+
printf("All done!\n");
77+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
Testing library_int53.js function $convertI32PairToI53Checked():
2+
3+
Testing positive losslessIntegers:
4+
input=0 / 0x0: convertI32PairToI53Checked(lo=0 hi=0)=0.000000
5+
input=1 / 0x1: convertI32PairToI53Checked(lo=1 hi=0)=1.000000
6+
input=2 / 0x2: convertI32PairToI53Checked(lo=2 hi=0)=2.000000
7+
input=3 / 0x3: convertI32PairToI53Checked(lo=3 hi=0)=3.000000
8+
input=16777215 / 0xffffff: convertI32PairToI53Checked(lo=16777215 hi=0)=16777215.000000
9+
input=16777216 / 0x1000000: convertI32PairToI53Checked(lo=16777216 hi=0)=16777216.000000
10+
input=16777217 / 0x1000001: convertI32PairToI53Checked(lo=16777217 hi=0)=16777217.000000
11+
input=16909060 / 0x1020304: convertI32PairToI53Checked(lo=16909060 hi=0)=16909060.000000
12+
input=2147483647 / 0x7fffffff: convertI32PairToI53Checked(lo=2147483647 hi=0)=2147483647.000000
13+
input=2147483648 / 0x80000000: convertI32PairToI53Checked(lo=-2147483648 hi=0)=2147483648.000000
14+
input=2415919104 / 0x90000000: convertI32PairToI53Checked(lo=-1879048192 hi=0)=2415919104.000000
15+
input=4294967295 / 0xffffffff: convertI32PairToI53Checked(lo=-1 hi=0)=4294967295.000000
16+
input=4294967296 / 0x100000000: convertI32PairToI53Checked(lo=0 hi=1)=4294967296.000000
17+
input=4294967297 / 0x100000001: convertI32PairToI53Checked(lo=1 hi=1)=4294967297.000000
18+
input=6442450943 / 0x17fffffff: convertI32PairToI53Checked(lo=2147483647 hi=1)=6442450943.000000
19+
input=6442450944 / 0x180000000: convertI32PairToI53Checked(lo=-2147483648 hi=1)=6442450944.000000
20+
input=68719476735 / 0xfffffffff: convertI32PairToI53Checked(lo=-1 hi=15)=68719476735.000000
21+
input=4538990157889536 / 0x10203000000000: convertI32PairToI53Checked(lo=0 hi=1056816)=4538990157889536.000000
22+
input=9007194959773696 / 0x1fffff00000000: convertI32PairToI53Checked(lo=0 hi=2097151)=9007194959773696.000000
23+
input=9007194959773697 / 0x1fffff00000001: convertI32PairToI53Checked(lo=1 hi=2097151)=9007194959773697.000000
24+
input=9007199254740990 / 0x1ffffffffffffe: convertI32PairToI53Checked(lo=-2 hi=2097151)=9007199254740990.000000
25+
input=9007199254740991 / 0x1fffffffffffff: convertI32PairToI53Checked(lo=-1 hi=2097151)=9007199254740991.000000
26+
input=9007199254740992 / 0x20000000000000: convertI32PairToI53Checked(lo=0 hi=2097152)=9007199254740992.000000
27+
28+
Testing negative losslessIntegers:
29+
input=0 / 0x0: convertI32PairToI53Checked(lo=0 hi=0)=0.000000
30+
input=-1 / 0xffffffffffffffff: convertI32PairToI53Checked(lo=-1 hi=-1)=-1.000000
31+
input=-2 / 0xfffffffffffffffe: convertI32PairToI53Checked(lo=-2 hi=-1)=-2.000000
32+
input=-3 / 0xfffffffffffffffd: convertI32PairToI53Checked(lo=-3 hi=-1)=-3.000000
33+
input=-16777215 / 0xffffffffff000001: convertI32PairToI53Checked(lo=-16777215 hi=-1)=-16777215.000000
34+
input=-16777216 / 0xffffffffff000000: convertI32PairToI53Checked(lo=-16777216 hi=-1)=-16777216.000000
35+
input=-16777217 / 0xfffffffffeffffff: convertI32PairToI53Checked(lo=-16777217 hi=-1)=-16777217.000000
36+
input=-16909060 / 0xfffffffffefdfcfc: convertI32PairToI53Checked(lo=-16909060 hi=-1)=-16909060.000000
37+
input=-2147483647 / 0xffffffff80000001: convertI32PairToI53Checked(lo=-2147483647 hi=-1)=-2147483647.000000
38+
input=-2147483648 / 0xffffffff80000000: convertI32PairToI53Checked(lo=-2147483648 hi=-1)=-2147483648.000000
39+
input=-2415919104 / 0xffffffff70000000: convertI32PairToI53Checked(lo=1879048192 hi=-1)=-2415919104.000000
40+
input=-4294967295 / 0xffffffff00000001: convertI32PairToI53Checked(lo=1 hi=-1)=-4294967295.000000
41+
input=-4294967296 / 0xffffffff00000000: convertI32PairToI53Checked(lo=0 hi=-1)=-4294967296.000000
42+
input=-4294967297 / 0xfffffffeffffffff: convertI32PairToI53Checked(lo=-1 hi=-2)=-4294967297.000000
43+
input=-6442450943 / 0xfffffffe80000001: convertI32PairToI53Checked(lo=-2147483647 hi=-2)=-6442450943.000000
44+
input=-6442450944 / 0xfffffffe80000000: convertI32PairToI53Checked(lo=-2147483648 hi=-2)=-6442450944.000000
45+
input=-68719476735 / 0xfffffff000000001: convertI32PairToI53Checked(lo=1 hi=-16)=-68719476735.000000
46+
input=-4538990157889536 / 0xffefdfd000000000: convertI32PairToI53Checked(lo=0 hi=-1056816)=-4538990157889536.000000
47+
input=-9007194959773696 / 0xffe0000100000000: convertI32PairToI53Checked(lo=0 hi=-2097151)=-9007194959773696.000000
48+
input=-9007194959773697 / 0xffe00000ffffffff: convertI32PairToI53Checked(lo=-1 hi=-2097152)=-9007194959773697.000000
49+
input=-9007199254740990 / 0xffe0000000000002: convertI32PairToI53Checked(lo=2 hi=-2097152)=-9007199254740990.000000
50+
input=-9007199254740991 / 0xffe0000000000001: convertI32PairToI53Checked(lo=1 hi=-2097152)=-9007199254740991.000000
51+
input=-9007199254740992 / 0xffe0000000000000: convertI32PairToI53Checked(lo=0 hi=-2097152)=-9007199254740992.000000
52+
53+
Testing preciseUnsignedIntegers:
54+
input=9007199254740994 / 0x20000000000002: convertI32PairToI53Checked(lo=2 hi=2097152)=nan
55+
input=-9223372036854775808 / 0x8000000000000000: convertI32PairToI53Checked(lo=0 hi=-2147483648)=nan
56+
input=10684768937290248 / 0x25f5bda103aa08: convertI32PairToI53Checked(lo=-1593595384 hi=2487741)=nan
57+
input=17794735985140884 / 0x3f3837d5442494: convertI32PairToI53Checked(lo=-716954476 hi=4143159)=nan
58+
input=24124026775257760 / 0x55b4acae7dc2a0: convertI32PairToI53Checked(lo=-1367489888 hi=5616812)=nan
59+
input=32297031363930280 / 0x72bdfa99bf28a8: convertI32PairToI53Checked(lo=-1715525464 hi=7519738)=nan
60+
input=46167792506543936 / 0xa4055cd86a9f40: convertI32PairToI53Checked(lo=-664101056 hi=10749276)=nan
61+
input=82665451100278032 / 0x125afca30078d10: convertI32PairToI53Checked(lo=805801232 hi=19247050)=nan
62+
input=82908143057184192 / 0x1268c844fe925c0: convertI32PairToI53Checked(lo=1340679616 hi=19303556)=nan
63+
input=83912190268867232 / 0x12a1db1454d02a0: convertI32PairToI53Checked(lo=1162674848 hi=19537329)=nan
64+
input=89664494320124096 / 0x13e8d61ecea80c0: convertI32PairToI53Checked(lo=-320175936 hi=20876641)=nan
65+
input=110368417731171280 / 0x1881b7dbd49d3d0: convertI32PairToI53Checked(lo=-1119235120 hi=25697149)=nan
66+
input=1145953455528558336 / 0xfe73e98a5e93f00: convertI32PairToI53Checked(lo=-1511440640 hi=266813080)=nan
67+
input=3045800721111138304 / 0x2a44db9e56754000: convertI32PairToI53Checked(lo=1450524672 hi=709155742)=nan
68+
input=9223372036854774784 / 0x7ffffffffffffc00: convertI32PairToI53Checked(lo=-1024 hi=2147483647)=nan
69+
70+
Testing preciseNegativeIntegers:
71+
input=-9007199254740994 / 0xffdffffffffffffe: convertI32PairToI53Checked(lo=-2 hi=-2097153)=nan
72+
input=-12617674251062866 / 0xffd32c4ac85fb1ae: convertI32PairToI53Checked(lo=-933252690 hi=-2937782)=nan
73+
input=-55648245524499544 / 0xff3a4c372d2373a8: convertI32PairToI53Checked(lo=757298088 hi=-12956617)=nan
74+
input=-66000169181570864 / 0xff15853220d118d0: convertI32PairToI53Checked(lo=550574288 hi=-15366862)=nan
75+
input=-120096864633363760 / 0xfe555489b4e3e2d0: convertI32PairToI53Checked(lo=-1260133680 hi=-27962231)=nan
76+
input=-361031700292802688 / 0xfafd5b94d7646780: convertI32PairToI53Checked(lo=-681285760 hi=-84059244)=nan
77+
input=-560694631167452608 / 0xf838033421cb9a40: convertI32PairToI53Checked(lo=566991424 hi=-130546892)=nan
78+
input=-3237861497225076224 / 0xd310ce1f89fc2200: convertI32PairToI53Checked(lo=-1979964928 hi=-753873377)=nan
79+
input=-3861047501233185792 / 0xca6acdc11c161c00: convertI32PairToI53Checked(lo=471211008 hi=-898970175)=nan
80+
input=-5809229155090978816 / 0xaf6178dcaff5a800: convertI32PairToI53Checked(lo=-1342855168 hi=-1352566564)=nan
81+
input=-7278325711600376832 / 0x9afe3153d877a400: convertI32PairToI53Checked(lo=-663247872 hi=-1694617261)=nan
82+
input=-8396058280915096576 / 0x8b7b357a4c942c00: convertI32PairToI53Checked(lo=1284779008 hi=-1954859654)=nan
83+
84+
Testing impreciseUnsignedIntegers:
85+
input=9007199254740993 / 0x20000000000001: convertI32PairToI53Checked(lo=1 hi=2097152)=nan
86+
input=127505432520080110 / 0x1c4fd83ec4abaee: convertI32PairToI53Checked(lo=-330646802 hi=29687171)=nan
87+
input=479805370944382924 / 0x6a89c715876e7cc: convertI32PairToI53Checked(lo=1484187596 hi=111713393)=nan
88+
input=741614427870654944 / 0xa4abe649588f1e0: convertI32PairToI53Checked(lo=-1786187296 hi=172670564)=nan
89+
input=907487167196863996 / 0xc980ac53efe9dfc: convertI32PairToI53Checked(lo=1056873980 hi=211290821)=nan
90+
input=1756673437269809681 / 0x1860f52f16d4da11: convertI32PairToI53Checked(lo=383048209 hi=409007407)=nan
91+
input=1840835048382645901 / 0x198bf5b92cefc68d: convertI32PairToI53Checked(lo=753911437 hi=428602809)=nan
92+
input=3027162577017478950 / 0x2a02a453407b9f26: convertI32PairToI53Checked(lo=1081843494 hi=704816211)=nan
93+
input=3941293303591155941 / 0x36b24960b42d38e5: convertI32PairToI53Checked(lo=-1272104731 hi=917653856)=nan
94+
input=8081542314388259075 / 0x702767eac6668103: convertI32PairToI53Checked(lo=-966360829 hi=1881630698)=nan
95+
input=-9164540905907573330 / 0x80d1029a15d7adae: convertI32PairToI53Checked(lo=366456238 hi=-2133785958)=nan
96+
input=-7971287758477026451 / 0x91604c04718e9b6d: convertI32PairToI53Checked(lo=1905171309 hi=-1855960060)=nan
97+
input=-5424086639962337831 / 0xb4b9c5f0621a4dd9: convertI32PairToI53Checked(lo=1645891033 hi=-1262893584)=nan
98+
input=-4523806170446195733 / 0xc138364191d593eb: convertI32PairToI53Checked(lo=-1848273941 hi=-1053280703)=nan
99+
input=-4056602181414254248 / 0xc7b40dcf0dba8958: convertI32PairToI53Checked(lo=230328664 hi=-944501297)=nan
100+
input=-966053959041631511 / 0xf297e30ae976bae9: convertI32PairToI53Checked(lo=-378094871 hi=-224926966)=nan
101+
input=-366479884486708211 / 0xfaea007c9bd7f40d: convertI32PairToI53Checked(lo=-1680346099 hi=-85327748)=nan
102+
input=-308319151265219435 / 0xfbb8a15d8f62fc95: convertI32PairToI53Checked(lo=-1889338219 hi=-71786147)=nan
103+
input=-1 / 0xffffffffffffffff: convertI32PairToI53Checked(lo=-1 hi=-1)=-1.000000
104+
105+
Testing impreciseNegativeIntegers:
106+
input=-9007199254740993 / 0xffdfffffffffffff: convertI32PairToI53Checked(lo=-1 hi=-2097153)=nan
107+
input=-133996157760400114 / 0xfe23f334576c950e: convertI32PairToI53Checked(lo=1466733838 hi=-31198412)=nan
108+
input=-228467469520603516 / 0xfcd4520c047df684: convertI32PairToI53Checked(lo=75363972 hi=-53194228)=nan
109+
input=-273666790607730256 / 0xfc33bd80ff0149b0: convertI32PairToI53Checked(lo=-16692816 hi=-63718016)=nan
110+
input=-1191557145388856828 / 0xef76bd16e384ca04: convertI32PairToI53Checked(lo=-477836796 hi=-277431018)=nan
111+
input=-1298332612384647073 / 0xedfb655e2e82185f: convertI32PairToI53Checked(lo=780277855 hi=-302291618)=nan
112+
input=-1989398812941491341 / 0xe4643c51e609e373: convertI32PairToI53Checked(lo=-435559565 hi=-463193007)=nan
113+
input=-3377237107138057879 / 0xd121a4be92c4a969: convertI32PairToI53Checked(lo=-1832605335 hi=-786324290)=nan
114+
input=-5387531583823159334 / 0xb53ba491a205dfda: convertI32PairToI53Checked(lo=-1576673318 hi=-1254382447)=nan
115+
input=-7668821978737496343 / 0x9592df0a9fa4aee9: convertI32PairToI53Checked(lo=-1616597271 hi=-1785536758)=nan
116+
input=-8059210294467506632 / 0x9027eeefcc17ce38: convertI32PairToI53Checked(lo=-870855112 hi=-1876431121)=nan
117+
input=-8639913759366442907 / 0x8818dc364af41065: convertI32PairToI53Checked(lo=1257508965 hi=-2011636682)=nan
118+
119+
Testing otherDoubles:
120+
Double: 0.000000 -> input=1 / 0x1: convertI32PairToI53Checked(lo=1 hi=0)=1.000000
121+
Double: 0.000000 -> input=4503599627370496 / 0x10000000000000: convertI32PairToI53Checked(lo=0 hi=1048576)=4503599627370496.000000
122+
Double: 0.000000 -> input=4372995238176751616 / 0x3cb0000000000000: convertI32PairToI53Checked(lo=0 hi=1018167296)=nan
123+
Double: 0.100000 -> input=4591870180066957722 / 0x3fb999999999999a: convertI32PairToI53Checked(lo=-1717986918 hi=1069128089)=nan
124+
Double: 0.250000 -> input=4598175219545276416 / 0x3fd0000000000000: convertI32PairToI53Checked(lo=0 hi=1070596096)=nan
125+
Double: 0.500000 -> input=4602678819172646912 / 0x3fe0000000000000: convertI32PairToI53Checked(lo=0 hi=1071644672)=nan
126+
Double: 0.750000 -> input=4604930618986332160 / 0x3fe8000000000000: convertI32PairToI53Checked(lo=0 hi=1072168960)=nan
127+
Double: 1.912607 -> input=4611292433669438292 / 0x3ffe9a0968503b54: convertI32PairToI53Checked(lo=1750088532 hi=1073650185)=nan
128+
Double: 2.746370 -> input=4613366693597869068 / 0x4005f890ae84f40c: convertI32PairToI53Checked(lo=-1367018484 hi=1074133136)=nan
129+
Double: 150655528000.361053 -> input=4774248685726871095 / 0x424189e276202e37: convertI32PairToI53Checked(lo=1981820471 hi=1111591394)=nan
130+
Double: 679247267523850.500000 -> input=4828789179053992020 / 0x43034e2ca0c36854: convertI32PairToI53Checked(lo=-1597806508 hi=1124290092)=nan
131+
Double: 967873430891084.250000 -> input=4831098188360929890 / 0x430b8234c0495262: convertI32PairToI53Checked(lo=-1068936606 hi=1124827700)=nan
132+
Double: 1913278962515964.500000 -> input=4835511916391235570 / 0x431b3077e3aafff2: convertI32PairToI53Checked(lo=-475332622 hi=1125855351)=nan
133+
Double: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 -> input=9218868437227405311 / 0x7fefffffffffffff: convertI32PairToI53Checked(lo=-1 hi=2146435071)=nan
134+
Double: inf -> input=9218868437227405312 / 0x7ff0000000000000: convertI32PairToI53Checked(lo=0 hi=2146435072)=nan
135+
Double: -0.000000 -> input=-9223372036854775807 / 0x8000000000000001: convertI32PairToI53Checked(lo=1 hi=-2147483648)=nan
136+
Double: -0.000000 -> input=-9218868437227405312 / 0x8010000000000000: convertI32PairToI53Checked(lo=0 hi=-2146435072)=nan
137+
Double: -0.000000 -> input=-4850376798678024192 / 0xbcb0000000000000: convertI32PairToI53Checked(lo=0 hi=-1129316352)=nan
138+
Double: -0.100000 -> input=-4631501856787818086 / 0xbfb999999999999a: convertI32PairToI53Checked(lo=-1717986918 hi=-1078355559)=nan
139+
Double: -0.250000 -> input=-4625196817309499392 / 0xbfd0000000000000: convertI32PairToI53Checked(lo=0 hi=-1076887552)=nan
140+
Double: -0.500000 -> input=-4620693217682128896 / 0xbfe0000000000000: convertI32PairToI53Checked(lo=0 hi=-1075838976)=nan
141+
Double: -0.750000 -> input=-4618441417868443648 / 0xbfe8000000000000: convertI32PairToI53Checked(lo=0 hi=-1075314688)=nan
142+
Double: -1.912607 -> input=-4612079603185337516 / 0xbffe9a0968503b54: convertI32PairToI53Checked(lo=1750088532 hi=-1073833463)=nan
143+
Double: -2.746370 -> input=-4610005343256906740 / 0xc005f890ae84f40c: convertI32PairToI53Checked(lo=-1367018484 hi=-1073350512)=nan
144+
Double: -150655528000.361053 -> input=-4449123351127904713 / 0xc24189e276202e37: convertI32PairToI53Checked(lo=1981820471 hi=-1035892254)=nan
145+
Double: -679247267523850.500000 -> input=-4394582857800783788 / 0xc3034e2ca0c36854: convertI32PairToI53Checked(lo=-1597806508 hi=-1023193556)=nan
146+
Double: -967873430891084.250000 -> input=-4392273848493845918 / 0xc30b8234c0495262: convertI32PairToI53Checked(lo=-1068936606 hi=-1022655948)=nan
147+
Double: -1913278962515964.500000 -> input=-4387860120463540238 / 0xc31b3077e3aafff2: convertI32PairToI53Checked(lo=-475332622 hi=-1021628297)=nan
148+
Double: -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 -> input=-4503599627370497 / 0xffefffffffffffff: convertI32PairToI53Checked(lo=-1 hi=-1048577)=-4503599627370497.000000
149+
Double: -inf -> input=-4503599627370496 / 0xfff0000000000000: convertI32PairToI53Checked(lo=0 hi=-1048576)=-4503599627370496.000000
150+
All done!

tests/test_core.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from tools.shared import try_delete, PIPE
2323
from tools.shared import PYTHON, EMCC, EMAR
24-
from tools.utils import WINDOWS, MACOS
24+
from tools.utils import WINDOWS, MACOS, write_file
2525
from tools import shared, building, config, webassembly
2626
import common
2727
from common import RunnerCore, path_from_root, requires_native_clang, test_file, create_file
@@ -447,10 +447,19 @@ def test_int53(self):
447447
if common.EMTEST_REBASELINE:
448448
self.run_process([EMCC, test_file('core/test_int53.c'), '-o', 'a.js', '-DGENERATE_ANSWERS'] + self.emcc_args)
449449
ret = self.run_process(config.NODE_JS + ['a.js'], stdout=PIPE).stdout
450-
open(test_file('core/test_int53.out'), 'w').write(ret)
450+
write_file(test_file('core/test_int53.out'), ret)
451451
else:
452452
self.do_core_test('test_int53.c', interleaved_output=False)
453453

454+
def test_int53_convertI32PairToI53Checked(self):
455+
self.emcc_args += ['-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[$convertI32PairToI53Checked]']
456+
if common.EMTEST_REBASELINE:
457+
self.run_process([EMCC, test_file('core/test_convertI32PairToI53Checked.cpp'), '-o', 'a.js', '-DGENERATE_ANSWERS'] + self.emcc_args)
458+
ret = self.run_process(config.NODE_JS + ['a.js'], stdout=PIPE).stdout
459+
write_file(test_file('core/test_convertI32PairToI53Checked.out'), ret)
460+
else:
461+
self.do_core_test('test_convertI32PairToI53Checked.cpp', interleaved_output=False)
462+
454463
def test_i64(self):
455464
self.do_core_test('test_i64.c')
456465

0 commit comments

Comments
 (0)