This repository has been archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestAddAff.ml
51 lines (41 loc) · 1.58 KB
/
testAddAff.ml
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
open Compilateur
open Exceptions
(* Changer le chemin d'accès du jar. *)
let runtamcmde = "java -jar ../../runtam.jar"
(* let runtamcmde = "java -jar /mnt/n7fs/.../tools/runtam/runtam.jar" *)
(* Execute the TAM code obtained from the rat file and return the ouptut of this code *)
let runtamcode cmde ratfile =
let tamcode = compiler ratfile in
let (tamfile, chan) = Filename.open_temp_file "test" ".tam" in
output_string chan tamcode;
close_out chan;
let ic = Unix.open_process_in (cmde ^ " " ^ tamfile) in
let printed = input_line ic in
close_in ic;
Sys.remove tamfile; (* à commenter si on veut étudier le code TAM. *)
String.trim printed
(* Compile and run ratfile, then print its output *)
let runtam ratfile =
print_string (runtamcode runtamcmde ratfile)
exception ErreurNonDetectee
let%expect_test "test-add-aff-int" =
runtam "../../fichiersRat/test-add-aff/test-add-aff-int.rat";
[%expect{| 7 |}]
let%expect_test "test-add-aff-rat" =
runtam "../../fichiersRat/test-add-aff/test-add-aff-rat.rat";
[%expect{| [9/2] |}]
let%expect_test "test-add-aff-reference" =
runtam "../../fichiersRat/test-add-aff/test-add-aff-reference.rat";
[%expect{| 7 |}]
let%expect_test "test-add-aff-pointeur" =
try let _ = runtam "../../fichiersRat/test-add-aff/test-add-aff-pointeur.rat"
in raise ErreurNonDetectee
with
| TypeInattendu _ -> ();
[%expect{| |}]
let%expect_test "test-add-aff-incompatible" =
try let _ = runtam "../../fichiersRat/test-add-aff/test-add-aff-incompatible.rat"
in raise ErreurNonDetectee
with
| TypeInattendu _ -> ();
[%expect{| |}]