summaryrefslogtreecommitdiff
path: root/src/test/test.ml
blob: 9ae698a8a587f9e8c20837a1a97e54a493929220 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
    | exception _ ->
      error := 1;
      Printf.fprintf stdout
        "%s : error \n%!"
        line
    | 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",    "abEs2Ra"
  ; "achat",        "aSa(t)"
  ; "agneau",       "aNo"
  ; "aimes",        "Em°(s)"
  ; "aiment",       "Em°(t)"
  ; "anniversaire", "anivERsER°"
  ; "anta",         "@ta"
  ; "anneaux",      "ano(s)"
  ; "arachide",     "aRaSid°"
  ; "as",           "a(s)"
  ; "asia",         "az[ja]"
  ; "astiqué",      "astike"
  ; "atmosphère",   "atmosfER°"
  ; "automne",      "ot§n°"
  ; "autruche",     "otRyS°"
  ; "besoin",       "b2zw5"
  ; "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°"
  ; "demeure",      "d2m9R°"
  ; "diag|nostic",  "d[ja]gnostik"
  ; "ébrouas",      "ebRua(s)"
  ; "effroi",       "EfR[wa]"
  ; "em|magasinais","@magazinE(s)"
  ; "essai",        "EsE"
  ; "extra",        "EkstRa"
  ; "famille",      "famij°"
  ; "feuille",      "f9j°"
  ; "final",        "finaL"
  ; "loin",         "L[w5]"
  ; "groin",        "gR[w5]"
  ; "hélicoptère",  "eLikoptER°"
  ; "hirondelle",   "iR§dEL°"
  ; "joues",        "Zu°(s)"
  ; "libellule",    "LibELyL°"
  ; "main",         "m5"
  ; "merci",        "mERsi"
  ; "ménageais",    "menaZE(s)"
  ; "mouillage",    "mujaZ°"
  ; "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",      "t[wa]tyR°"
  ; "trois",        "tR[wa](s)"
  ; "vieux",        "v[j9](s)"
  ; "vil|le",       "viLL°"
  ; "wèb",          "wEb"
  ]

let () =
  let n = ref 0 in
  let () = List.iter tests
      ~f:(fun (input, expected) ->
          incr n;
          repeat (Lexing.from_string input) expected)
  in

  Printf.printf "Runned %d tests. Got %d errors\n" (!n) (!error);
  exit !error