From 9944c81b37da44274e29d3c7386d4f2ab4ce7a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <edu@thorsten-wissmann.de> Date: Thu, 11 Feb 2016 16:43:47 +0100 Subject: [PATCH] Add init function to testsuite sections Allow testcase sections to adjust the global settings before evaluating the test formulas. --- src/testsuite/cool-testsuite.ml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/testsuite/cool-testsuite.ml b/src/testsuite/cool-testsuite.ml index 6bab2be..6e92013 100644 --- a/src/testsuite/cool-testsuite.ml +++ b/src/testsuite/cool-testsuite.ml @@ -13,16 +13,17 @@ let kd = [| (CM.MultiModalKD, [0]) |] let cl = [| (CM.CoalitionLogic, [0]) |] let gml = [| (CM.GML, [0]) |] -type testcase_section = string * satCheck list +type testcase_section = string * (unit -> unit)* satCheck list let sat x = (Sat,x) let unsat x = (Unsat,x) let parseerror x = (ParseError,x) +let __ () = () -let use_functor (functors_: string) (cases: (testResult*string) list): testcase_section = +let use_functor (functors_: string) (init_globals: unit->unit) (cases: (testResult*string) list): testcase_section = let sortTable = FP.sortTableFromString functors_ in let satchecks : satCheck list = List.map (fun (a,b) -> (a,sortTable,b)) cases in - (functors_, satchecks) + (functors_, init_globals, satchecks) let k_testcases: satCheck list = let c a b = (a,k,b) in @@ -68,7 +69,7 @@ let kd_testcases = ] let cl_testcases : testcase_section = - use_functor "CL" + use_functor "CL" (fun () -> CoolUtils.cl_set_agents [|1;2;3;4;5|]) [ unsat "[{1}] C & [{ 2 }] ~C" ; sat "[{1}] C & <{ 2 }> ~C" ; unsat "[{1}] C & <{ 1 2 }> ~C" @@ -79,7 +80,7 @@ let cl_testcases : testcase_section = ] let kAndKd_testcases : testcase_section = - use_functor "K * KD" + use_functor "K * KD" __ [ sat "[pi1]True" ; sat "[pi1][R]False" ; unsat "[pi2][R]False" @@ -89,7 +90,7 @@ let kAndKd_testcases : testcase_section = ] let kAndK_testcases : testcase_section = - use_functor "K * K" + use_functor "K * K" __ [ sat "[pi1]<R>c0 | [pi1]<S>c1 | [pi2]<T>c3" ; sat "[pi1]<R>c0 | [pi1]<S>c1 | [pi2]<T>c3 | [pi1][U]c4" ] @@ -106,7 +107,7 @@ let kOrKd_testcases : satCheck list = ] let pml_testcases : testcase_section = - use_functor "PML" + use_functor "PML" __ [ sat "SKIP {>= 1/3} C & {< 1/2} D" ; sat "SKIP {>= 1/3} C & {< 1/2} C" ; unsat "SKIP {< 1/3} C & {>= 1/2} C" @@ -114,7 +115,7 @@ let pml_testcases : testcase_section = ] let testcases = - let c name table = (name,table) in + let c name table = (name,__,table) in [ c "DL98 (Sat)" DL98.satCasesList ; c "DL98 (Unsat)" DL98.unsatCasesList ; c "K" k_testcases @@ -125,7 +126,7 @@ let testcases = ; kAndK_testcases ; c "K+KD" kOrKd_testcases ; pml_testcases - ; use_functor "PML + K" + ; use_functor "PML + K" __ [ sat "(P4 + False)" ; sat "SKIP (({>= 3/5} p0 & {>= 2/5} p1) + False)" ; sat "SKIP ({>= 3/5} (False + <R1> True & <R2> True) & {>= 2/5} ({>= 1/10} p0 & {>= 1/10} (~ p0) + False ) + False)" @@ -137,12 +138,13 @@ let main = let success = ref 0 in let skipped = ref 0 in let failed = ref 0 in - foreach_l testcases (fun (name,table) -> + foreach_l testcases (fun (name,init_globals,table) -> Printf.printf "==== Testing %s ====\n" name; (* let (_,sorts,_) = List.hd table in Printf.printf "sortTable = %s\n" (FP.stringFromSortTable sorts); *) + init_globals(); foreach_l table (fun sc -> let (expected,sort,formula) = sc in if Str.string_match skipchecker formula 0 -- GitLab