diff options
Diffstat (limited to 'ocamlbuild/test/test9')
-rw-r--r-- | ocamlbuild/test/test9/dbgl | 10 | ||||
-rwxr-xr-x | ocamlbuild/test/test9/test.sh | 6 | ||||
-rw-r--r-- | ocamlbuild/test/test9/testglob.ml | 91 |
3 files changed, 107 insertions, 0 deletions
diff --git a/ocamlbuild/test/test9/dbgl b/ocamlbuild/test/test9/dbgl new file mode 100644 index 000000000..ac61a3d55 --- /dev/null +++ b/ocamlbuild/test/test9/dbgl @@ -0,0 +1,10 @@ +#load "unix.cma";; +#load "str.cma";; +#load "discard_printf.cmo";; +#load "debug.cmo";; +#load "bool.cmo";; +#load "glob_ast.cmo";; +#load "glob_lexer.cmo";; +#load "my_unix.cmo";; +#use "glob.ml";; +#install_printer print_is;; diff --git a/ocamlbuild/test/test9/test.sh b/ocamlbuild/test/test9/test.sh new file mode 100755 index 000000000..0feded208 --- /dev/null +++ b/ocamlbuild/test/test9/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +set -x +cd `dirname $0`/../.. +./_build/ocamlbuild.native -quiet -build-dir _buildtest -no-links test/test9/testglob.native $@ +./_buildtest/test/test9/testglob.native diff --git a/ocamlbuild/test/test9/testglob.ml b/ocamlbuild/test/test9/testglob.ml new file mode 100644 index 000000000..e307a769c --- /dev/null +++ b/ocamlbuild/test/test9/testglob.ml @@ -0,0 +1,91 @@ +(* Testglob *) + +open Bool;; +open Glob;; + +let yep f x = + try + ignore (f x); + true + with + | _ -> false +;; + +let tests1 = [ + "\"hello\"", true; + "<hello>", true; + "<hel*lo>", true; + "<a> and <b> or <c>", true; + "<a> titi", false +];; + +let tests2 = [ + "<[a]>", ["a"], ["b"]; + "<[a-z]>", ["a";"e";"k";"z"], ["0";"A";"~"]; + "<[a-z][0-9]>", ["a0";"b9"], ["a00";"a0a";"b0a";"isduis";""]; + "<hello>", ["hello"], ["helli"]; + "\"hello\"", ["hello"], ["heidi"]; + "<*>", ["";"a";"ax"], []; + "<a*b>", ["ab";"acb";"axxxxxb";"ababbababb"], ["abx";"xxxxxab";"xab"]; + "<*.ml>", ["hello.ml";".ml"], ["ml"; ""; "toto.mli"]; + "<a>", ["a"], ["";"aa";"ba";"ab";"abaa"]; + "<ab>", ["ab"], ["";"abab";"aba";"abx"]; + "<ab?c>", ["abac";"abxc"], ["abab";"ababab";"ababa"]; + "<*ab?cd*>", ["123abecd345";"abccd";"abccd345";"ababcababccdab"], ["abcd";"aaaaabcdababcd"]; + "<*this*is*a*test*>", ["this is a test";"You know this is a test really";"thisisatest"], ["thisatest"]; + "<b*>", ["bxx";"bx"], ["aaab";""]; + "<*>", ["";"a";"aaa";"aaaaa"], []; + "<?>", ["a"],["";"aaa";"aaaaa"]; + "<{a,b}>", ["a";"b"],["";"aa";"ab";"ba";"bb";"c"]; + "<toto.{ml,mli}>", ["toto.ml";"toto.mli"],["toto.";"toto.mll"]; + "<{a,b}{c,[de]}{f,g}>", ["acf";"acg";"adf";"adg";"aef";"aeg";"bcf";"bcg";"bdf";"bdg";"bef";"beg"], + ["afg";"af";"aee"]; + "(<*.ml> or <*.mli>) and not \"hello.ml\"", + ["a.ml"; "b.ml"; "a.mli"], + ["hello.ml"; "a.mli.x"]; + "<*>", ["alpha";"beta"], ["alpha/beta";"gamma/delta"]; + "<alpha/**/beta>", ["alpha/beta";"alpha/gamma/beta";"alpha/gamma/delta/beta"], + ["alpha";"beta";"gamma/delta"]; + "<**/*.ml>", ["toto.ml";"toto/tata.ml";"alpha/gamma/delta/beta.ml"], + ["toto.mli"]; + "<toto/**>", ["toto/";"toto/tata";"toto/alpha/gamma/delta/beta.ml";"toto"], + ["toto2/tata"; "tata/titi"] +];; + + +let _ = + let times = 3 in + List.iter + begin fun (str, ast) -> + let ast' = yep Glob.parse str in + if ast <> ast' then + begin + Printf.printf "Globexp parsing failed for %S.\n%!" str; + exit 1 + end + else + Printf.printf "Globexp for %S OK\n%!" str + end + tests1; + List.iter + begin fun (gstr, yes, no) -> + let globber = Glob.parse gstr in + let check polarity = + List.iter + begin fun y -> + if Glob.eval globber y = polarity then + Printf.printf "Glob.eval %S %S = %b OK\n%!" gstr y polarity + else + begin + Printf.printf "Glob.eval %S %S = %b FAIL\n%!" gstr y (not polarity); + exit 1 + end + end + in + for k = 1 to times do + check true yes; + check false no + done + end + tests2 +;; |