+<test>
- <!-- general purpose -->
+ <!-- general purpose -->
-<help />
+ <help />
-<usage>usage string</usage>
+ <usage>usage string</usage>
-<exception name='eccezione1'>corpo dell'exc</exception>
+ <exception name='eccezione1'>corpo dell'exc</exception>
- <!-- client -> broker -->
+ <!-- client -> broker -->
-<register_client id='client_id' url='client_url' />
+ <register_client id='client_id' url='client_url' />
-<unregister_client id='client_id' />
+ <unregister_client id='client_id' />
-<list_tutors id='client_id' />
+ <list_tutors id='client_id' />
-<subscribe id='client_id'>
- <tutor id='tutor_id1' />
- <tutor id='tutor_id2' />
- <!-- .... -->
- <tutor id='tutor_idN' />
-</subscribe>
+ <subscribe id='client_id'>
+ <tutor id='tutor_id1' />
+ <tutor id='tutor_id2' />
+ <!-- .... -->
+ <tutor id='tutor_idN' />
+ </subscribe>
-<state_change id='client_id'>
- <!-- STATO -->
-</state_change>
+ <state_change id='client_id'> <!-- new state received -->
+ <gTopLevelStatus>
+ <CurrentGoal>0</CurrentGoal>
+ <ConstantType>
+ </ConstantType>
+ <CurrentProof>
+ </CurrentProof>
+ </gTopLevelStatus>
+ </state_change>
- <!-- tutor -> broker -->
+ <state_change id='client_id'> <!-- no state received: proof is completed -->
+ <gTopLevelStatus />
+ </state_change>
-<register_tutor id='tutor_id' url='tutor_url'>
- <hint_type>
- <!-- HINT TYPE -->
- </hint_type>
- <description>
- descrizione del tutor
- </description>
-</register_tutor>
+ <wow id="client_id" />
-<unregister_tutor id='tutor_id' />
+ <!-- tutor -> broker -->
-<musing_started id='tutor_id' musing_id='musing_id' />
+ <register_tutor id='tutor_id' url='tutor_url'>
+ <hint_type>
+ <!-- HINT TYPE -->
+ </hint_type>
+ <description>
+ descrizione del tutor
+ </description>
+ </register_tutor>
-<musing_completed id='tutor_id' musing_id='musing_id'>
- <!-- either -->
- <sorry />
+ <unregister_tutor id='tutor_id' />
- <!-- or -->
- <eureka> extras </eureka>
-</musing_completed>
+ <musing_started id='tutor_id' musing_id='musing_id' />
- <!-- broker -> client -->
+ <musing_aborted id='tutor_id' musing_id='musing_id' />
-<client_registered id='broker_id' />
+ <musing_completed id='tutor_id' musing_id='musing_id'>
+ <sorry />
+ </musing_completed>
-<client_unregistered id='broker_id' />
+ <musing_completed id='tutor_id' musing_id='musing_id'>
+ <eureka>
+ <ring />
+ </eureka>
+ </musing_completed>
-<tutor_list id='broker_id'>
- <tutor_dsc id='tutor_id1'> description 1 </tutor_dsc>
- <tutor_dsc id='tutor_id2'> description 2 </tutor_dsc>
- <!-- ... -->
- <tutor_dsc id='tutor_idN'> description N </tutor_dsc>
-</tutor_list>
+ <musing_completed id='tutor_id' musing_id='musing_id'>
+ <eureka>
+ <hints>
+ <ring />
+ <fourier />
+ </hints>
+ </eureka>
+ </musing_completed>
-<subscribed id='broker_id'>
- <tutor_dsc id='tutor_id1'> description 1 </tutor_dsc>
- <tutor_dsc id='tutor_id2'> description 2 </tutor_dsc>
- <!-- ... -->
- <tutor_dsc id='tutor_idN'> description N </tutor_dsc>
-</subscribed>
+ <!-- broker -> client -->
-<state_accepted id='broker_id'>
- <stopped>
- <musing id='musing_id1' />
- <!-- ... -->
- <musing id='musing_idN' />
- </stopped>
- <started>
- <musing id='musing_id1' />
- <!-- ... -->
- <musing id='musing_idM' />
- </started>
-</state_accepted>
-
-<hint id='broker_id'>
- <!-- HINT parsata a seconda dell'hint type del tutor -->
-</hint>
-
- <!-- broker -> tutor -->
-
-<tutor_registered id='broker_id' />
+ <client_registered id='broker_id' />
-<tutor_unregistered id='broker_id' />
+ <client_unregistered id='broker_id' />
-<start_musing id='broker_id'>
- <!-- STATE -->
-</start_musing>
-
-<thanks id='broker_id' musing_id='musing_id' />
-
-<abort_musing id='broker_id' musing_id='musing_id' />
+ <tutor_list id='broker_id'>
+ <tutor_dsc id='tutor_id1'> description 1 </tutor_dsc>
+ <tutor_dsc id='tutor_id2'> description 2 </tutor_dsc>
+ <!-- ... -->
+ <tutor_dsc id='tutor_idN'> description N </tutor_dsc>
+ </tutor_list>
+ <subscribed id='broker_id'>
+ <tutor_dsc id='tutor_id1'> description 1 </tutor_dsc>
+ <tutor_dsc id='tutor_id2'> description 2 </tutor_dsc>
+ <!-- ... -->
+ <tutor_dsc id='tutor_idN'> description N </tutor_dsc>
+ </subscribed>
+
+ <state_accepted id='broker_id'>
+ <stopped>
+ <musing id='musing_id1' />
+ <!-- ... -->
+ <musing id='musing_idN' />
+ </stopped>
+ <started>
+ <musing id='musing_id1' />
+ <!-- ... -->
+ <musing id='musing_idM' />
+ </started>
+ </state_accepted>
+
+ <hint id='broker_id'>
+ <ring />
+ </hint>
+
+ <hint id='broker_id'>
+ <hints>
+ <ring />
+ <fourier />
+ </hints>
+ </hint>
+
+ <!-- broker -> tutor -->
+
+ <tutor_registered id='broker_id' />
+
+ <tutor_unregistered id='broker_id' />
+
+ <start_musing id='broker_id'>
+ <gTopLevelStatus>
+ <CurrentGoal>0</CurrentGoal>
+ <ConstantType>
+ </ConstantType>
+ <CurrentProof>
+ </CurrentProof>
+ </gTopLevelStatus>
+ </start_musing>
+
+ <abort_musing id='broker_id' musing_id='musing_id' />
+
+ <thanks id='broker_id' musing_id='musing_id' />
+
+ <too_late id='broker_id' musing_id='musing_id' />
+
+</test>
* http://helm.cs.unibo.it/
*)
-(* test serialization/deserialization of Hbugs_messages module. File given as
-cmd line argument is read line by line, each line is expected to contain a
-Hbugs_types.message that is parsed, pretty printed and parsed again to check for
-serialization consistency *)
+open Pxp_document;;
+open Pxp_dtd;;
+open Pxp_types;;
+open Pxp_yacc;;
+
open Printf;;
-let fname = Sys.argv.(1) in
-let ic = open_in fname in
-let lineno = ref 1 in
-try
- while true do
- let line = input_line ic in
- let msg = Hbugs_messages.msg_of_string line in
+
+let test_data = "HBUGS_MESSAGES.xml" ;;
+
+let test_message (n:('a Pxp_document.extension as 'b) Pxp_document.node as 'a) =
+ try
+ let msg_string =
+ let buf = Buffer.create 1000 in
+ n#write (`Out_buffer buf) `Enc_utf8;
+ Buffer.contents buf
+ in
+ let msg = Hbugs_messages.msg_of_string msg_string in
let pp = Hbugs_messages.string_of_msg msg in
let msg' = Hbugs_messages.msg_of_string pp in
- assert (msg = msg');
- incr lineno
- done
-with
-| End_of_file -> prerr_endline "All done!"
-| exc ->
+ if (msg <> msg') then
+ prerr_endline
+ (sprintf "Failure with msg %s"
+ (match n#node_type with T_element name -> name | _ -> assert false))
+ with e ->
prerr_endline
- (sprintf "Failure at line %d: %s" !lineno (Printexc.to_string exc))
+ (sprintf "Failure with msg %s: uncaught exception %s"
+ (match n#node_type with T_element name -> name | _ -> assert false)
+ (Printexc.to_string e))
+;;
+
+let is_xml_element n =
+ match n#node_type with T_element _ -> true | _ -> false
+;;
+
+let root =
+ parse_wfcontent_entity default_config (from_file test_data) default_spec
+in
+printf "Testing all messages from %s ...\n" test_data; flush stdout;
+List.iter test_message (List.filter is_xml_element root#sub_nodes);
+printf "Done!\n"
+;;
+