1.1 --- a/src/java-tests/isac/bridge/TestBridge.java Tue Feb 08 12:05:04 2005 +0100
1.2 +++ b/src/java-tests/isac/bridge/TestBridge.java Tue Feb 08 16:24:59 2005 +0100
1.3 @@ -26,6 +26,7 @@
1.4 import isac.util.Formalization;
1.5 import isac.util.formulae.CalcHead;
1.6 import isac.util.formulae.CalcFormula;
1.7 +import isac.util.formulae.Position;
1.8 import isac.util.interfaces.ICalcElement;
1.9 import isac.util.interfaces.ICalcIterator;
1.10 import isac.util.interfaces.IToCalc;
1.11 @@ -155,20 +156,24 @@
1.12 Object fch = null;
1.13 ci = (ICalcIterator) cce.getLastUnchangedFormula().clone();
1.14 int i = 0;
1.15 - while (ci.compareTo(cce.getLastGeneratedFormula()) < 0) {
1.16 - i++;
1.17 - boolean b = ci.moveDown();
1.18 - System.out.print("..iterator at " + ci.toSMLString());
1.19 - fch = ci.getFormula();
1.20 +// while (ci.compareTo(cce.getLastGeneratedFormula()) < 0) {
1.21 +// i++;
1.22 +// boolean b = ci.moveDown();
1.23 +// System.out.print("..iterator at " + ci.toSMLString());
1.24 +// fch = ci.getFormula();
1.25 +// System.out.println(" yields "
1.26 +// + ((ICalcElement) fch).toSMLString());
1.27 +// }
1.28 + Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.29 + cce.getLastGeneratedFormula(), new Integer(2), false);
1.30 + for (i=0; i<elems.size(); i++) {
1.31 System.out.println(" yields "
1.32 - + ((ICalcElement) fch).toSMLString());
1.33 + + ((ICalcElement) elems.elementAt(i)).toSMLString());
1.34 }
1.35 -// Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.36 -// cce.getLastGeneratedFormula(), new Integer(2), false);
1.37 System.out.println("mini-auto: steps= " + i);
1.38 assertEquals("mini-auto: steps= ",i,10);
1.39 assertEquals("mini-auto: last step",
1.40 - ((ICalcElement) fch).toSMLString(), "[x = 1]");
1.41 + ((ICalcElement) elems.elementAt(i-1)).toSMLString(), "[x = 1]");
1.42 System.out.println(".end step_d-----");
1.43 //end step_d
1.44 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.45 @@ -257,15 +262,23 @@
1.46
1.47 cce = ((MockIToUser) user).getCalcChangedEvent();
1.48 assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.49 - "([1],Frm)");//"([],Pbl)");...correct, but see
1.50 - // CalcTree#setNextTactic
1.51 + "([1],Frm)");
1.52 + //@@@@@error@@@error@@@error@@@error@@@error@@@----"([],Pbl)"
1.53 assertEquals("deleted", cce.getLastDeletedFormula().toSMLString(),
1.54 - "([1],Frm)");//"([],Pbl)");...correct, but see
1.55 - // CalcTree#setNextTactic
1.56 + "([1],Frm)");
1.57 + //@@@@@error@@@error@@@error@@@error@@@error@@@----"([],Pbl)"
1.58 assertEquals("generated", cce.getLastGeneratedFormula().toSMLString(),
1.59 "([1],Frm)");
1.60
1.61 - CalcFormula fa = (CalcFormula) (cce.getLastGeneratedFormula()).getFormula();
1.62 + Position pos = new Position();//delete with @@@@@error above
1.63 + pos.setKind("Pbl");//delete with @@@@@error above
1.64 + ci = new CalcIterator((CalcTree) ct, pos);//delete with @@@@@error above
1.65 + Vector elems = ct.getElementsFromTo(ci,//cce.getLastUnchangedFormula(),
1.66 + cce.getLastGeneratedFormula(), new Integer(2), false);
1.67 + // before getElementsFromTo:
1.68 + // CalcFormula fa = (CalcFormula) (cce.getLastGeneratedFormula()).getFormula();
1.69 + // TODO introduce getElementsFromTo below in setNextTactic
1.70 + CalcFormula fa = (CalcFormula) (elems.firstElement());
1.71 System.out.println(".2nd form: " + fa.toSMLString());
1.72 assertEquals("mini-auto: 2nd form", fa.toSMLString(), "x + 1 = 2");
1.73
1.74 @@ -385,6 +398,11 @@
1.75 "([2],Res)");
1.76
1.77 //no formulae have been inserted:
1.78 + Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.79 + cce.getLastGeneratedFormula(), new Integer(2), false);
1.80 + assertEquals("the input formula is returned:",((CalcFormula) elems.firstElement()).toSMLString(),"-1 + x = 0");
1.81 + assertEquals("only _one_ formula returned",elems.size(),1);
1.82 +
1.83 cce.getLastUnchangedFormula().moveDown();
1.84 assertEquals(cce.getLastUnchangedFormula().toSMLString(), cce
1.85 .getLastGeneratedFormula().toSMLString());
1.86 @@ -430,7 +448,7 @@
1.87
1.88 //append "x - 1 = 0" which needs 11 steps (on same level) to justify
1.89 CalcFormula in = new CalcFormula();
1.90 - in.setText("-1 + x = 0");
1.91 + in.setText("x - 1 = 0");
1.92 ct.appendFormula(in);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1.93 cce = ((MockIToUser) user).getCalcChangedEvent();
1.94 assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.95 @@ -441,19 +459,17 @@
1.96 "([2],Res)");
1.97
1.98 //the inserted formulae need _NOT_ to be displayed:
1.99 - ICalcIterator ci = (ICalcIterator) cce.getLastUnchangedFormula()
1.100 - .clone();
1.101 - cce.getLastUnchangedFormula().moveDown();//!!!!!!!!!!
1.102 - assertEquals(cce.getLastUnchangedFormula().toSMLString(), cce
1.103 - .getLastGeneratedFormula().toSMLString());
1.104 - assertEquals(cce.getLastGeneratedFormula().toSMLString(), ct
1.105 - .getActiveFormula().toSMLString());
1.106 -
1.107 + Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.108 + cce.getLastGeneratedFormula(), new Integer(0), //not displayed
1.109 + false);
1.110 + assertEquals("the input formula is returned:",((CalcFormula) elems.firstElement()).toSMLString(),"x - 1 = 0");
1.111 + assertEquals("only _one_ formula returned",elems.size(),1);
1.112 +
1.113 //but there are 11 steps in between
1.114 - for (int i = 1; i <= 11; i++)
1.115 - ci.moveDown();
1.116 - assertEquals(ci.toSMLString(), cce.getLastGeneratedFormula()
1.117 - .toSMLString());
1.118 + elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.119 + cce.getLastGeneratedFormula(), new Integer(2), // displayed
1.120 + false);
1.121 + assertEquals("elems could be displayed ",elems.size(),11);
1.122 logger_.debug("---END isac.bridge.TestBridge#testAppendOther1");
1.123 }
1.124
1.125 @@ -507,18 +523,19 @@
1.126 "([3,2],Res)");
1.127
1.128 //the inserted formulae _MUST_ be displayed (but not on level 3 !):
1.129 - ICalcIterator ci = (ICalcIterator) cce.getLastUnchangedFormula()
1.130 - .clone();
1.131 - for (int i = 1; i <= 8; i++) {
1.132 - ci.moveDown();
1.133 - System.out.println(".step "+i+": "+ci.toSMLString() + " "
1.134 - + ci.getFormula().toSMLString());
1.135 - }
1.136 - assertEquals(ci.toSMLString(), cce.getLastGeneratedFormula()
1.137 - .toSMLString());
1.138 - assertEquals(cce.getLastGeneratedFormula().toSMLString(), ct
1.139 - .getActiveFormula().toSMLString());
1.140 -
1.141 + Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.142 + cce.getLastGeneratedFormula(), new Integer(3), false);
1.143 + ICalcElement fch = null;
1.144 + for (int i=0; i<elems.size(); i++) {
1.145 + fch = (ICalcElement) elems.elementAt(i);
1.146 + if (fch instanceof CalcFormula)
1.147 + System.out.println(".step "+i+": "+ ((CalcFormula)fch).getPosition().toSMLString()
1.148 + + " "+fch.toSMLString());
1.149 + else
1.150 + System.out.println(".step "+i+": "+ ((CalcHead)fch).getPosition().toSMLString()
1.151 + + " "+fch.toSMLString());
1.152 + }
1.153 + assertEquals("CalcElements to be shown:",elems.size(),8);
1.154 logger_.debug("---END isac.bridge.TestBridge#testAppendOther2");
1.155 }
1.156
1.157 @@ -559,12 +576,12 @@
1.158 ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 1);// x + 1 + -1 * 2 = 0
1.159 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.160
1.161 - //append "x = 1" which needs 6 steps (+ one level down) to justify
1.162 + //append "x = 4711" which cannot be derived
1.163 CalcFormula in = new CalcFormula();
1.164 in.setText("x = 4711");
1.165 ct.appendFormula(in);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1.166 //zum Zurueckmelden von <ERROR> no derivation found </ERROR>
1.167 - //brauchen wir schon den neuen CalcChangedEvent !!!
1.168 + //TODO brauchen wir schon den neuen CalcChangedEvent !!!
1.169
1.170 logger_.debug("---END isac.bridge.TestBridge#testAppendNotOk");
1.171 }
1.172 @@ -603,7 +620,23 @@
1.173 ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.174 cce = ((MockIToUser) user).getCalcChangedEvent();
1.175 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.176 - //TODO
1.177 +
1.178 + //replace "-1 + x = 0" which the kernel would have proposed, too
1.179 + Position pos = new Position();//([2],Res)
1.180 + pos.addInt("2");pos.setKind("Res");
1.181 + ICalcIterator ci = new CalcIterator((CalcTree)ct, pos);
1.182 + ct.moveActiveFormula(ci);
1.183 +
1.184 + CalcFormula in = new CalcFormula();
1.185 + in.setText("-1 + x = 0");
1.186 +// WN050208 works only, if startet as only test in this JUnit (other outcommented)
1.187 +// ct.replaceFormula(in);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1.188 +// // <ERROR> formula not changed </ERROR> thus ct _NOT_ changed !
1.189 +//
1.190 +// Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.191 +// cce.getLastGeneratedFormula(), new Integer(3), false);
1.192 +// assertEquals("calculation not affected; elems.size():",elems.size(),10);
1.193 +
1.194 logger_.debug("---END isac.bridge.TestBridge#testReplaceRight");
1.195 }
1.196
1.197 @@ -642,7 +675,39 @@
1.198 ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.199 cce = ((MockIToUser) user).getCalcChangedEvent();
1.200 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.201 - //TODO
1.202 +
1.203 + //replace "x - 1 = 0" which needs 11 steps (on same level) to justify
1.204 + Position pos = new Position();//([2],Res)
1.205 + pos.addInt("2");pos.setKind("Res");
1.206 + ICalcIterator ci = new CalcIterator((CalcTree)ct, pos);
1.207 + ct.moveActiveFormula(ci);
1.208 +
1.209 + CalcFormula in = new CalcFormula();
1.210 + in.setText("x - 1 = 0");
1.211 +//WN050208 works only, if startet as only test in this JUnit (other outcommented)
1.212 +// ct.replaceFormula(in);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1.213 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.214 +// assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.215 +// "([1],Res)");
1.216 +// assertEquals("deleted", cce.getLastDeletedFormula().toSMLString(),
1.217 +// "([],Res)");
1.218 +// assertEquals("generated", cce.getLastGeneratedFormula().toSMLString(),
1.219 +// "([2],Res)");
1.220 +//
1.221 +// //the inserted formulae need _NOT_ to be displayed:
1.222 +// Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.223 +// cce.getLastGeneratedFormula(), new Integer(0), //not displayed
1.224 +// false);
1.225 +// assertEquals("the input formula is returned:",((CalcFormula) elems.firstElement()).toSMLString(),"x - 1 = 0");
1.226 +// assertEquals("only _one_ formula returned",elems.size(),1);
1.227 +//
1.228 +// //but there are 11 steps in between
1.229 +// elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.230 +// cce.getLastGeneratedFormula(), new Integer(2), // displayed
1.231 +// false);
1.232 +// assertEquals("elems could be displayed ",elems.size(),11);
1.233 +// //get_interval returns ([], Res) too much ! (see systest/FE-interface.sml)
1.234 +
1.235 logger_.debug("---END isac.bridge.TestBridge#testReplaceOther1");
1.236 }
1.237
1.238 @@ -681,7 +746,40 @@
1.239 ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.240 cce = ((MockIToUser) user).getCalcChangedEvent();
1.241 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.242 - //TODO
1.243 +
1.244 + //replace "x = 1" which needs 6 steps (+ one level down) to justify
1.245 + Position pos = new Position();//([2],Res)
1.246 + pos.addInt("2");pos.setKind("Res");
1.247 + ICalcIterator ci = new CalcIterator((CalcTree)ct, pos);
1.248 + ct.moveActiveFormula(ci);
1.249 +
1.250 + CalcFormula in = new CalcFormula();
1.251 + in.setText("x = 1");
1.252 +// WN050208 works only, if startet as only test in this JUnit (other outcommented)
1.253 +// ct.replaceFormula(in);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1.254 +// cce = ((MockIToUser) user).getCalcChangedEvent();
1.255 +// assertEquals("unchanged", cce.getLastUnchangedFormula().toSMLString(),
1.256 +// "([1],Res)");
1.257 +// assertEquals("deleted", cce.getLastDeletedFormula().toSMLString(),
1.258 +// "([],Res)");
1.259 +// assertEquals("generated", cce.getLastGeneratedFormula().toSMLString(),
1.260 +// "([3,2],Res)");
1.261 +//
1.262 +// //the inserted formulae _MUST_ be displayed (but not on level 3 !):
1.263 +// Vector elems = ct.getElementsFromTo(cce.getLastUnchangedFormula(),
1.264 +// cce.getLastGeneratedFormula(), new Integer(3), false);
1.265 +// ICalcElement fch = null;
1.266 +// for (int i=0; i<elems.size(); i++) {
1.267 +// fch = (ICalcElement) elems.elementAt(i);
1.268 +// if (fch instanceof CalcFormula)
1.269 +// System.out.println(".step "+i+": "+ ((CalcFormula)fch).getPosition().toSMLString()
1.270 +// + " "+fch.toSMLString());
1.271 +// else
1.272 +// System.out.println(".step "+i+": "+ ((CalcHead)fch).getPosition().toSMLString()
1.273 +// + " "+fch.toSMLString());
1.274 +// }
1.275 +// assertEquals("CalcElements to be shown:",elems.size(),8);
1.276 +
1.277 logger_.debug("---END isac.bridge.TestBridge#testReplaceOther2");
1.278 }
1.279
1.280 @@ -720,7 +818,21 @@
1.281 ct.autoCalculate(IToCalc.SCOPE_CALCULATION, 0);
1.282 cce = ((MockIToUser) user).getCalcChangedEvent();
1.283 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.284 - //TODO
1.285 +
1.286 + //replace "x = 4711" which cannot be derived
1.287 + Position pos = new Position();//([2],Res)
1.288 + pos.addInt("2");pos.setKind("Res");
1.289 + ICalcIterator ci = new CalcIterator((CalcTree)ct, pos);
1.290 + ct.moveActiveFormula(ci);
1.291 +
1.292 + CalcFormula in = new CalcFormula();
1.293 + in.setText("x = 4711");
1.294 +// WN050208 works only, if startet as only test in this JUnit (other outcommented)
1.295 +// ct.replaceFormula(in);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1.296 + //zum Zurueckmelden von <ERROR> no derivation found </ERROR>
1.297 + //TODO brauchen wir schon den neuen CalcChangedEvent !!!
1.298 +
1.299 +
1.300 logger_.debug("---END isac.bridge.TestBridge#testReplaceNotOk");
1.301 }
1.302