From 2e706111f7aa832fa3314ceafd2e749ba92bd46a Mon Sep 17 00:00:00 2001 From: Cassandra Sziklai Date: Fri, 9 Aug 2024 11:04:52 -0400 Subject: [PATCH] add new test case --- dsl/lib/policy.ml | 5 +++-- dsl/test/well_formed.ml | 2 ++ progs/incorrect/duplicate_samepol.sched | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 progs/incorrect/duplicate_samepol.sched diff --git a/dsl/lib/policy.ml b/dsl/lib/policy.ml index 39a7e00..995682c 100644 --- a/dsl/lib/policy.ml +++ b/dsl/lib/policy.ml @@ -53,8 +53,9 @@ let rec eval cl st (used : string list ref) p = TokenBucket (eval_plst cl st used plst, n1, n2) | Ast.StopAndGo (plst, n) -> StopAndGo (eval_plst cl st used plst, n) -(* Evaluates a program, looking up any variables and substituting them in. *) -let from_program (cl, alst, ret) = eval cl alst (ref []) ret +(* Evaluates a program, looking up any variables and substituting them in. It returns + the final policy with any variables substituted in. *) +let from_program (cl, alst, ret) : t = eval cl alst (ref []) ret let rec to_string p = let bracket_wrap s = "[" ^ s ^ "]" in diff --git a/dsl/test/well_formed.ml b/dsl/test/well_formed.ml index 5a5645c..0807e1f 100644 --- a/dsl/test/well_formed.ml +++ b/dsl/test/well_formed.ml @@ -62,6 +62,8 @@ let error_tests = "incorrect/unbound_var_hier.sched" (Policy.UnboundVariable "r_polic"); make_error_test "class used twice in policy" "incorrect/duplicate_classes.sched" (Policy.DuplicateClass "B"); + make_error_test "class used twice in one fifo" + "incorrect/duplicate_samepol.sched" (Policy.DuplicateClass "A"); ] let suite = "suite" >::: tests @ error_tests diff --git a/progs/incorrect/duplicate_samepol.sched b/progs/incorrect/duplicate_samepol.sched new file mode 100644 index 0000000..8c0f3d7 --- /dev/null +++ b/progs/incorrect/duplicate_samepol.sched @@ -0,0 +1,5 @@ +classes A, B; + +x = fifo[A, A]; + +return x \ No newline at end of file