(* file_unittest.ml - Don Yang (uguu.org) 05/20/06 *) (* Check test input files *) let src_file = "file_unittest.ml";; let data_file = "file_unittest.cmx";; let tmp_file = "file_unittest.tmp";; if not (Sys.file_exists src_file) then failwith (src_file ^ " not found");; if not (Sys.file_exists data_file) then failwith (data_file ^ " not found");; if Sys.file_exists tmp_file then failwith ("Need to delete " ^ tmp_file ^ " before running test");; (* File.compare: Comparing the same file, expect "false" *) if File.compare data_file data_file then failwith "File.compare(data, data)";; (* File.compare: Compare against nonexistent files, expect "true" *) if not (File.compare data_file tmp_file) then failwith "File.compare(data, nonexist)";; if not (File.compare tmp_file data_file) then failwith "File.compare(nonexist, data)";; (* File.compare: Compare two nonexistent files, expect "true" *) if not (File.compare tmp_file tmp_file) then failwith "File.compare(nonexist, nonexist)";; (* File.compare: Compare two different files, expect "true" *) if not (File.compare data_file src_file) then failwith "File.compare(data1, data2)";; if not (File.compare src_file data_file) then failwith "File.compare(data2, data1)";; (* File.copy, File.compare: Copy file and compare, expect "false" *) File.copy data_file tmp_file;; if File.compare data_file tmp_file then failwith "File.compare(data, copy)";; if File.compare tmp_file data_file then failwith "File.compare(copy, data)";; if File.compare tmp_file tmp_file then failwith "File.compare(copy, copy)";; (* Cleanup *) Sys.remove tmp_file;; print_string "PASS\n";;