Skip to content

Commit

Permalink
More testing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KabirSamsi committed Oct 27, 2024
1 parent 7b84500 commit 844e193
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
31 changes: 31 additions & 0 deletions semantics/data/test_3_output.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
30.81 7.13 9.28
30.81 7.13 9.28
18.7 48.73 14.78
18.7 48.73 14.78
12.63 11.95 36.88
12.63 11.95 36.88
12.63 11.95 36.88
12.63 11.95 36.88
12.63 11.95 36.88
12.63 11.95 36.88
12.63 11.95 36.88
12.63 11.95 36.88
5.92 12.87 13.97
10.52 36.78 7.62
10.52 36.78 7.62
8.5 48.72 12.26
0.78 0.96 9.34
0.78 0.96 9.34
0.5 4.26 44.01
10.42 25.59 36.48
8.54 23.44 22.33
8.54 23.44 22.33
8.54 23.44 22.33
8.54 23.44 22.33
8.54 23.44 22.33
8.54 23.44 22.33
8.54 23.44 22.33
8.54 23.44 22.33
8.54 23.44 22.33
10.42 25.59 36.48
10.42 25.59 36.48
36 changes: 36 additions & 0 deletions semantics/data/test_4_output.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
46.21 2.72 22.35
No packet
23.45 28.16 38.02
3.41 11.8 21.25
5.33 34.92 26.18
23.45 28.16 38.02
5.33 34.92 26.18
23.45 28.16 38.02
5.24 46.15 39.06
14.4 7.49 42.33
5.33 34.92 26.18
14.4 7.49 42.33
5.33 34.92 26.18
14.4 7.49 42.33
5.33 34.92 26.18
14.4 7.49 42.33
5.33 34.92 26.18
41.55 2.97 27.23
9.8 25.24 28.65
14.4 7.49 42.33
9.8 25.24 28.65
12.73 16.11 39.54
9.8 25.24 28.65
35.75 13.83 44.56
9.8 25.24 28.65
41.55 2.97 27.23
9.8 25.24 28.65
3.97 1.9 36.15
9.8 25.24 28.65
41.55 2.97 27.23
9.8 25.24 28.65
41.55 2.97 27.23
9.8 25.24 28.65
41.55 2.97 27.23
2.74 47.02 16.67

12 changes: 8 additions & 4 deletions semantics/test/test_semantics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module TestGenerator = struct
in
read_lines []
|> List.map (String.split_on_char ' ')
|> List.filter (fun x -> List.length x = 5)
|> List.map parse_to_query
end

Expand Down Expand Up @@ -86,7 +87,7 @@ struct
^ string_of_float (Pkt.time p)
^ " "
^ string_of_float (Pkt.weight p)
^ "\n")
^ "\n" ^ acc)
results "");
close_out oc

Expand All @@ -95,10 +96,10 @@ struct
let rec aux (p, qs) = function
| [] -> []
| (cmd, p1, p2, p3, i) :: t ->
if cmd = 1 then
if cmd = 0 then
(* Command = 1 => push with packet and qs[i] *)
aux (S.push ((p1, p2, p3), List.nth qs i, (p, qs))) t
else if cmd = 0 then
else if cmd = 1 then
(* Command = 0 => pop *)
let popped, new_state = S.pop (p, qs) in
popped :: aux new_state t
Expand Down Expand Up @@ -314,4 +315,7 @@ let () =
TestGenerator.gen_tests 7 "data/test_7_classes.data" 100;
TestGenerator.gen_tests 8 "data/test_8_classes.data" 100;
TestGenerator.gen_tests 9 "data/test_9_classes.data" 100;
TestGenerator.gen_tests 10 "data/test_10_classes.data" 100
TestGenerator.gen_tests 10 "data/test_10_classes.data" 100;
"data/test_4_classes.data" |> TestGenerator.load_queries
|> Tester.simulate (List.hd Tester.four_classes)
|> Tester.write_results "data/test_4_output.data"

0 comments on commit 844e193

Please sign in to comment.