open StdLabels module T = Translator let error = ref 0 let process (optional_line : string option) expected = match optional_line with | None -> () | Some line -> match T.Reader.process line with | Error result -> error := 1; Printf.fprintf stdout "%s : %s\n%!" line result | Ok response -> if String.equal response expected then () (* (Printf.fprintf stdout "%s : %s OK \n%!" line expected) *) else ( error := 1; (Printf.fprintf stdout "%s : got %s / %s expected\n%!" line response expected) ) let rec repeat input expected = (* Attempt to read one line. *) let optional_line, continue = T.Lexer.line input in process optional_line expected; if continue then repeat input expected let tests = [ "abaca", "abaka" ; "abaissa", "abEsa" ; "abaissait", "abEsE(t)" ; "abaissant", "abEs@(t)" ; "abaissées", "abEse(s)" ; "abaissera", "abEs°Ra" ; "achat", "aSa(t)" ; "ani", "ani" ; "anta", "@ta" ; "anneaux", "ano(s)" ; "arachide", "aRaSid°" ; "as", "a(s)" ; "asia", "azia" ; "astiqué", "astike" ; "autruche", "otRyS°" ; "besoin", "b°zw5" ; "beaumont", "bom§(t)" ; "bisoux", "bizu(s)" ; "casait", "kazE(t)" ; "cassait", "kasE(t)" ; "célibat", "seLiba(t)" ; "chanci", "S@si" ; "chat", "Sa(t)" ; "chipant", "Sip@(t)" ; "co|incidant", "ko5sid@(t)" ; "croire", "kR[wa]R°" ; "ébrouas", "ebRua(s)" ; "em|magasinais","@magazinE(s)" ; "famille", "famij°" ; "loin", "Lw5" ; "groin", "gR[w5]" ; "hirondelle", "iR§dEL°" ; "joues", "Zu°(s)" ; "libellule", "LibELyL°" ; "main", "m5" ; "merci", "mERsi" ; "ménageais", "menaZE(s)" ; "neige", "nEZ°" ; "neuf", "n9f" ; "nerf", "nE(R)" ; "pacha", "paSa" ; "péché", "peSe" ; "persai", "pERsE" ; "personne", "pERson°" ; "plan", "pL@" ; "plat", "pLa(t)" ; "platte", "pLat°" ; "soin", "sw5" ; "souris", "suRi(s)" ; "toiture", "twatyR°" ; "trois", "tR[wa](s)" ; "vil|le", "viLL°" ; "wèb", "wEb" ] let () = let () = List.iter tests ~f:(fun (input, expected) -> repeat (Lexing.from_string input) expected) in exit !error