-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
12,967 additions
and
3,473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version=0.19.0 | ||
profile = conventional | ||
break-separators = after | ||
space-around-lists = false | ||
doc-comments = before | ||
match-indent = 2 | ||
match-indent-nested = always | ||
parens-ite | ||
exp-grouping = preserve | ||
module-item-spacing = compact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,50 @@ | ||
(* This test that unicode_old.ml is a strict sub-set of | ||
* new unicode.ml. *) | ||
|
||
let test_versions = ("13.0.0","14.0.0") | ||
|
||
let test_versions = ("13.0.0", "14.0.0") | ||
let regressions = [] | ||
|
||
let interval s e = | ||
Array.to_list | ||
(Array.init (e-s) (fun pos -> s + pos)) | ||
let interval s e = Array.to_list (Array.init (e - s) (fun pos -> s + pos)) | ||
|
||
exception Found | ||
|
||
let test_exception name x = | ||
try | ||
let l = List.assoc name regressions in | ||
List.iter (fun (s,e) -> | ||
if s<=x && x<=e then raise Found) l | ||
List.iter (fun (s, e) -> if s <= x && x <= e then raise Found) l | ||
with Not_found -> () | ||
|
||
let compare name old_l new_l = | ||
let code_points = List.fold_left (fun res (s,e) -> | ||
res@(interval s e)) [] old_l | ||
let code_points = | ||
List.fold_left (fun res (s, e) -> res @ interval s e) [] old_l | ||
in | ||
let test x = | ||
try | ||
test_exception name x; | ||
List.iter (fun (s,e) -> | ||
if s<=x && x<=e then raise Found) new_l; | ||
List.iter (fun (s, e) -> if s <= x && x <= e then raise Found) new_l; | ||
false | ||
with Found -> true | ||
in | ||
List.iter (fun x -> | ||
if not (test x) then | ||
Printf.printf "Code point 0x%x missing in %s!\n" x name) | ||
code_points | ||
List.iter | ||
(fun x -> | ||
if not (test x) then | ||
Printf.printf "Code point 0x%x missing in %s!\n" x name) | ||
code_points | ||
|
||
let test new_l (name, old_l) = | ||
(* Cn is for unassigned code points, which are allowed to be | ||
* used in future version. *) | ||
if name <> "cn" then | ||
compare name old_l (List.assoc name new_l) | ||
if name <> "cn" then compare name old_l (List.assoc name new_l) | ||
|
||
let () = | ||
if (Unicode_old.version,Sedlex_ppx.Unicode.version) <> test_versions then | ||
failwith (Printf.sprintf "Test written for versions: %s => %s\n%!" Unicode_old.version Sedlex_ppx.Unicode.version); | ||
Printf.printf "Testing Unicode regression: %s => %s\n%!" Unicode_old.version Sedlex_ppx.Unicode.version; | ||
List.iter (test Sedlex_ppx.Unicode.Categories.list) Unicode_old.Categories.list; | ||
List.iter (test Sedlex_ppx.Unicode.Properties.list) Unicode_old.Properties.list | ||
if (Unicode_old.version, Sedlex_ppx.Unicode.version) <> test_versions then | ||
failwith | ||
(Printf.sprintf "Test written for versions: %s => %s\n%!" | ||
Unicode_old.version Sedlex_ppx.Unicode.version); | ||
Printf.printf "Testing Unicode regression: %s => %s\n%!" Unicode_old.version | ||
Sedlex_ppx.Unicode.version; | ||
List.iter | ||
(test Sedlex_ppx.Unicode.Categories.list) | ||
Unicode_old.Categories.list; | ||
List.iter | ||
(test Sedlex_ppx.Unicode.Properties.list) | ||
Unicode_old.Properties.list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
let rec token buf = | ||
match%sedlex buf with | ||
| white_space -> print_endline "\tWhitespace"; token buf | ||
| 'a', Rep(white_space, 1) -> print_endline "a\n\tWhitespace"; token buf | ||
| Rep("bc", 2) -> print_endline "bcbc"; token buf | ||
| Rep("d", 1 .. 1) -> print_endline "d"; token buf | ||
| Rep("ef", 1 .. 3) -> Printf.printf "%s\n" (Sedlexing.Utf8.lexeme buf); token buf | ||
| white_space -> | ||
print_endline "\tWhitespace"; | ||
token buf | ||
| 'a', Rep (white_space, 1) -> | ||
print_endline "a\n\tWhitespace"; | ||
token buf | ||
| Rep ("bc", 2) -> | ||
print_endline "bcbc"; | ||
token buf | ||
| Rep ("d", 1 .. 1) -> | ||
print_endline "d"; | ||
token buf | ||
| Rep ("ef", 1 .. 3) -> | ||
Printf.printf "%s\n" (Sedlexing.Utf8.lexeme buf); | ||
token buf | ||
| eof -> print_endline "\tEnd" | ||
| any -> print_endline "Other"; token buf | ||
| any -> | ||
print_endline "Other"; | ||
token buf | ||
| _ -> failwith "Internal failure: Reached impossible place" | ||
|
||
|
||
let () = | ||
let lexbuf = Sedlexing.Utf8.from_string "a bcbc d ef efef efefef" in | ||
token lexbuf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
let rec token buf = | ||
match%sedlex buf with | ||
| white_space -> print_endline "\tWhitespace"; token buf | ||
| Sub (Chars "ab","b") -> print_endline "a"; token buf | ||
| (Chars "ab"|"c") -> print_endline "abc"; token buf | ||
| Intersect ("d", Chars "abd") -> print_endline "d"; token buf | ||
| white_space -> | ||
print_endline "\tWhitespace"; | ||
token buf | ||
| Sub (Chars "ab", "b") -> | ||
print_endline "a"; | ||
token buf | ||
| Chars "ab" | "c" -> | ||
print_endline "abc"; | ||
token buf | ||
| Intersect ("d", Chars "abd") -> | ||
print_endline "d"; | ||
token buf | ||
| eof -> print_endline "\tEnd" | ||
| any -> print_endline "Other"; token buf | ||
| any -> | ||
print_endline "Other"; | ||
token buf | ||
| _ -> failwith "Internal failure: Reached impossible place" | ||
|
||
|
||
let () = | ||
let lexbuf = Sedlexing.Utf8.from_string "a b c d e" in | ||
token lexbuf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.