@@ -177,10 +177,38 @@ let%expect_test "log2" =
177177 p 1024.0 ;
178178 [% expect {| 10.000000 | }]
179179
180+ let print' f = try print (f () ) with e -> print_endline (Printexc. to_string e)
181+
180182let % expect_test " of_string" =
181183 let x = " 0x1.1" in
182- print ( float_of_string x);
184+ print' ( fun () -> float_of_string x);
183185 [% expect {| 1.062500 | }];
184186 let x = " 0x1.1p-1" in
185- print (float_of_string x);
186- [% expect {| 0.531250 | }]
187+ print' (fun () -> float_of_string x);
188+ [% expect {| 0.531250 | }];
189+ let x = " 0x1.1" in
190+ print' (fun () -> float_of_string x);
191+ [% expect {| 1.062500 | }];
192+ let x = " 0x1.1 " in
193+ print' (fun () -> float_of_string x);
194+ [% expect {| Failure (" float_of_string" ) | }];
195+ let x = " 0x1.1 p-1" in
196+ print' (fun () -> float_of_string x);
197+ [% expect {| Failure (" float_of_string" ) | }]
198+
199+ let % expect_test " of_string" =
200+ let x = " 3.14" in
201+ print' (fun () -> float_of_string x);
202+ [% expect {| 3.140000 | }];
203+ let x = " 3.14" in
204+ print' (fun () -> float_of_string x);
205+ [% expect {| 3.140000 | }];
206+ let x = " 3. 14" in
207+ print' (fun () -> float_of_string x);
208+ [% expect {| Failure (" float_of_string" ) | }];
209+ let x = " 3.1 4" in
210+ print' (fun () -> float_of_string x);
211+ [% expect {| Failure (" float_of_string" ) | }];
212+ let x = " 3.14 " in
213+ print' (fun () -> float_of_string x);
214+ [% expect {| Failure (" float_of_string" ) | }]
0 commit comments