src/Pure/ProofGeneral/pgip_tests.ML
changeset 26541 14b268974c4b
parent 25275 76d7f3fd4fb3
child 28020 1ff5167592ba
equal deleted inserted replaced
26540:173d548ce9d2 26541:14b268974c4b
    12 fun asseq_p toS a b =
    12 fun asseq_p toS a b =
    13     if a=b then ()
    13     if a=b then ()
    14     else error("PGIP test: expected these two values to be equal:\n" ^
    14     else error("PGIP test: expected these two values to be equal:\n" ^
    15 	       (toS a) ^"\n and: \n" ^ (toS b))
    15 	       (toS a) ^"\n and: \n" ^ (toS b))
    16 
    16 
    17 val asseqx = asseq_p XML.string_of_tree
    17 val asseqx = asseq_p XML.string_of
    18 val asseqs = asseq_p I
    18 val asseqs = asseq_p I
    19 val asseqb = asseq_p (fn b=>if b then "true" else "false")
    19 val asseqb = asseq_p (fn b=>if b then "true" else "false")
    20 
       
    21 val p = XML.tree_of_string (* parse *)
       
    22 
    20 
    23 open PgipTypes;
    21 open PgipTypes;
    24 in
    22 in
    25 
    23 
    26 val _ = asseqx (pgiptype_to_xml Pgipnull) (p "<pgipnull/>");
    24 val _ = asseqx (pgiptype_to_xml Pgipnull) (XML.parse "<pgipnull/>");
    27 val _ = asseqx (pgiptype_to_xml Pgipbool) (p "<pgipbool/>");
    25 val _ = asseqx (pgiptype_to_xml Pgipbool) (XML.parse "<pgipbool/>");
    28 val _ = asseqx (pgiptype_to_xml (Pgipint (NONE,NONE))) (p "<pgipint/>");
    26 val _ = asseqx (pgiptype_to_xml (Pgipint (NONE,NONE))) (XML.parse "<pgipint/>");
    29 val _ = asseqx (pgiptype_to_xml (Pgipint (SOME 5,SOME 7))) (p "<pgipint min='5' max='7'/>");
    27 val _ = asseqx (pgiptype_to_xml (Pgipint (SOME 5,SOME 7))) (XML.parse "<pgipint min='5' max='7'/>");
    30 val _ = asseqx (pgiptype_to_xml (Pgipint (NONE,SOME 7))) (p "<pgipint max='7'/>");
    28 val _ = asseqx (pgiptype_to_xml (Pgipint (NONE,SOME 7))) (XML.parse "<pgipint max='7'/>");
    31 val _ = asseqx (pgiptype_to_xml (Pgipint (SOME ~5,NONE))) (p "<pgipint min='-5'/>");
    29 val _ = asseqx (pgiptype_to_xml (Pgipint (SOME ~5,NONE))) (XML.parse "<pgipint min='-5'/>");
    32 val _ = asseqx (pgiptype_to_xml Pgipstring) (p "<pgipstring/>");
    30 val _ = asseqx (pgiptype_to_xml Pgipstring) (XML.parse "<pgipstring/>");
    33 val _ = asseqx (pgiptype_to_xml (Pgipconst "radio1"))  (p "<pgipconst name='radio1'/>");
    31 val _ = asseqx (pgiptype_to_xml (Pgipconst "radio1"))  (XML.parse "<pgipconst name='radio1'/>");
    34 val _ = asseqx (pgiptype_to_xml (Pgipchoice [Pgipdtype (SOME "the best choice",Pgipbool)]))
    32 val _ = asseqx (pgiptype_to_xml (Pgipchoice [Pgipdtype (SOME "the best choice",Pgipbool)]))
    35        (p "<pgipchoice><pgipbool descr='the best choice'/></pgipchoice>");
    33        (XML.parse "<pgipchoice><pgipbool descr='the best choice'/></pgipchoice>");
    36 
    34 
    37 val _ = asseqs (pgval_to_string (read_pgval Pgipbool "true")) "true";
    35 val _ = asseqs (pgval_to_string (read_pgval Pgipbool "true")) "true";
    38 val _ = asseqs (pgval_to_string (read_pgval Pgipbool "false")) "false";
    36 val _ = asseqs (pgval_to_string (read_pgval Pgipbool "false")) "false";
    39 val _ = asseqs (pgval_to_string (read_pgval (Pgipint(NONE,NONE)) "-37")) "-37";
    37 val _ = asseqs (pgval_to_string (read_pgval (Pgipint(NONE,NONE)) "-37")) "-37";
    40 val _ = asseqs (pgval_to_string (read_pgval Pgipnat "45")) "45";
    38 val _ = asseqs (pgval_to_string (read_pgval Pgipnat "45")) "45";
    52 	 error "pgip_tests: should fail") handle PGIP _ => ()
    50 	 error "pgip_tests: should fail") handle PGIP _ => ()
    53 end
    51 end
    54 
    52 
    55 val _ = asseqx (haspref {name="provewithgusto",descr=SOME "use energetic proofs",
    53 val _ = asseqx (haspref {name="provewithgusto",descr=SOME "use energetic proofs",
    56 		 default=SOME "true", pgiptype=Pgipbool})
    54 		 default=SOME "true", pgiptype=Pgipbool})
    57        (p "<haspref name='provewithgusto' descr='use energetic proofs' default='true'><pgipbool/></haspref>");
    55        (XML.parse "<haspref name='provewithgusto' descr='use energetic proofs' default='true'><pgipbool/></haspref>");
    58 end
    56 end
    59 
    57 
    60 
    58 
    61 (** pgip_input.ML **)
    59 (** pgip_input.ML **)
    62 local
    60 local
    63 
    61 
    64 val p = XML.tree_of_string (* parse *)
    62 fun e str = case XML.parse str of 
    65 
       
    66 fun e str = case p str of 
       
    67 		(XML.Elem args) => args
    63 		(XML.Elem args) => args
    68 	      | _ => error("Expected to get an XML Element")
    64 	      | _ => error("Expected to get an XML Element")
    69 
    65 
    70 open PgipInput;
    66 open PgipInput;
    71 open PgipTypes;
    67 open PgipTypes;