Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jun 27, 2023
1 parent 57d53f2 commit 7b1f9be
Show file tree
Hide file tree
Showing 2 changed files with 490 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/lib/sedlexing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ type lexbuf = {

let chunk_size = 512

let empty_lexbuf =
let empty_lexbuf bytes_per_char =
{
refill = (fun _ _ _ -> assert false);
bytes_per_char = (fun _ -> assert false);
bytes_per_char;
buf = [||];
len = 0;
offset = 0;
Expand Down Expand Up @@ -95,9 +95,8 @@ let nl_uchar = Uchar.of_int 10

let create ?(bytes_per_char = fun _ -> 1) refill =
{
empty_lexbuf with
(empty_lexbuf bytes_per_char) with
refill;
bytes_per_char;
buf = Array.make chunk_size dummy_uchar;
}
Expand Down Expand Up @@ -138,9 +137,8 @@ let from_int_array ?bytes_per_char a =
let from_uchar_array ?(bytes_per_char = fun _ -> 1) a =
let len = Array.length a in
{
empty_lexbuf with
(empty_lexbuf bytes_per_char) with
buf = Array.init len (fun i -> a.(i));
bytes_per_char;
len;
finished = true;
}
Expand Down Expand Up @@ -369,7 +367,7 @@ module Latin1 = struct
let from_string s =
let len = String.length s in
{
empty_lexbuf with
(empty_lexbuf (fun _ -> 1)) with
buf = Array.init len (fun i -> Uchar.of_char s.[i]);
len;
finished = true;
Expand Down
Loading

0 comments on commit 7b1f9be

Please sign in to comment.