Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
puripuri2100 committed Nov 2, 2023
1 parent d8a14f4 commit 3a45418
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions tests/split-grapheme-cluster.saty
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,38 @@ let () =
[0x1F469, 0x1F3FE, 0x200D, 0x1F393]
]
in
let slst = split-grapheme-cluster s1 in
let is-ok =
let rec loop l1 l2 =
match (l1, l2) with
| (s1::xs1, s2::xs2)-> string-same s1 (string-unexplode s2) && (loop xs1 xs2)
| ([], []) -> true
| _ -> false
end
in
loop slst s2
let s3 =
[
[0x1F1EF, 0x1F1F5],
[0x30AB, 0x3099],
[0x30AB, 0x3099],
[0x1F468, 0x200D, 0x1F469, 0x200D, 0x1F466],
[0x1F469, 0x200D, 0x1F469, 0x200D, 0x1F467, 0x200D, 0x1F467],
[0x1F3F4, 0xE0067, 0xE0062, 0xE0077, 0xE006C, 0xE0073, 0xE007F],
[0x1F469, 0x1F3FE, 0x200D, 0x1F393]
]
in
let slst1 = s1 |> normalize-string-to-nfc |> split-grapheme-cluster in
let slst2 = s1 |> normalize-string-to-nfd |> split-grapheme-cluster in
let rec check-loop l1 l2 =
match (l1, l2) with
| (s1::xs1, s2::xs2)-> string-same s1 (string-unexplode s2) && (check-loop xs1 xs2)
| ([], []) -> true
| _ -> false
end
in
if is-ok then
let is-ok1 = check-loop slst1 s2 in
let is-ok2 = check-loop slst2 s3 in
if is-ok1 && is-ok2 then
display-message `ok`
else
abort-with-message `err`
if not is-ok1 && not is-ok2 then
abort-with-message `err1, 2`
else
if not is-ok1 then
abort-with-message `err1`
else
abort-with-message `err2`
in

document (|
Expand Down

0 comments on commit 3a45418

Please sign in to comment.