From e740f9ff639e9e9951879be93bf19180aef5e872 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 19 Apr 2014 01:27:34 +0200 Subject: [PATCH] quick tests --- tests/quick/.common.ml | 15 +++++++++++++++ tests/quick/all.sh | 6 ++++++ tests/quick/levenshtein_dict.ml | 18 ++++++++++++++++++ tests/quick/ratTerm.ml | 17 +++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 tests/quick/.common.ml create mode 100755 tests/quick/all.sh create mode 100755 tests/quick/levenshtein_dict.ml create mode 100755 tests/quick/ratTerm.ml diff --git a/tests/quick/.common.ml b/tests/quick/.common.ml new file mode 100644 index 00000000..1bb57abf --- /dev/null +++ b/tests/quick/.common.ml @@ -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 +*) diff --git a/tests/quick/all.sh b/tests/quick/all.sh new file mode 100755 index 00000000..80591a99 --- /dev/null +++ b/tests/quick/all.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +for i in tests/quick/*.ml ; do + echo -n "${i}..." + $i +done diff --git a/tests/quick/levenshtein_dict.ml b/tests/quick/levenshtein_dict.ml new file mode 100755 index 00000000..6a785351 --- /dev/null +++ b/tests/quick/levenshtein_dict.ml @@ -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;; diff --git a/tests/quick/ratTerm.ml b/tests/quick/ratTerm.ml new file mode 100755 index 00000000..2eb9d93f --- /dev/null +++ b/tests/quick/ratTerm.ml @@ -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();;