Skip to content

Commit b51f8f2

Browse files
committed
Fix int64 test spec
1 parent 6599248 commit b51f8f2

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

jscomp/stdlib-406/release.ninja

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ build stdlib-406/gc.cmj : cc_cmi stdlib-406/gc.ml | stdlib-406/gc.cmi stdlib-406
6262
build stdlib-406/gc.cmi : cc stdlib-406/gc.mli | stdlib-406/pervasives.cmj others
6363
build stdlib-406/genlex.cmj : cc_cmi stdlib-406/genlex.ml | stdlib-406/bytes.cmj stdlib-406/char.cmj stdlib-406/genlex.cmi stdlib-406/hashtbl.cmj stdlib-406/list.cmj stdlib-406/stream.cmj stdlib-406/string.cmj others
6464
build stdlib-406/genlex.cmi : cc stdlib-406/genlex.mli | stdlib-406/pervasives.cmj stdlib-406/stream.cmi others
65-
build stdlib-406/hashtbl.cmj : cc_cmi stdlib-406/hashtbl.ml | stdlib-406/array.cmj stdlib-406/hashtbl.cmi stdlib-406/lazy.cmj stdlib-406/obj.cmj stdlib-406/random.cmj stdlib-406/string.cmj stdlib-406/sys.cmj others
65+
build stdlib-406/hashtbl.cmj : cc_cmi stdlib-406/hashtbl.ml | stdlib-406/array.cmj stdlib-406/hashtbl.cmi stdlib-406/lazy.cmj stdlib-406/random.cmj stdlib-406/string.cmj stdlib-406/sys.cmj others
6666
build stdlib-406/hashtbl.cmi : cc stdlib-406/hashtbl.mli | stdlib-406/pervasives.cmj others
6767
build stdlib-406/int32.cmj : cc_cmi stdlib-406/int32.ml | stdlib-406/int32.cmi stdlib-406/pervasives.cmj others
6868
build stdlib-406/int32.cmi : cc stdlib-406/int32.mli | stdlib-406/pervasives.cmj others

jscomp/test/int64_test.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -2354,39 +2354,50 @@ function eq(loc, x, y) {
23542354
}
23552355

23562356
function id(loc, x) {
2357-
return eq(loc, Caml_int64.bits_of_float(Caml_int64.float_of_bits(x)), x);
2357+
var float_value = Caml_int64.float_of_bits(x);
2358+
var match = Pervasives.classify_float(float_value);
2359+
if (match >= 4) {
2360+
return /* () */0;
2361+
} else {
2362+
return eq(loc, Caml_int64.bits_of_float(float_value), x);
2363+
}
23582364
}
23592365

2360-
eq("File \"int64_test.ml\", line 176, characters 5-12", Caml_int64.bits_of_float(0.3), /* int64 */[
2366+
eq("File \"int64_test.ml\", line 181, characters 5-12", Caml_int64.bits_of_float(0.3), /* int64 */[
23612367
/* hi */1070805811,
23622368
/* lo */858993459
23632369
]);
23642370

2365-
eq("File \"int64_test.ml\", line 177, characters 5-12", Caml_int64.float_of_bits(/* int64 */[
2371+
eq("File \"int64_test.ml\", line 182, characters 5-12", Caml_int64.float_of_bits(/* int64 */[
23662372
/* hi */1070805811,
23672373
/* lo */858993459
23682374
]), 0.3);
23692375

2370-
id("File \"int64_test.ml\", line 178, characters 5-12", /* int64 */[
2376+
id("File \"int64_test.ml\", line 183, characters 5-12", /* int64 */[
23712377
/* hi */-1,
23722378
/* lo */4294967295
23732379
]);
23742380

2375-
id("File \"int64_test.ml\", line 179, characters 5-12", /* int64 */[
2381+
id("File \"int64_test.ml\", line 184, characters 5-12", /* int64 */[
23762382
/* hi */-1,
23772383
/* lo */4294967196
23782384
]);
23792385

2380-
id("File \"int64_test.ml\", line 180, characters 5-12", /* int64 */[
2386+
id("File \"int64_test.ml\", line 185, characters 5-12", /* int64 */[
23812387
/* hi */0,
23822388
/* lo */4294967295
23832389
]);
23842390

2385-
id("File \"int64_test.ml\", line 181, characters 5-12", /* int64 */[
2391+
id("File \"int64_test.ml\", line 186, characters 5-12", /* int64 */[
23862392
/* hi */0,
23872393
/* lo */536870911
23882394
]);
23892395

2396+
id("File \"int64_test.ml\", line 187, characters 5-12", /* int64 */[
2397+
/* hi */0,
2398+
/* lo */536870655
2399+
]);
2400+
23902401
Mt.from_pair_suites("Int64_test", suites$1[0]);
23912402

23922403
exports.f = f;

jscomp/test/int64_test.ml

+8-2
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,19 @@ let test_id = ref 0
171171
let eq loc x y = Mt.eq_suites ~test_id ~suites loc x y
172172

173173
let id loc (x : int64) =
174-
eq loc (Int64.bits_of_float (Int64.float_of_bits x)) x
174+
(* This is not a round trip, since NaN is not distinguishable in JS*)
175+
let float_value = (Int64.float_of_bits x) in
176+
match classify_float float_value with
177+
| FP_nan -> ()
178+
| _ ->
179+
eq loc (Int64.bits_of_float float_value) x
175180
let () =
176181
eq __LOC__ (Int64.bits_of_float 0.3) 4599075939470750515L;
177182
eq __LOC__ (Int64.float_of_bits 4599075939470750515L) 0.3;
178183
id __LOC__ (-1L);
179184
id __LOC__ (-100L);
180185
id __LOC__ 0xff_ff_ff_ffL;
181-
id __LOC__ 0x1f_ff_ff_ffL
186+
id __LOC__ 0x1f_ff_ff_ffL;
187+
id __LOC__ 0x1f_ff_fe_ffL
182188

183189
;; Mt.from_pair_suites __MODULE__ !suites

scripts/prebuilt.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env node
12
//@ts-check
23
var cp = require("child_process");
34
var path = require("path");

0 commit comments

Comments
 (0)