Skip to content

Commit c861942

Browse files
committed
More tests for scanf
1 parent 3ff1235 commit c861942

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

jscomp/test/format_test.ml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ let aux_list loc ls =
9292
eq loc (sl a ) b
9393
) ls
9494
#if OCAML_VERSION =~ ">4.03.0" then
95-
let () =
96-
aux_list __LOC__ [
95+
96+
let literals =
97+
[
9798
0x3.fp+1, "0x1.f8p+2" (* (1. +. 0xf8p0 /. 0x1_00p0) *. 4.*);
9899
0.3, "0x1.3333333333333p-2";
99100
infinity, "infinity";
@@ -105,10 +106,23 @@ let () =
105106
0.9, "0x1.ccccccccccccdp-1";
106107
]
107108

109+
let () =
110+
aux_list __LOC__ literals
111+
108112
let () =
109113
eq __LOC__ (Printf.sprintf "%H" 0x3.fp+1) "0X1.F8P+2"
114+
let scan_float loc s expect =
115+
Scanf.sscanf s "%h" (fun result -> eq loc result expect)
116+
117+
let () =
118+
scan_float __LOC__ "0x3f.p1" 0x3f.p1;
119+
scan_float __LOC__ "0x1.3333333333333p-2" 0.3;
120+
List.iter (fun (a,b) ->
121+
scan_float __LOC__ b a
122+
) literals
110123
#end
111124

125+
112126
#if
113127
(* OCAML_VERSION =~ ">4.03.0" *) 0
114128
then

0 commit comments

Comments
 (0)