From 7b845005ad286ad14b958122bda724444c80cbb0 Mon Sep 17 00:00:00 2001 From: Kabir Samsi Date: Sat, 26 Oct 2024 18:19:00 -0400 Subject: [PATCH] Fixed test functors --- semantics/lib/packet.ml | 16 ++++++++++++++-- semantics/lib/packet.mli | 20 -------------------- semantics/lib/queue.ml | 17 +++++++++++++++++ semantics/lib/queue.mli | 29 ----------------------------- semantics/test/test_semantics.ml | 11 +++++++---- 5 files changed, 38 insertions(+), 55 deletions(-) delete mode 100644 semantics/lib/packet.mli delete mode 100644 semantics/lib/queue.mli diff --git a/semantics/lib/packet.ml b/semantics/lib/packet.ml index 7c059b1..bd63201 100644 --- a/semantics/lib/packet.ml +++ b/semantics/lib/packet.ml @@ -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 diff --git a/semantics/lib/packet.mli b/semantics/lib/packet.mli deleted file mode 100644 index b854747..0000000 --- a/semantics/lib/packet.mli +++ /dev/null @@ -1,20 +0,0 @@ -(** 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 diff --git a/semantics/lib/queue.ml b/semantics/lib/queue.ml index de5099f..07fd981 100644 --- a/semantics/lib/queue.ml +++ b/semantics/lib/queue.ml @@ -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 diff --git a/semantics/lib/queue.mli b/semantics/lib/queue.mli deleted file mode 100644 index 34b7e3e..0000000 --- a/semantics/lib/queue.mli +++ /dev/null @@ -1,29 +0,0 @@ -(** 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 diff --git a/semantics/test/test_semantics.ml b/semantics/test/test_semantics.ml index 84b1361..ca084ec 100644 --- a/semantics/test/test_semantics.ml +++ b/semantics/test/test_semantics.ml @@ -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 @@ -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;