From 7165ff3ae62930d735894b8f3a55e910082800cf Mon Sep 17 00:00:00 2001 From: fab Date: Fri, 23 Nov 2018 20:42:55 +0000 Subject: test client eval vs server eval --- tests/utf8.ur | 78 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/utf8.ur b/tests/utf8.ur index 468c776d..07ac9c3d 100644 --- a/tests/utf8.ur +++ b/tests/utf8.ur @@ -19,6 +19,18 @@ fun test_fn_sside [a ::: Type] (_ : eq a) (_ : show a) (f : unit -> a) (expected
{[assert (f () = expected) "False" testname "True" ]}
+fun test_fn_cside [a ::: Type] (_ : eq a) (_ : show a) (f : unit -> a) (expected : a) (testname : string) : xbody = + +

Client side test: {[testname]}

{[r]}
+ end}> + + + fun substrings () : transaction page = return @@ -359,27 +371,40 @@ fun isxdigits () : transaction page = fun tolowers () : transaction page = - return - - {test_fn_both_sides (fn _ => tolower #"A") #"a" "tolower 1"} - {test_fn_both_sides (fn _ => tolower #"a") #"a" "tolower 2"} - {test_fn_both_sides (fn _ => tolower (strsub "á" 0)) (strsub "á" 0) "tolower 3"} - {test_fn_both_sides (fn _ => tolower (strsub "Á" 0)) (strsub "á" 0) "tolower 4"} - {test_fn_both_sides (fn _ => tolower #"1") #"1" "tolower 5"} - - + let + fun lower_of a _ = + tolower a + in + return + + {test_fn_both_sides (lower_of #"A") #"a" "tolower 1"} + {test_fn_both_sides (lower_of #"a") #"a" "tolower 2"} + {test_fn_both_sides (lower_of (strsub "á" 0)) (strsub "á" 0) "tolower 3"} + {test_fn_both_sides (lower_of (strsub "Á" 0)) (strsub "á" 0) "tolower 4"} + {test_fn_both_sides (lower_of #"1") #"1" "tolower 5"} + {test_fn_cside (lower_of (strsub "ß" 0)) (lower_of (strsub "ß" 0) ()) "tolower 6"} + + + end fun touppers () : transaction page = - return - - {test_fn_both_sides (fn _ => toupper #"A") #"A" "toupper 1"} - {test_fn_both_sides (fn _ => toupper #"a") #"A" "toupper 2"} - {test_fn_both_sides (fn _ => toupper (strsub "á" 0)) (strsub "Á" 0) "toupper 3"} - {test_fn_both_sides (fn _ => toupper (strsub "Á" 0)) (strsub "Á" 0) "toupper 4"} - {test_fn_both_sides (fn _ => toupper #"1") #"1" "toupper 5"} - - - + let + fun upper_of a _ = + toupper a + in + return + + {test_fn_both_sides (upper_of #"A") #"A" "toupper 1"} + {test_fn_both_sides (upper_of #"a") #"A" "toupper 2"} + {test_fn_both_sides (upper_of (strsub "á" 0)) (strsub "Á" 0) "toupper 3"} + {test_fn_both_sides (upper_of (strsub "Á" 0)) (strsub "Á" 0) "toupper 4"} + {test_fn_both_sides (upper_of #"1") #"1" "toupper 5"} + + {test_fn_cside (upper_of (strsub "ß" 0)) (upper_of (strsub "ß" 0) ()) "toupper 6"} + + + end + fun ord_and_chrs () : transaction page = return @@ -393,7 +418,19 @@ fun ord_and_chrs () : transaction page = {test_fn_both_sides (fn _ => chr (ord (strsub "漢" 0))) (strsub "漢" 0) "ord => chr 8"} {test_fn_both_sides (fn _ => chr (ord (strsub "カ" 0))) (strsub "カ" 0) "ord => chr 9"} - + + +fun test_ords () : transaction page = + let + fun ord_of c _ = + ord c + in + return + + {test_fn_cside (ord_of (strsub "a" 0)) (ord_of (strsub "a" 0) ()) "test ord 1"} + + + end table t : { Id : int, Text : string } @@ -469,6 +506,7 @@ fun index () : transaction page = tolowers touppers ord_and_chrs + test ord test_db -- cgit v1.2.3