1 (* Title: tests for sml/xmlsrc/pbl-met-hierarchy.sml
2 Author: Walther Neuper 060209
5 use"../smltest/xmlsrc/pbl-met-hierarchy.sml";
6 use"pbl-met-hierarchy.sml";
8 CAUTION with testing *2file functions -- they are actually writing !!!
11 val thy = @{theory "Isac_Knowledge"};
13 "-----------------------------------------------------------------";
14 "table of contents -----------------------------------------------";
15 "-----------------------------------------------------------------";
16 "----- pbl2xml ---------------------------------------------------";
17 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
18 "----- fun pbl2term ----------------------------------------------";
19 "----- fun insert_errpats ----------------------------------------";
20 "-----------------------------------------------------------------";
21 "-----------------------------------------------------------------";
22 "-----------------------------------------------------------------";
26 "----- pbl2xml ---------------------------------------------------";
27 "----- pbl2xml ---------------------------------------------------";
28 "----- pbl2xml ---------------------------------------------------";
29 (*what to do if from 'pbls2file "../../xmldata/pbl/";' you get the error
31 ### pbl2file: id = ["Biegelinie"]
32 *** Type unification failed: Clash of types "fun" and "Program.ID".
33 *** Type error in application: Incompatible operand type.
35 *** Operator: Problem :: ID * ID list => ??'a
36 *** Operand: (Biegelinie, [Biegelinie]) ::
37 *** ((real => real) => una) * ((real => real) => una) list
39 Exception- OPTION raised
42 if Pbl_Met_Hierarchy.pbl2xml ["Biegelinien"] (Problem.from_store ["Biegelinien"]) =
44 " <GUH> pbl_bieg </GUH>\n"^
46 " <STRING> Biegelinien </STRING>\n"^
47 " </STRINGLIST>\n <META> </META>\n"^
50 " <ISA> Problem (Biegelinie', [Biegelinien]) </ISA>\n"^
56 " <ISA> Traegerlaenge l_l </ISA>\n"^
59 " <ISA> Streckenlast q_q </ISA>\n"^
60 " </MATHML> </GIVEN>\n <WHERE> </WHERE>\n"^
63 " <ISA> Biegelinie b_b </ISA>\n"^
64 " </MATHML> </FIND>\n"^
67 " <ISA> Randbedingungen r_b </ISA>\n"^
68 " </MATHML> </RELATE>\n"^
70 " <EXPLANATIONS> </EXPLANATIONS>\n"^
73 " <TAG> Theorem </TAG>\n"^
75 " <GUH> thy_isac_Biegelinie-thm- </GUH>\n"^
81 " <TAG> MethodC</TAG>\n"^
82 " <ID> [IntegrierenUndKonstanteBestimmen2] </ID>\n"^
83 " <GUH> met_biege_2 </GUH>\n"^
87 " <EVALPRECOND> empty </EVALPRECOND>\n"^
91 " <STRING> isac team 2006 </STRING>\n"^
92 " </COURSEDESIGNS>\n"^
94 then () else error "fun pbl2xml 'Biegelinien' changed";
96 (* val id = ["Biegelinie"];
97 val {(*guh,*)cas,met,ppc,prls,thy,where_} = Problem.from_store ["Biegelinie"];
98 AND STEP THROUGH pbl2xml ...
100 term2xml i (pbl2term thy id);
103 (* val (thy, pblRD) = (thy, id);
104 AND STEP THROUGH pbl2term...
106 val str = ("Problem (" ^
107 (get_thy o theory2domID) thy ^ ", " ^
108 (strs2str' o rev) pblRD ^ ")");
110 str2term "Biegelinie";
111 str2term "Biegelinien";
114 ("Biegelinie.Biegelinie",
115 "("Real.real => "Real.real) => Tools.una") : Term.term
116 ..I.E. THE "Program.ID" _WAS_ ALREADY OCCUPIED BY A 'description'*)
119 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
120 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
121 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
123 "~~~~~ fun pbls2file, args:"; val (p: Pbl_Met_Hierarchy.filepath) = (path ^ "pbl/");
124 get_ptyps (); (*not = []*)
125 "~~~~~ fun nodes, args:"; val (pa, ids, po, wfn, (n::ns)) =
126 (p, []: string list, [0], Pbl_Met_Hierarchy.pbl2file, (get_ptyps ()));
127 "~~~~~ fun node, args:"; val (pa: Pbl_Met_Hierarchy.filepath, ids, po, wfn, Store.Node (id,[n],ns)) = (pa, ids, po, wfn, n);
130 "~~~~~ fun pbl2file, args:"; val ((path:Pbl_Met_Hierarchy.filepath), (pos:pos), (id: MethodC.id), (pbl as {guh,...})) =
131 (pa, po', (ids@[id]), n);
132 strs2str id = "[\"e_pblID\"]"; (*true*)
133 pos2str pos = "[1]"; (*true*)
134 path ^ Thy_Present.guh2filename guh = "/tmp/pbl/pbl_empty.xml"; (*true*)
135 "~~~~~ fun pbl2xml, args:"; val (id: Problem.id, {guh,mathauthors,init,cas,met,ppc,prls,thy,where_}) =
137 "~~~~~ fun pbl2term, args:"; val (thy, (pblRD:Problem.id_reverse)) = (thy, id);
138 if ("Problem (" ^ Context.theory_name thy ^ "', " ^ (strs2str' o rev) pblRD ^ ")") =
139 "Problem (Pure', [empty_probl_id])"
140 then () else error "fun pbl2term changed";
143 "----- fun pbl2term ----------------------------------------------";
144 "----- fun pbl2term ----------------------------------------------";
145 "----- fun pbl2term ----------------------------------------------";
146 (*see WN120405a.TODO.txt*)
147 if UnparseC.term (Pbl_Met_Hierarchy.pbl2term (ThyC.get_theory "Isac_Knowledge") ["equations", "univariate", "normalise"]) =
148 "Problem (Isac_Knowledge', [normalise, univariate, equations])"
149 then () else error "fun pbl2term changed";
151 "----- fun insert_errpats ----------------------------------------";
152 "----- fun insert_errpats ----------------------------------------";
153 "----- fun insert_errpats ----------------------------------------";
154 (* vv--- here intermediate save/restore does not work and affects other tests ---vv
155 see test/../calcelems.sml --- Unsynchronized.ref doesn't work any more ---
158 [("chain-rule-diff-both",
159 [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
160 parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
161 parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
162 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
163 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
164 [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
165 @{thm diff_ln_chain}, @{thm diff_exp_chain}])];
167 insert_errpats ["diff", "differentiate_on_R"] errpatstest;
169 val {errpats, ...} = MethodC.from_store ["diff", "differentiate_on_R"];
171 ("chain-rule-diff-both", _, _) :: _ => ()
172 | _ => error "insert_errpats chain-rule-diff-both changed";
173 ^^^^^--- here intermediate save/restore does not work and affects other tests ---^^*)