diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 2 | ||||
-rw-r--r-- | tests/utf8.py | 174 | ||||
-rw-r--r-- | tests/utf8.ur | 794 | ||||
-rw-r--r-- | tests/utf8.urp | 6 |
4 files changed, 976 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile index ecf5557b..03e37e4b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -28,3 +28,5 @@ simple:: ./driver.sh fact ./driver.sh filter ./driver.sh jsbspace + ./driver.sh utf8 + diff --git a/tests/utf8.py b/tests/utf8.py new file mode 100644 index 00000000..6036fa12 --- /dev/null +++ b/tests/utf8.py @@ -0,0 +1,174 @@ +import unittest +import base + +class Suite(base.Base): + + def no_falses(self, name): + self.start('Utf8/' + name) + + elems = self.driver.find_elements_by_xpath('//pre') + + self.assertNotEqual(0, len(elems)) + for e in elems: + self.assertEqual("True", e.text) + + def test_1(self): + """Test case: substring (1)""" + self.no_falses('substrings') + + def test_2(self): + """Test case: strlen (2)""" + self.no_falses('strlens') + + def test_3(self): + """Test case: strlenGe (3)""" + self.no_falses('strlenGens') + + def test_4(self): + """Test case: strcat (4)""" + self.no_falses('strcats') + + def test_5(self): + """Test case: strsub (5)""" + self.no_falses('strsubs') + + def test_6(self): + """Test case: strsuffix (6)""" + self.no_falses('strsuffixs') + + def test_7(self): + """Test case: strchr (7)""" + self.no_falses('strchrs') + + def test_8(self): + """Test case: strindex (8)""" + self.no_falses('strindexs') + + def test_9(self): + """Test case: strindex (9)""" + self.no_falses('strsindexs') + + def test_10(self): + """Test case: strcspn (10)""" + self.no_falses('strcspns') + + def test_11(self): + """Test case: str1 (11)""" + self.no_falses('str1s') + + def test_12(self): + """Test case: isalnum (12)""" + self.no_falses('isalnums') + + def test_13(self): + """Test case: isalpha (13)""" + self.no_falses('isalphas') + + def test_14(self): + """Test case: isblank (14)""" + self.no_falses('isblanks') + + def test_15(self): + """Test case: iscntrl (15)""" + self.no_falses('iscntrls') + + def test_16(self): + """Test case: isdigit (16)""" + self.no_falses('isdigits') + + def test_17(self): + """Test case: isgraph (17)""" + self.no_falses('isgraphs') + + def test_18(self): + """Test case: islower (18)""" + self.no_falses('islowers') + + def test_19(self): + """Test case: isprint (19)""" + self.no_falses('isprints') + + def test_20(self): + """Test case: ispunct (20)""" + self.no_falses('ispuncts') + + def test_21(self): + """Test case: isspace (21)""" + self.no_falses('isspaces') + + def test_22(self): + """Test case: isupper (22)""" + self.no_falses('isuppers') + + def test_23(self): + """Test case: isxdigit (23)""" + self.no_falses('isxdigits') + + def test_24(self): + """Test case: toupper (24)""" + self.no_falses('touppers') + + def test_25(self): + """Test case: ord (25)""" + self.no_falses('ord_and_chrs') + + def test_26 (self): + """Test case: test_db (26) """ + self.no_falses('test_db') + + def full_test (self, name): + + gap = 1000 + i = 0 + while (i + gap < 130000): + self.start('Utf8/' + name + '/' + str(i) + '/' + str(i + gap)) + errors = self.body_text() + self.assertEqual("", errors, errors) + i = i + gap + + + def test_89 (self): + """Test case: ftTolower """ + self.full_test("ftTolower") + + def test_90 (self): + """Test case: ftToupper """ + self.full_test("ftToupper") + + def test_91 (self): + """Test case: ftIsalpha """ + self.full_test("ftIsalpha") + + def test_92 (self): + """Test case: ftIsdigit """ + self.full_test("ftIsdigit") + + def test_93 (self): + """Test case: ftIsalnum """ + self.full_test("ftIsalnum") + + def test_94 (self): + """Test case: ftIsspace """ + self.full_test("ftIsspace") + + def test_95 (self): + """Test case: ftIsblank """ + self.full_test("ftIsblank") + + def test_96 (self): + """Test case: ftIsprint """ + self.full_test("ftIsprint") + + def test_97 (self): + """Test case: ftIsxdigit """ + self.full_test("ftIsxdigit") + + def test_98 (self): + """Test case: ftIsupper """ + self.full_test("ftIsupper") + + def test_99 (self): + """Test case: ftIslower """ + self.full_test("ftIslower") + ''' + ''' diff --git a/tests/utf8.ur b/tests/utf8.ur new file mode 100644 index 00000000..4a89c22b --- /dev/null +++ b/tests/utf8.ur @@ -0,0 +1,794 @@ + +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> + <pre>{[show (f () = expected)]}</pre> + <active code={return <xml><p>Client side test: {[testname]}</p><pre>{[show (f () = expected)]}</pre></xml>}> +</active> +</xml> + +fun test_fn_sside [a ::: Type] (_ : eq a) (_ : show a) (f : unit -> a) (expected : a) (testname : string) : xbody = + <xml> + <p>Server side test: {[testname]}</p> + <pre>{[show (f () = expected)]}</pre> + </xml> + +fun test_fn_cside [a ::: Type] (_ : eq a) (_ : show a) (f : unit -> a) (expected : a) (testname : string) : xbody = + <xml> + <active code={return <xml><p>Client side test: {[testname]}</p><pre>{[show (f () = expected)]}</pre></xml>}> + </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> + {test_fn_cside (fn _ => strlen "ππππ") (strlen "ππππ") "high encode - strlen 1"} + {test_fn_cside (fn _ => strlen "πππ") (strlen "πππ") "high encode - strlen 2"} + {test_fn_cside (fn _ => strlen "ππ") (strlen "ππ") "high encode - strlen 3"} + {test_fn_cside (fn _ => strlen "π") (strlen "π") "high encode - strlen 4"} + + {test_fn_cside (fn _ => substring "ππππ" 1 3) (substring "ππππ" 1 3) "high encode - substring 1"} + {test_fn_cside (fn _ => substring "ππππ" 2 2) (substring "ππππ" 2 2) "high encode - substring 2"} + {test_fn_cside (fn _ => substring "ππππ" 3 1) (substring "ππππ" 3 1) "high encode - substring 3"} + + {test_fn_cside (fn _ => strlen (substring "ππππ" 1 3)) (strlen (substring "ππππ" 1 3)) "high encode - strlen of substring 1"} + {test_fn_cside (fn _ => strlen (substring "ππππ" 2 2)) (strlen (substring "ππππ" 2 2)) "high encode - strlen of substring 2"} + {test_fn_cside (fn _ => strlen (substring "ππππ" 3 1)) (strlen (substring "ππππ" 3 1)) "high encode - strlen of substring 3"} + + {test_fn_cside (fn _ => strsub "ππππ" 0) (strsub "ππππ" 0) "high encode - strsub 1"} + {test_fn_cside (fn _ => strsub "ππππ" 1) (strsub "ππππ" 1) "high encode - strsub 2"} + {test_fn_cside (fn _ => strsub "ππππ" 2) (strsub "ππππ" 2) "high encode - strsub 3"} + {test_fn_cside (fn _ => strsub "ππππ" 3) (strsub "ππππ" 3) "high encode - strsub 4"} + + {test_fn_cside (fn _ => strsuffix "ππππ" 0) (strsuffix "ππππ" 0) "high encode - strsuffix 1"} + {test_fn_cside (fn _ => strsuffix "ππππ" 1) (strsuffix "ππππ" 1) "high encode - strsuffix 2"} + {test_fn_cside (fn _ => strsuffix "ππππ" 2) (strsuffix "ππππ" 2) "high encode - strsuffix 3"} + {test_fn_cside (fn _ => strsuffix "ππππ" 3) (strsuffix "ππππ" 3) "high encode - strsuffix 4"} + + {test_fn_cside (fn _ => strchr "ππππ" #"c") (strchr "ππππ" #"c") "high encode - strchr 1"} + {test_fn_cside (fn _ => strchr "ππππ" (strsub "π" 0)) (strchr "ππππ" (strsub "π" 0)) "high encode - strchr 2"} + {test_fn_cside (fn _ => strchr "ππππ" (strsub "π" 0)) (strchr "ππππ" (strsub "π" 0)) "high encode - strchr 3"} + {test_fn_cside (fn _ => strchr "ππππ" (strsub "π" 0)) (strchr "ππππ" (strsub "π" 0)) "high encode - strchr 4"} + {test_fn_cside (fn _ => strchr "ππππ" (strsub "π" 0)) (strchr "ππππ" (strsub "π" 0)) "high encode - strchr 5"} + + {test_fn_cside (fn _ => strindex "ππππ" #"c") (strindex "ππππ" #"c") "high encode - strindex 1"} + {test_fn_cside (fn _ => strindex "ππππ" (strsub "π" 0)) (strindex "ππππ" (strsub "π" 0)) "high encode - strindex 2"} + {test_fn_cside (fn _ => strindex "ππππ" (strsub "π" 0)) (strindex "ππππ" (strsub "π" 0)) "high encode - strindex 3"} + {test_fn_cside (fn _ => strindex "ππππ" (strsub "π" 0)) (strindex "ππππ" (strsub "π" 0)) "high encode - strindex 4"} + {test_fn_cside (fn _ => strindex "ππππ" (strsub "π" 0)) (strindex "ππππ" (strsub "π" 0)) "high encode - strindex 5"} + + {test_fn_cside (fn _ => strsindex "ππππ" "") (strsindex "ππππ" "") "high encode - strsindex 1"} + {test_fn_cside (fn _ => strsindex "ππππ" "ππππ") (strsindex "ππππ" "ππππ") "high encode - strsindex 2"} + {test_fn_cside (fn _ => strsindex "ππππ" "πππc") (strsindex "ππππ" "πππc") "high encode - strsindex 3"} + {test_fn_cside (fn _ => strsindex "ππππ" "πππ") (strsindex "ππππ" "πππ") "high encode - strsindex 4"} + {test_fn_cside (fn _ => strsindex "ππππ" "ππc") (strsindex "ππππ" "ππc") "high encode - strsindex 5"} + {test_fn_cside (fn _ => strsindex "ππππ" "ππ") (strsindex "ππππ" "ππ") "high encode - strsindex 6"} + {test_fn_cside (fn _ => strsindex "ππππ" "πc") (strsindex "ππππ" "πc") "high encode - strsindex 7"} + {test_fn_cside (fn _ => strsindex "ππππ" "π") (strsindex "ππππ" "π") "high encode - strsindex 8"} + {test_fn_cside (fn _ => strsindex "ππππ" "c") (strsindex "ππππ" "c") "high encode - strsindex 9"} + + {test_fn_cside (fn _ => strcspn "ππππ" "") (strcspn "ππππ" "") "high encode - strcspn 1"} + {test_fn_cside (fn _ => strcspn "ππππ" "ππππ") (strcspn "ππππ" "ππππ") "high encode - strcspn 2"} + {test_fn_cside (fn _ => strcspn "ππππ" "π") (strcspn "ππππ" "π") "high encode - strcspn 3"} + {test_fn_cside (fn _ => strcspn "ππππ" "πππ") (strcspn "ππππ" "πππ") "high encode - strcspn 4"} + {test_fn_cside (fn _ => strcspn "ππππ" "ππ") (strcspn "ππππ" "ππ") "high encode - strcspn 5"} + {test_fn_cside (fn _ => strcspn "ππππ" "π") (strcspn "ππππ" "π") "high encode - strcspn 6"} + + {test_fn_cside (fn _ => ord (strsub "ππππ" 0)) (ord (strsub "ππππ" 0)) "high encode - ord 1"} + {test_fn_cside (fn _ => ord (strsub "ππππ" 1)) (ord (strsub "ππππ" 1)) "high encode - ord 2"} + {test_fn_cside (fn _ => ord (strsub "ππππ" 2)) (ord (strsub "ππππ" 2)) "high encode - ord 3"} + {test_fn_cside (fn _ => ord (strsub "ππππ" 3)) (ord (strsub "ππππ" 3)) "high encode - ord 4"} + + {test_fn_cside (fn _ => show (strsub "ππππ" 0)) (show (strsub "ππππ" 0)) "high encode - show 1"} + {test_fn_cside (fn _ => show (strsub "ππππ" 1)) (show (strsub "ππππ" 1)) "high encode - show 2"} + {test_fn_cside (fn _ => show (strsub "ππππ" 2)) (show (strsub "ππππ" 2)) "high encode - show 3"} + {test_fn_cside (fn _ => show (strsub "ππππ" 3)) (show (strsub "ππππ" 3)) "high encode - show 4"} + + </body> + </xml> + +fun substrings () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => substring "abc" 0 3) "abc" "substrings 1"} + {test_fn_both_sides (fn _ => substring "abc" 1 2) "bc" "substrings 2"} + {test_fn_both_sides (fn _ => substring "abc" 2 1) "c" "substrings 3"} + {test_fn_both_sides (fn _ => substring "Γ‘bΓ³" 0 3) "Γ‘bΓ³" "substrings 4"} + {test_fn_both_sides (fn _ => substring "Γ‘bΓ³" 1 2) "bΓ³" "substrings 5"} + {test_fn_both_sides (fn _ => substring "Γ‘bΓ³" 2 1) "Γ³" "substrings 6"} + {test_fn_both_sides (fn _ => substring "Γ‘bΓ³" 0 2) "Γ‘b" "substrings 7"} + {test_fn_both_sides (fn _ => substring "Γ‘bΓ³" 0 1) "Γ‘" "substrings 8"} + {test_fn_both_sides (fn _ => substring "" 0 0) "" "substrings 9"} + </body> + </xml> + + +fun strlens () : transaction page = return <xml> + <body> + {test_fn_both_sides (fn _ => strlen "abc") 3 "strlen 1"} + {test_fn_both_sides (fn _ => strlen "Γ§bc") 3 "strlen 2"} + {test_fn_both_sides (fn _ => strlen "çãc") 3 "strlen 3"} + {test_fn_both_sides (fn _ => strlen "çãó") 3 "strlen 4"} + {test_fn_both_sides (fn _ => strlen "Γ§") 1 "strlen 5"} + {test_fn_both_sides (fn _ => strlen "c") 1 "strlen 6"} + {test_fn_both_sides (fn _ => strlen "") 0 "strlen 7"} + {test_fn_both_sides (fn _ => strlen "γ") 1 "strlen 8"} + {test_fn_both_sides (fn _ => strlen "ζΌ’") 1 "strlen 9"} + {test_fn_both_sides (fn _ => strlen "γ«") 1 "strlen 10"} + {test_fn_both_sides (fn _ => strlen "ΩΨΈΩΩΩΨ©") 6 "strlen 11"} + {test_fn_both_sides (fn _ => strlen "ε½ζΈ") 2 "strlen 12"} + {test_fn_both_sides (fn _ => strlen "Π€ΡΠ½ΠΊΡΠΈΠΎΠ½Π°Π»ΡΠ½ΠΎΠ΅") 14 "strlen 13"} + </body> + </xml> + +fun strlenGens () : transaction page = return <xml> + <body> + {test_fn_both_sides (fn _ => strlenGe "" 1) False "strlenGe 1"} + {test_fn_both_sides (fn _ => strlenGe "" 0) True "strlenGe 2"} + {test_fn_both_sides (fn _ => strlenGe "aba" 4) False "strlenGe 3"} + {test_fn_both_sides (fn _ => strlenGe "aba" 3) True "strlenGe 4"} + {test_fn_both_sides (fn _ => strlenGe "aba" 2) True "strlenGe 5"} + {test_fn_both_sides (fn _ => strlenGe "à çÑ" 4) False "strlenGe 6"} + {test_fn_both_sides (fn _ => strlenGe "à çÑ" 3) True "strlenGe 7"} + {test_fn_both_sides (fn _ => strlenGe "à çÑ" 2) True "strlenGe 8"} + </body> + </xml> + +type clen = { S : string, L : int } + +val clen_eq : eq clen = mkEq (fn a b => + a.S = b.S && a.L = b.L) + +val clen_show : show clen = mkShow (fn a => + "{S = " ^ a.S ^ ", L = " ^ (show a.L) ^ "}") + +fun strcats () : transaction page = + let + fun test_cat_and_len n a b expS expL = + test_fn_both_sides (fn _ => let val c = strcat a b in {S = c, L = strlen c} end) {S=expS, L=expL} ("strcat " ^ (show n)) + in + return <xml> + <body> + {test_cat_and_len 1 "" "" "" 0} + {test_cat_and_len 2 "aa" "bb" "aabb" 4} + {test_cat_and_len 3 "" "bb" "bb" 2} + {test_cat_and_len 4 "aa" "" "aa" 2} + {test_cat_and_len 5 "Γ Γ " "ÑÑ" "à à ÑÑ" 4} + {test_cat_and_len 6 "" "ÑÑ" "ÑÑ" 2} + {test_cat_and_len 7 "Γ Γ " "" "Γ Γ " 2} + {test_cat_and_len 8 "ε½ζΈ" "ãã" "ε½ζΈΓ£Γ£" 4} + {test_cat_and_len 9 "Γ§" "Γ£" "çã" 2} + {test_cat_and_len 10 (show (strsub "Γ§" 0)) (show (strsub "Γ£" 0)) "çã" 2} + {test_cat_and_len 11 (show (chr 231)) (show (chr 227)) "çã" 2} + </body> + </xml> +end + +fun strsubs () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => strsub "abΓ Γ§" 0) #"a" "strsub 1"} + {test_fn_both_sides (fn _ => strsub "abΓ Γ§" 1) #"b" "strsub 2"} + {test_fn_both_sides (fn _ => strsub "Γ b" 0) (strsub "Γ " 0) "strsub 3"} + {test_fn_both_sides (fn _ => strsub "abΓ Γ§" 2) (strsub "Γ " 0) "strsub 4"} + {test_fn_both_sides (fn _ => strsub "abΓ Γ§" 3) (strsub "Γ§" 0) "strsub 5"} + </body> + </xml> + +fun strsuffixs () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => strsuffix "abΓ Γ§" 0) "abΓ Γ§" "strsuffix 1"} + {test_fn_both_sides (fn _ => strsuffix "abΓ Γ§" 1) "bΓ Γ§" "strsuffix 2"} + {test_fn_both_sides (fn _ => strsuffix "abΓ Γ§" 2) "Γ Γ§" "strsuffix 3"} + {test_fn_both_sides (fn _ => strsuffix "abΓ Γ§" 3) "Γ§" "strsuffix 4"} + </body> + </xml> + +fun strchrs () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => strchr "abΓ Γ§" #"c") None "strchr 1"} + {test_fn_both_sides (fn _ => strchr "abΓ Γ§" #"a") (Some "abΓ Γ§") "strchr 2"} + {test_fn_both_sides (fn _ => strchr "abΓ Γ§" #"b") (Some "bΓ Γ§") "strchr 3"} + {test_fn_both_sides (fn _ => strchr "abΓ Γ§" (strsub "Γ " 0)) (Some "Γ Γ§") "strchr 4"} + {test_fn_both_sides (fn _ => strchr "abΓ Γ§" (strsub "Γ§" 0)) (Some "Γ§") "strchr 5"} + </body> + </xml> + +fun strindexs () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => strindex "abΓ Γ§" #"c") None "strindex 1"} + {test_fn_both_sides (fn _ => strindex "abΓ Γ§" #"a") (Some 0) "strindex 2"} + {test_fn_both_sides (fn _ => strindex "abΓ Γ§" #"b") (Some 1) "strindex 3"} + {test_fn_both_sides (fn _ => strindex "abΓ Γ§" (strsub "Γ " 0)) (Some 2) "strindex 4"} + {test_fn_both_sides (fn _ => strindex "abΓ Γ§" (strsub "Γ§" 0)) (Some 3) "strindex 5"} + </body> + </xml> + +fun strsindexs () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "") (Some 0) "strsindex 1"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "abΓ Γ§") (Some 0) "strsindex 2"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "abΓ c") None "strsindex 3"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "bΓ Γ§") (Some 1) "strsindex 4"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "bΓ c") None "strsindex 5"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "Γ Γ§") (Some 2) "strsindex 6"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "Γ c") None "strsindex 7"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "Γ§") (Some 3) "strsindex 8"} + {test_fn_both_sides (fn _ => strsindex "abΓ Γ§" "c") None "strsindex 9"} + </body> + </xml> + +fun strcspns () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => strcspn "abΓ Γ§" "") 4 "strcspn 1"} + {test_fn_both_sides (fn _ => strcspn "abΓ Γ§" "abΓ Γ§") 0 "strcspn 2"} + {test_fn_both_sides (fn _ => strcspn "abΓ Γ§" "a") 0 "strcspn 3"} + {test_fn_both_sides (fn _ => strcspn "abΓ Γ§" "bΓ Γ§") 1 "strcspn 4"} + {test_fn_both_sides (fn _ => strcspn "abΓ Γ§" "Γ Γ§") 2 "strcspn 5"} + {test_fn_both_sides (fn _ => strcspn "abΓ Γ§" "Γ§") 3 "strcspn 6"} + </body> + </xml> + +fun str1s () : transaction page = return <xml> + <body> + {test_fn_both_sides (fn _ => str1 #"a") "a" "str1 1"} + {test_fn_both_sides (fn _ => str1 (strsub "Γ " 0)) "Γ " "str1 2"} + {test_fn_both_sides (fn _ => str1 (strsub "aΓ‘" 1)) "Γ‘" "str1 3"} + </body> + </xml> + +fun isalnums () : transaction page = return <xml> + <body> + {test_fn_both_sides (fn _ => isalnum #"a") True "isalnum 1"} + {test_fn_both_sides (fn _ => isalnum #"a") True "isalnum 2"} + {test_fn_both_sides (fn _ => isalnum (strsub "Γ " 0)) True "isalnum 3"} + {test_fn_both_sides (fn _ => isalnum #"A") True "isalnum 4"} + {test_fn_both_sides (fn _ => isalnum (strsub "Γ" 0)) True "isalnum 5"} + {test_fn_both_sides (fn _ => isalnum #"1") True "isalnum 6"} + {test_fn_both_sides (fn _ => not (isalnum #"!")) True "isalnum 7"} + {test_fn_both_sides (fn _ => not (isalnum #"#")) True "isalnum 8"} + {test_fn_both_sides (fn _ => not (isalnum #" ")) True "isalnum 9"} + </body> +</xml> + +fun isalphas () : transaction page = return <xml> + <body> + {test_fn_both_sides (fn _ => isalpha #"a") True "isalpha 1"} + {test_fn_both_sides (fn _ => isalpha (strsub "Γ " 0)) True "isalpha 2"} + {test_fn_both_sides (fn _ => isalpha #"A") True "isalpha 3"} + {test_fn_both_sides (fn _ => isalpha (strsub "Γ" 0)) True "isalpha 4"} + {test_fn_both_sides (fn _ => not (isalpha #"1")) True "isalpha 5"} + {test_fn_both_sides (fn _ => not (isalpha #"!")) True "isalpha 6"} + {test_fn_both_sides (fn _ => not (isalpha #"#")) True "isalpha 7"} + {test_fn_both_sides (fn _ => not (isalpha #" ")) True "isalpha 8"} + </body> +</xml> + +fun isblanks () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => not (isblank #"a")) True "isblank 1"} + {test_fn_both_sides (fn _ => not (isblank (strsub "Γ " 0))) True "isblank 2"} + {test_fn_both_sides (fn _ => not (isblank #"A")) True "isblank 3"} + {test_fn_both_sides (fn _ => not (isblank (strsub "Γ" 0))) True "isblank 4"} + {test_fn_both_sides (fn _ => not (isblank #"1")) True "isblank 5"} + {test_fn_both_sides (fn _ => not (isblank #"!")) True "isblank 6"} + {test_fn_both_sides (fn _ => not (isblank #"#")) True "isblank 7"} + {test_fn_both_sides (fn _ => isblank #" ") True "isblank 8"} + {test_fn_both_sides (fn _ => isblank #"\t") True "isblank 9"} + {test_fn_both_sides (fn _ => not (isblank #"\n")) True "isblank 10"} + </body> + </xml> + +fun iscntrls () : transaction page = + return <xml> + <body> + {test_fn_sside (fn _ => not (iscntrl #"a")) True "iscntrl 1"} + {test_fn_sside (fn _ => not (iscntrl (strsub "Γ " 0))) True "iscntrl 2"} + {test_fn_sside (fn _ => not (iscntrl #"A")) True "iscntrl 3"} + {test_fn_sside (fn _ => not (iscntrl (strsub "Γ" 0))) True "iscntrl 4"} + {test_fn_sside (fn _ => not (iscntrl #"1")) True "iscntrl 5"} + {test_fn_sside (fn _ => not (iscntrl #"!")) True "iscntrl 6"} + {test_fn_sside (fn _ => not (iscntrl #"#")) True "iscntrl 7"} + {test_fn_sside (fn _ => not (iscntrl #" ")) True "iscntrl 8"} + {test_fn_sside (fn _ => iscntrl #"\t") True "iscntrl 9"} + {test_fn_sside (fn _ => iscntrl #"\n") True "iscntrl 10"} + </body> + </xml> + +fun isdigits () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => not (isdigit #"a")) True "isdigit 1"} + {test_fn_both_sides (fn _ => not (isdigit (strsub "Γ " 0))) True "isdigit 2"} + {test_fn_both_sides (fn _ => not (isdigit #"A")) True "isdigit 3"} + {test_fn_both_sides (fn _ => not (isdigit (strsub "Γ" 0))) True "isdigit 4"} + {test_fn_both_sides (fn _ => isdigit #"1") True "isdigit 5"} + {test_fn_both_sides (fn _ => not (isdigit #"!")) True "isdigit 6"} + {test_fn_both_sides (fn _ => not (isdigit #"#")) True "isdigit 7"} + {test_fn_both_sides (fn _ => not (isdigit #" ")) True "isdigit 8"} + {test_fn_both_sides (fn _ => not (isdigit #"\t")) True "isdigit 9"} + {test_fn_both_sides (fn _ => not (isdigit #"\n")) True "isdigit 10"} + </body> + </xml> + +fun isgraphs () : transaction page = + return <xml> + <body> + {test_fn_sside (fn _ => isgraph #"a") True "isgraph 1"} + {test_fn_sside (fn _ => isgraph (strsub "Γ " 0)) True "isgraph 2"} + {test_fn_sside (fn _ => isgraph #"A") True "isgraph 3"} + {test_fn_sside (fn _ => isgraph (strsub "Γ" 0)) True "isgraph 4"} + {test_fn_sside (fn _ => isgraph #"1") True "isgraph 5"} + {test_fn_sside (fn _ => isgraph #"!") True "isgraph 6"} + {test_fn_sside (fn _ => isgraph #"#") True "isgraph 7"} + {test_fn_sside (fn _ => not (isgraph #" ")) True "isgraph 8"} + {test_fn_sside (fn _ => not (isgraph #"\t")) True "isgraph 9"} + {test_fn_sside (fn _ => not (isdigit #"\n")) True "isgraph 10"} + </body> + </xml> + +fun islowers () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => islower #"a") True "islower 1"} + {test_fn_both_sides (fn _ => islower (strsub "Γ " 0)) True "islower 2"} + {test_fn_both_sides (fn _ => not (islower #"A")) True "islower 3"} + {test_fn_both_sides (fn _ => not (islower (strsub "Γ" 0))) True "islower 4"} + {test_fn_both_sides (fn _ => not (islower #"1")) True "islower 5"} + {test_fn_both_sides (fn _ => not (islower #"!")) True "islower 6"} + {test_fn_both_sides (fn _ => not (islower #"#")) True "islower 7"} + {test_fn_both_sides (fn _ => not (islower #" ")) True "islower 8"} + {test_fn_both_sides (fn _ => not (islower #"\t")) True "islower 9"} + {test_fn_both_sides (fn _ => not (islower #"\n")) True "islower 10"} + </body> + </xml> + +fun isprints () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => isprint #"a") True "isprint 1"} + {test_fn_both_sides (fn _ => isprint (strsub "Γ " 0)) True "isprint 2"} + {test_fn_both_sides (fn _ => isprint #"A") True "isprint 3"} + {test_fn_both_sides (fn _ => isprint (strsub "Γ" 0)) True "isprint 4"} + {test_fn_both_sides (fn _ => isprint #"1") True "isprint 5"} + {test_fn_both_sides (fn _ => isprint #"!") True "isprint 6"} + {test_fn_both_sides (fn _ => isprint #"#") True "isprint 7"} + {test_fn_both_sides (fn _ => isprint #" ") True "isprint 8"} + {test_fn_both_sides (fn _ => not (isprint #"\t")) True "isprint 9"} + {test_fn_both_sides (fn _ => not (isprint #"\n")) True "isprint 10"} + </body> + </xml> + +fun ispuncts () : transaction page = + return <xml> + <body> + {test_fn_sside (fn _ => not (ispunct #"a")) True "ispunct 1"} + {test_fn_sside (fn _ => not (ispunct (strsub "Γ " 0))) True "ispunct 2"} + {test_fn_sside (fn _ => not (ispunct #"A")) True "ispunct 3"} + {test_fn_sside (fn _ => not (ispunct (strsub "Γ" 0))) True "ispunct 4"} + {test_fn_sside (fn _ => not (ispunct #"1")) True "ispunct 5"} + {test_fn_sside (fn _ => ispunct #"!") True "ispunct 6"} + {test_fn_sside (fn _ => ispunct #"#") True "ispunct 7"} + {test_fn_sside (fn _ => not (ispunct #" ")) True "ispunct 8"} + {test_fn_sside (fn _ => not (isprint #"\t")) True "ispunct 9"} + {test_fn_sside (fn _ => not (isprint #"\n")) True "ispunct 10"} + </body> + </xml> + +fun isspaces () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => not (isspace #"a")) True "isspace 1"} + {test_fn_both_sides (fn _ => not (isspace (strsub "Γ " 0))) True "isspace 2"} + {test_fn_both_sides (fn _ => not (isspace #"A")) True "isspace 3"} + {test_fn_both_sides (fn _ => not (isspace (strsub "Γ" 0))) True "isspace 4"} + {test_fn_both_sides (fn _ => not (isspace #"1")) True "isspace 5"} + {test_fn_both_sides (fn _ => not (isspace #"!")) True "isspace 6"} + {test_fn_both_sides (fn _ => not (isspace #"#")) True "isspace 7"} + {test_fn_both_sides (fn _ => isspace #" ") True "isspace 8"} + {test_fn_both_sides (fn _ => isspace #"\t") True "isspace 9"} + {test_fn_both_sides (fn _ => isspace #"\n") True "isspace 10"} + </body> + </xml> + +fun isuppers () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => not (isupper #"a")) True "isupper 1"} + {test_fn_both_sides (fn _ => not (isupper (strsub "Γ " 0))) True "isupper 2"} + {test_fn_both_sides (fn _ => isupper #"A") True "isupper 3"} + {test_fn_both_sides (fn _ => isupper (strsub "Γ" 0)) True "isupper 4"} + {test_fn_both_sides (fn _ => not (isupper #"1")) True "isupper 5"} + {test_fn_both_sides (fn _ => not (isupper #"!")) True "isupper 6"} + {test_fn_both_sides (fn _ => not (isupper #"#")) True "isupper 7"} + {test_fn_both_sides (fn _ => not (isupper #" ")) True "isupper 8"} + {test_fn_both_sides (fn _ => not (isupper #"\t")) True "isupper 9"} + {test_fn_both_sides (fn _ => not (isupper #"\n")) True "isupper 10"} + </body> + </xml> + +fun isxdigits () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => isxdigit #"a") True "isxdigit 1"} + {test_fn_both_sides (fn _ => not (isxdigit (strsub "Γ " 0))) True "isxdigit 2"} + {test_fn_both_sides (fn _ => isxdigit #"A") True "isxdigit 3"} + {test_fn_both_sides (fn _ => not (isxdigit (strsub "Γ" 0))) True "isxdigit 4"} + {test_fn_both_sides (fn _ => isxdigit #"1") True "isxdigit 5"} + {test_fn_both_sides (fn _ => not (isxdigit #"!")) True "isxdigit 6"} + {test_fn_both_sides (fn _ => not (isxdigit #"#")) True "isxdigit 7"} + {test_fn_both_sides (fn _ => not (isxdigit #" ")) True "isxdigit 8"} + {test_fn_both_sides (fn _ => not (isxdigit #"\t")) True "isxdigit 9"} + {test_fn_both_sides (fn _ => not (isxdigit #"\n")) True "isxdigit 10"} + </body> + </xml> + +fun tolowers () : transaction page = + let + fun lower_of a _ = + tolower a + in + return <xml> + <body> + {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"} + </body> + </xml> + end + +fun touppers () : transaction page = + let + fun upper_of a _ = + toupper a + in + return <xml> + <body> + {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"} + </body> + </xml> + end + +fun ord_and_chrs () : transaction page = + return <xml> + <body> + {test_fn_both_sides (fn _ => chr (ord #"A")) #"A" "ord => chr 1"} + {test_fn_both_sides (fn _ => chr (ord #"a")) #"a" "ord => chr 2"} + {test_fn_both_sides (fn _ => chr (ord (strsub "Γ‘" 0))) (strsub "Γ‘" 0) "ord => chr 3"} + {test_fn_both_sides (fn _ => chr (ord (strsub "Γ" 0))) (strsub "Γ" 0) "ord => chr 4"} + {test_fn_both_sides (fn _ => chr (ord #"1")) #"1" "ord => chr 5"} + {test_fn_both_sides (fn _ => chr (ord #"\n")) #"\n" "ord => chr 6"} + {test_fn_both_sides (fn _ => chr (ord (strsub "γ" 0))) (strsub "γ" 0) "ord => chr 7"} + {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"} + </body> + </xml> + +fun test_ords () : transaction page = + let + fun ord_of c _ = + ord c + in + return <xml> + <body> + {test_fn_cside (ord_of (strsub "a" 0)) (ord_of (strsub "a" 0) ()) "test ord 1"} + {test_fn_cside (ord_of (strsub "Γ‘" 0)) (ord_of (strsub "Γ‘" 0) ()) "test ord 2"} + {test_fn_cside (ord_of (strsub "5" 0)) (ord_of (strsub "5" 0) ()) "test ord 3"} + {test_fn_cside (ord_of (strsub "γ" 0)) (ord_of (strsub "γ" 0) ()) "test ord 4"} + {test_fn_cside (ord_of (strsub "ζΌ’" 0)) (ord_of (strsub "ζΌ’" 0) ()) "test ord 5"} + {test_fn_cside (ord_of (strsub "γ«" 0)) (ord_of (strsub "γ«" 0) ()) "test ord 6"} + </body> + </xml> + end + +table t : { Id : int, Text : string } + +fun test_db () : transaction page = + let + val s1 = "abc" + val s2 = "çãó" + val s3 = "γ" + val s4 = "ζΌ’" + val s5 = "γ«" + val s6 = "ΩΨΈΩΩΩΨ©" + + fun test_str_and_len n c expS expL = + test_fn_both_sides (fn _ => {S = c, L = strlen c}) {S=expS, L=expL} ("test_db " ^ (show n)) + + in + dml (INSERT INTO t (Id, Text) VALUES({[1]}, {[s1]})); + t1 <- oneRow (SELECT t.Text FROM t WHERE t.Id = 1); + + dml (INSERT INTO t (Id, Text) VALUES({[2]}, {[s2]})); + t2 <- oneRow (SELECT t.Text FROM t WHERE t.Id = 2); + + dml (INSERT INTO t (Id, Text) VALUES({[3]}, {[s3]})); + t3 <- oneRow (SELECT t.Text FROM t WHERE t.Id = 3); + + dml (INSERT INTO t (Id, Text) VALUES({[4]}, {[s4]})); + t4 <- oneRow (SELECT t.Text FROM t WHERE t.Id = 4); + + dml (INSERT INTO t (Id, Text) VALUES({[5]}, {[s5]})); + t5 <- oneRow (SELECT t.Text FROM t WHERE t.Id = 5); + + dml (INSERT INTO t (Id, Text) VALUES({[6]}, {[s6]})); + t6 <- oneRow (SELECT t.Text FROM t WHERE t.Id = 6); + + return <xml> + <body> + {test_str_and_len 1 t1.T.Text s1 (strlen s1)} + {test_str_and_len 2 t2.T.Text s2 (strlen s2)} + {test_str_and_len 3 t3.T.Text s3 (strlen s3)} + {test_str_and_len 4 t4.T.Text s4 (strlen s4)} + {test_str_and_len 5 t5.T.Text s5 (strlen s5)} + {test_str_and_len 6 t6.T.Text s6 (strlen s6)} + </body> + </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> + <a link={substrings ()}>substrings</a> + <a link={strlens ()}>strlens</a> + <a link={strlenGens ()}>strlenGens</a> + <a link={strcats ()}>strcats</a> + <a link={strsubs ()}>strsubs</a> + <a link={strsuffixs ()}>strsuffixs</a> + <a link={strchrs ()}>strchrs</a> + <a link={strindexs ()}>strindexs</a> + <a link={strsindexs ()}>strsindexs</a> + <a link={strcspns ()}>strcspns</a> + <a link={str1s ()}>str1s</a> + <a link={isalnums ()}>isalnums</a> + <a link={isalphas ()}>isalphas</a> + <a link={isblanks ()}>isblanks</a> + <a link={iscntrls ()}>iscntrls</a> + <a link={isdigits ()}>isdigits</a> + <a link={isgraphs ()}>isgraphs</a> + <a link={islowers ()}>islowers</a> + <a link={isprints ()}>isprints</a> + <a link={ispuncts ()}>ispuncts</a> + <a link={isspaces ()}>isspaces</a> + <a link={isuppers ()}>isuppers</a> + <a link={isxdigits ()}>isxdigits</a> + <a link={tolowers ()}>tolowers</a> + <a link={touppers ()}>touppers</a> + <a link={ord_and_chrs ()}>ord_and_chrs</a> + <a link={test_ords ()}>test ord</a> + <a link={highencode ()}>highencode</a> + <a link={test_db ()}>test_db</a> + </body> + </xml> diff --git a/tests/utf8.urp b/tests/utf8.urp new file mode 100644 index 00000000..25288aa8 --- /dev/null +++ b/tests/utf8.urp @@ -0,0 +1,6 @@ +database dbname=utf8 +sql utf8.sql +safeGet Utf8/test_db + +$/option +utf8
\ No newline at end of file |