Skip to content

Commit

Permalink
add some test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Heuzard committed Feb 25, 2023
1 parent 6be0490 commit 4fde081
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/utf8.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
open Printf

let next_tok buf =
let open Sedlexing.Utf8 in
match%sedlex buf with
| "a", Utf8 (Chars "+-×÷") -> sprintf "with Chars: %s" (lexeme buf)
| "b", Utf8 ("+" | "-" | "×" | "÷") ->
sprintf "with or_pattern: %s" (lexeme buf)
| _ -> failwith (sprintf "Unexpected character: %s" (lexeme buf))

let%expect_test _ =
Sedlexing.Utf8.from_string "a+" |> next_tok |> print_string;
[%expect {| with Chars: a+ |}];
Sedlexing.Utf8.from_string "" |> next_tok |> print_string;
[%expect {| with Chars: a÷ |}];
Sedlexing.Utf8.from_string "b+" |> next_tok |> print_string;
[%expect {| with or_pattern: b+ |}];
Sedlexing.Utf8.from_string "" |> next_tok |> print_string;
[%expect {| with or_pattern: b÷ |}]

0 comments on commit 4fde081

Please sign in to comment.