summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-08-23 14:37:53 +0200
committerSébastien Dailly <sebastien@chimrod.com>2021-08-23 14:37:53 +0200
commit546afdcf2148087f3a90b69c23ea756550f64433 (patch)
treeac56c71393aacf0fade729e98eeecb1e87a88534 /src/test
Initial commit
Diffstat (limited to 'src/test')
-rw-r--r--src/test/dune9
-rw-r--r--src/test/test.ml66
2 files changed, 75 insertions, 0 deletions
diff --git a/src/test/dune b/src/test/dune
new file mode 100644
index 0000000..f8dbc72
--- /dev/null
+++ b/src/test/dune
@@ -0,0 +1,9 @@
+(test
+ (name
+ test
+ )
+ (libraries translator)
+ )
+
+
+
diff --git a/src/test/test.ml b/src/test/test.ml
new file mode 100644
index 0000000..ca74a9e
--- /dev/null
+++ b/src/test/test.ml
@@ -0,0 +1,66 @@
+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
+ ()
+ 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)"
+ ; "astiqué", "astike"
+ ; "casait", "kazE(t)"
+ ; "cassait", "kasE(t)"
+ ; "chanci", "S@si"
+ ; "chat", "Sa(t)"
+ ; "chipant", "Sip@(t)"
+ ; "pacha", "paSa"
+ ; "péché", "peSe"
+ ; "persai", "pERse"
+ ; "asia", "azia"
+ ; "ani", "ani"
+ ; "anta", "@ta"
+ ; "plat", "pLa(t)"
+ ]
+
+let () =
+ let () = List.iter tests
+ ~f:(fun (input, expected) ->
+ repeat (Lexing.from_string input) expected)
+ in
+
+ exit !error
+