package commons
Yet another set of common utilities
Install
Dune Dependency
Authors
Maintainers
Sources
commons_1.8.0.tar.gz
md5=00142d2d5f299c86ee44f19820bf9874
sha512=d25a57c434514ecb9adc5a129eeec9feca1cea2d1383e3bde74b52a05da174a09e0f46e7407f7b86ecdf1bf6faf7e0a66ef744d6fb389cb5f8398bc32e349555
doc/src/commons.tests/Unit_FPath.ml.html
Source file Unit_FPath.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
(* TODO: copy paste of Unit_commons.with_file, but should be in Common.ml *) let with_file contents f = let file, oc = Filename.open_temp_file "test_pfff_read_file_" ".dat" in Fun.protect ~finally:(fun () -> close_out_noerr oc; Sys.remove file) (fun () -> output_string oc contents; close_out oc; f file) (* TODO: we should use Unix.realpath! but only available in 4.13 *) let realpath s = Common.fullpath s let test_path_conversion () = let check_path path = FPath.to_string (FPath.of_string path) = realpath path in let data = String.make 150 'v' in assert (check_path "."); assert (check_path ".."); assert (check_path "../.."); assert (FPath.to_string (FPath.of_string "/") = realpath "/"); with_file data (fun file -> let path = FPath.of_string file in let max_len = 24 in assert (FPath.to_string path = realpath file); assert (FPath.read_file path = data); assert (FPath.cat path = [ data ]); assert (FPath.read_file ~max_len path = Str.first_chars data max_len); assert (FPath.file_exists path); assert (not (FPath.is_directory path))); assert ( FPath.to_string FPath.(of_string "." / "." / ".." / "." / "..") = realpath "../..") let tests = Testutil.pack_tests "FPath" [ ("path_conversion", test_path_conversion) ]
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>