test/Tools/isac/ADDTESTS/libisabelle/protocol.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Wed, 05 Oct 2016 13:09:54 +0200
changeset 59248 5eba5e6d5266
parent 59176 8532cda27fbf
child 59261 61a1bcd51e0e
permissions -rw-r--r--
cleaned tests from autoCalculate' (removed ')

Notes
(1) autoCalculate' made Test_Some.thy complicated (had to be redefined)
(2) "fun autoCalculate'" was scattered over several tests -- probably due to (1)
(3) autoCalculate' has been put out of service in 5127be395ea1
(4) M.Lehnfeld finished his work with 8e3f73e1e3a3:
fun autoCalculate (cI:calcID) auto = Future.fork ... in isac/../interface.sml
wneuper@59175
     1
(* Title:  tests for libisabelle/libisabelle/src/main/isabelle/Protocol/Protocol.thy
wneuper@59175
     2
   Author: Walther Neuper 2015
wneuper@59175
     3
   (c) due to copyright terms
wneuper@59175
     4
wneuper@59175
     5
theory Test_Some imports Build_Thydata begin 
wneuper@59175
     6
ML {* KEStore_Elems.set_ref_thy @{theory};
wneuper@59175
     7
  fun autoCalculate' cI auto = autoCalculate cI auto (*|> Future.join*) *}
wneuper@59176
     8
ML_file "~~/test/Tools/isac/ADDTESTS/libisabelle/protocol.sml"
wneuper@59175
     9
*)
wneuper@59175
    10
wneuper@59175
    11
(* NOTE: Protocol.thy still belongs to a different development at
wneuper@59175
    12
     https://github.com/wneuper/libisabelle
wneuper@59175
    13
but Protocol.thy is enclosed in isabisac for testing synchronisation, 
wneuper@59175
    14
see Build_Isac.thy *)
wneuper@59175
    15
wneuper@59175
    16
"-----------------------------------------------------------------------------";
wneuper@59175
    17
"table of contents -----------------------------------------------------------";
wneuper@59175
    18
"-----------------------------------------------------------------------------";
wneuper@59175
    19
"----------- fun initContext, fun initcontext_pbl, fun initcontext_met -------";
wneuper@59175
    20
"-----------------------------------------------------------------------------";
wneuper@59175
    21
"-----------------------------------------------------------------------------";
wneuper@59175
    22
"-----------------------------------------------------------------------------";
wneuper@59175
    23
wneuper@59175
    24
"----------- fun initContext, fun initcontext_pbl, fun initcontext_met -------";
wneuper@59175
    25
"----------- fun initContext, fun initcontext_pbl, fun initcontext_met -------";
wneuper@59175
    26
"----------- fun initContext initcontext_pbl initcontext_met -----------------";
wneuper@59175
    27
(* compare isac-java/src/java-tests/isac/bridge/TestContext#testContext *)
wneuper@59175
    28
reset_states ();
wneuper@59175
    29
CalcTree [(["equality (x + 1 = (2::real))", "solveFor x", "solutions L"],
wneuper@59175
    30
  ("Test",["sqroot-test","univariate","equation","test"],["Test","squ-equ-test-subpbl1"]))];
wneuper@59175
    31
moveActiveRoot 1;
wneuper@59248
    32
autoCalculate 1 CompleteCalc;
wneuper@59175
    33
wneuper@59175
    34
(*-->ISA: initContext 1 Thy_ ([1],Frm);  *)
wneuper@59175
    35
val out = initContext 1 Thy_ ([1],Frm);
wneuper@59175
    36
if cut_xml out 105 = 
wneuper@59175
    37
"(CONTEXTTHY)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . thy_isac_Test-rls-norm_equation"
wneuper@59175
    38
then () else error "initContext 1 Thy_ ([1],Frm); CHANGED";
wneuper@59175
    39
wneuper@59175
    40
(*-->ISA: initContext 1 Thy_ ([1],Res);  *)
wneuper@59175
    41
val out = initContext 1 Thy_ ([1],Res);
wneuper@59175
    42
if cut_xml out 105 = 
wneuper@59175
    43
"(CONTEXTTHY)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . thy_isac_Test-rls-Test_simplify"
wneuper@59175
    44
then () else error "initContext 1 Thy_ ([1],Res); CHANGED";
wneuper@59175
    45
wneuper@59175
    46
val ((pt, _), _) = get_calc 1;
wneuper@59175
    47
wneuper@59175
    48
(*-->ISA: initContext 1 Pbl_ ([1],Res);  *)
wneuper@59175
    49
val (p, p_) = ([1], Res)
wneuper@59175
    50
val pp = par_pblobj pt p
wneuper@59175
    51
val chd = initcontext_pbl pt (pp,p_)
wneuper@59175
    52
val out = contextpblOK2xml 1 chd;
wneuper@59175
    53
if cut_xml out 100 = "(CONTEXTPBL)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . pbl_test_uni_roottest\n. . "
wneuper@59175
    54
then () else error "initContext 1 Pbl_ ([1],Res); CHANGED";
wneuper@59175
    55
wneuper@59175
    56
(*-->ISA: initContext 1 Pbl_ ([3,1],Res); *)
wneuper@59175
    57
val (p, p_) = ([3, 1], Res)
wneuper@59175
    58
val pp = par_pblobj pt p
wneuper@59175
    59
val chd = initcontext_pbl pt (pp,p_)
wneuper@59175
    60
val out = contextpblOK2xml 1 chd;
wneuper@59175
    61
if cut_xml out 90 = 
wneuper@59175
    62
"(CONTEXTPBL)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . pbl_test_uni_lin"
wneuper@59175
    63
then () else error "initContext 1 Pbl_ ([3,1],Res); CHANGED";
wneuper@59175
    64
wneuper@59175
    65
(*-->ISA: initContext 1 Met_ ([1],Res); *)
wneuper@59175
    66
val (p, p_) = ([1], Res)
wneuper@59175
    67
(*interface.sml*)val pp = par_pblobj pt p
wneuper@59175
    68
(*interface.sml*)val chd = initcontext_met pt (pp, p_);
wneuper@59175
    69
val out = contextmetOK2xml 1 chd; (*ERROR was pblID2guh: not for '[Test,squ-equ-test-subpbl1]'*)
wneuper@59175
    70
"~~~~~ fun contextmetOK2xml, args:"; val (calcid, contmet) = (1, chd);
wneuper@59175
    71
"~~~~~ fun xml_of_matchmet, args:"; val (model_ok, pI, scr, pbl, pre) = (contmet);
wneuper@59175
    72
if metID2guh pI = 
wneuper@59175
    73
"met_test_squ_sub" then () else error "xml_of_matchmet CHANGED";
wneuper@59175
    74
if cut_xml out 90 = "(CONTEXTMET)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . met_test_squ_sub"
wneuper@59175
    75
then () else error "initContext 1 Met_ ([1],Res); CHANGED";
wneuper@59175
    76
wneuper@59175
    77
(*-->ISA: initContext 1 Met_ ([3,1],Res); *)
wneuper@59175
    78
val (p, p_) = ([3,1],Res)
wneuper@59175
    79
(*interface.sml*)val pp = par_pblobj pt p
wneuper@59175
    80
(*interface.sml*)val chd = initcontext_met pt (pp, p_);
wneuper@59175
    81
val out = contextmetOK2xml 1 chd;
wneuper@59175
    82
if cut_xml out 91 = "(CONTEXTMET)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . met_test_solvelin"
wneuper@59175
    83
then () else error "initContext 1 Met_ ([3,1],Res); CHANGED";
wneuper@59175
    84
"~~~~~ fun operation_setup init_ctxt, args:"; val (intree) = 
wneuper@59175
    85
  XML.Elem (("INITCONTEXT", []), [
wneuper@59175
    86
    XML.Elem (("CALCID", []), [XML.Text "1"]),
wneuper@59175
    87
    XML.Elem (("KETYPE", []), [XML.Text "met"]),
wneuper@59175
    88
    XML.Elem (("POSITION", []), [
wneuper@59175
    89
      XML.Elem (("INTLIST", []), [
wneuper@59175
    90
        XML.Elem (("INT", []), [XML.Text "3"]),
wneuper@59175
    91
        XML.Elem (("INT", []), [XML.Text "1"])]),
wneuper@59175
    92
      XML.Elem (("POS", []), [XML.Text "Res"])])])
wneuper@59175
    93
fun xxxxx () = (fn intree => 
wneuper@59175
    94
	 ((let 
wneuper@59175
    95
	   val (ci, ketype, pos) = case intree of
wneuper@59175
    96
       XML.Elem (("INITCONTEXT", []), [
wneuper@59175
    97
         XML.Elem (("CALCID", []), [XML.Text ci]),
wneuper@59175
    98
         ketype as XML.Elem (("KETYPE", []), _),
wneuper@59175
    99
         pos as XML.Elem (("POSITION", []), _)]) 
wneuper@59175
   100
     => (str2int ci, xml_to_ketype ketype, xml_to_pos pos)
wneuper@59175
   101
     | tree => raise ERROR ("init_ctxt: WRONG intree = " ^ xmlstr 0 tree)
wneuper@59175
   102
     val result = Math_Engine.initContext ci ketype pos
wneuper@59175
   103
	 in result end)
wneuper@59175
   104
	 handle ERROR msg => sysERROR2xml 4711 msg)
wneuper@59175
   105
	   handle _  => sysERROR2xml 4711 "Protocol.operation_setup init_ctxt UNKNOWN exn")
wneuper@59175
   106
val out = xxxxx () intree;
wneuper@59175
   107
if cut_xml out 91 = "(CONTEXTMET)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . met_test_solvelin"
wneuper@59175
   108
then () else error "operation_setup initContext 1 Met_ ([3,1],Res); CHANGED";
wneuper@59175
   109