Skip to content

Commit

Permalink
Fixed test functors
Browse files Browse the repository at this point in the history
  • Loading branch information
KabirSamsi committed Oct 26, 2024
1 parent c7bfde9 commit 7b84500
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 55 deletions.
16 changes: 14 additions & 2 deletions semantics/lib/packet.ml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
(** A signature for packets. *)

module type Packet = sig
(* A type for packets *)
type t

(* An ordered type *)
type ord

val compare : ord -> ord -> int

(* rank pkt is the rank of pkt *)
val rank : t -> ord

(* time pkt is the pop deadline of pkt *)
val time : t -> ord

(* weight pkt is the weight pkt *)
val weight : t -> ord
end

(* An implementation for packets (see MLI) *)
module PacketImpl : Packet = struct
(* An implementation for packets *)
module PacketImpl :
Packet with type t = float * float * float and type ord = float = struct
type t = float * float * float
type ord = float

Expand Down
20 changes: 0 additions & 20 deletions semantics/lib/packet.mli

This file was deleted.

17 changes: 17 additions & 0 deletions semantics/lib/queue.ml
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
open Packet

(** A signature for queues. *)

module type Queue = sig
type elt

(* An abstract type for a queue with elements of type elt *)
type t

(* empty is the empty queue *)
val empty : t

(* push pushes the latest element (with some rank) into the queue *)
val push : elt * t -> t

(* pop qs returns the highest-priority element (if there is one) and modified queue *)
val pop : t -> elt option * t

(* pop qs removes the specified element from qs *)
val remove : elt option -> t -> t

(* update qs q q' is qs[q'/q] *)
val update : t -> t -> t list -> t list

(* flush q returns all elements enqeued in q. *)
val flush : t -> elt list

(* from_list elems returns a queue containing all elements enqueued in priority order *)
val from_list : elt list -> t
end

Expand Down
29 changes: 0 additions & 29 deletions semantics/lib/queue.mli

This file was deleted.

11 changes: 7 additions & 4 deletions semantics/test/test_semantics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ end

(** A functor for testing semantics with packet and queue modules *)
module SemanticsTester
(Pkt : RioSemantics.Packet.Packet
(Pkt : Packet.Packet
with type t = float * float * float
and type ord = float)
(Q : RioSemantics.Queue.Queue with type elt = Pkt.t) =
(Q : Queue.Queue with type elt = Pkt.t) =
struct
include RioSemantics.Program.Program
module S = RioSemantics.Semantics.Semantics (Pkt) (Q)
include Program.Program
module S = Semantics.Semantics (Pkt) (Q)

exception QueryFormatException

Expand Down Expand Up @@ -303,6 +303,9 @@ struct
]
end

module Tester =
SemanticsTester (Packet.PacketImpl) (Queue.QueueImpl (Packet.PacketImpl))

let () =
TestGenerator.gen_tests 3 "data/test_3_classes.data" 100;
TestGenerator.gen_tests 4 "data/test_4_classes.data" 100;
Expand Down

0 comments on commit 7b84500

Please sign in to comment.