diff options
author | fab <fabrice.leal.ch@gmail.com> | 2018-12-11 22:16:37 +0000 |
---|---|---|
committer | fab <fabrice.leal.ch@gmail.com> | 2018-12-11 22:16:37 +0000 |
commit | e452bb052b6c1afbaaa72efb653ea31561333866 (patch) | |
tree | 0e6a91e91dd84a6387614c974bc17a58d88c47ba /tests/utf8.ur | |
parent | 1ce628ae2ab01799b6f601f0677ea396d1ac1577 (diff) |
exhaustive testing brought to selenium. bug fix in isspace. useful function to test if char is <128
Diffstat (limited to 'tests/utf8.ur')
-rw-r--r-- | tests/utf8.ur | 217 |
1 files changed, 217 insertions, 0 deletions
diff --git a/tests/utf8.ur b/tests/utf8.ur index c7aefd79..777bb141 100644 --- a/tests/utf8.ur +++ b/tests/utf8.ur @@ -1,4 +1,13 @@ +fun from_m_upto_n f m n = + if m < n then + <xml> + { f m } + { from_m_upto_n f (m + 1) n } + </xml> + else + <xml></xml> + fun test_fn_both_sides [a ::: Type] (_ : eq a) (_ : show a) (f : unit -> a) (expected : a) (testname : string) : xbody = <xml> <p>Server side test: {[testname]}</p> @@ -31,6 +40,38 @@ fun test_fn_cside [a ::: Type] (_ : eq a) (_ : show a) (f : unit -> a) (expected </active> </xml> + +fun test_fn_cside_ch (f : unit -> char) (expected : char) (testname : string) : xbody = + <xml> + <active code={let + val computed = f () + val msgErr = "Expected (S) " ^ (show expected) ^ " [" ^ (show (ord expected)) ^ "] but is (C) " ^ + (show computed) ^ "[" ^ (show (ord computed)) ^ "]." + in + if computed = expected then + return <xml></xml> + else + return <xml><p>ERROR {[testname]}: {[msgErr]}</p></xml> + end}> + </active> + </xml> + +fun test_fn_cside_b (f : unit -> bool) (expected : bool) (testname : string) : xbody = + <xml> + <active code={let + val computed = f () + val msgErr = "Expected (S) " ^ (show expected) ^ " but is (C) " ^ + (show computed) ^ "." + in + if computed = expected then + return <xml></xml> + else + return <xml><p>ERROR {[testname]}: {[msgErr]}</p></xml> + end}> + </active> +</xml> + + fun highencode () : transaction page = return <xml> <body> @@ -553,6 +594,182 @@ fun test_db () : transaction page = </xml> end +and ftTolower (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_ch (fn _ => tolower (chr n)) (tolower (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftToupper (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_ch (fn _ => toupper (chr n)) (toupper (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsalpha (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isalpha (chr n)) (isalpha (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsdigit (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isdigit (chr n)) (isdigit (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsalnum (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isalnum (chr n)) (isalnum (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsspace (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isspace (chr n)) (isspace (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsblank (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isblank (chr n)) (isblank (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsprint (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isprint (chr n)) (isprint (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsxdigit (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isxdigit (chr n)) (isxdigit (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIsupper (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => isupper (chr n)) (isupper (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + +and ftIslower (minCh : int) (maxCh : int) : transaction page = + let + fun test_chr (n : int) : xbody = + if iscodepoint n then + test_fn_cside_b (fn _ => islower (chr n)) (islower (chr n)) + ("test chr " ^ (show n) ^ " : " ^ (show (chr n))) + else + <xml></xml> + in + return <xml> + <body> + { from_m_upto_n (fn n => test_chr n) minCh maxCh } + </body> + </xml> + end + fun index () : transaction page = return <xml> <body> |