quick tests

This commit is contained in:
Simon Cruanes 2014-04-19 01:27:34 +02:00
parent 097106d259
commit e740f9ff63
4 changed files with 56 additions and 0 deletions

15
tests/quick/.common.ml Normal file
View file

@ -0,0 +1,15 @@
#use "topfind";;
#directory "_build/";;
#require "unix";;
let ok () =
print_endline "... OK";
exit 0;;
let fail msg =
print_endline ("... FAILURE " ^ msg);
exit 1;;
(* vim:syntax=ocaml
*)

6
tests/quick/all.sh Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
for i in tests/quick/*.ml ; do
echo -n "${i}..."
$i
done

18
tests/quick/levenshtein_dict.ml Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env ocaml
#use "tests/quick/.common.ml";;
#load "containers.cma";;
open Containers;;
#require "batteries";;
open Batteries;;
let words = File.with_file_in "/usr/share/dict/cracklib-small"
(fun i -> IO.read_all i |> String.nsplit ~by:"\\n");;
let idx = List.fold_left
(fun idx s -> Levenshtein.StrIndex.add_string idx s s)
Levenshtein.StrIndex.empty words;;
Levenshtein.StrIndex.retrieve_string ~limit:1 idx "hell"
|> Levenshtein.klist_to_list
|> List.iter print_endline;;

17
tests/quick/ratTerm.ml Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env ocaml
#use "tests/quick/.common.ml";;
#load "containers.cma";;
open Containers;;
module T = RatTerm.Default;;
#install_printer T.fmt;;
#install_printer T.Subst.fmt;;
let t = T.(app "f" [const "a"; app "f" [mk_ref 1; const "b"]]);;
let t2 = T.(app "f" [var (); app "f" [mk_ref 1; var ()]]);;
let t3 = T.(app "f" [var (); app "f" [var (); const "b"]]);;
let subst2 = match T.unify t t3 with Some s -> s | None -> assert false;;
let t3' = T.Subst.apply subst2 t3;;
T.eq_set t t3';;
ok();;