Navigator: explicitly reject solutions that did not bind all wildcards
...this makes most of the remaining test cases pass only a plain anchor is not yet properly interpolated
This commit is contained in:
parent
d9db5f3917
commit
0ea5583b62
3 changed files with 82 additions and 66 deletions
|
|
@ -85,6 +85,20 @@ namespace interact {
|
|||
currDepth_ = depth+1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
size_t
|
||||
find_wildcardFree_suffix (UICoord const& uic)
|
||||
{
|
||||
size_t pos = uic.size();
|
||||
for ( ; 0 < pos; --pos)
|
||||
{
|
||||
Literal const& elm = uic[pos-1];
|
||||
if (elm == Symbol::ANY or elm == Symbol::EMPTY)
|
||||
break;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
}//(End) implementation details
|
||||
|
|
@ -123,7 +137,8 @@ namespace interact {
|
|||
// algorithm state
|
||||
size_t maxDepth = 0;
|
||||
PathManipulator coverage;
|
||||
size_t coordDepth = this->uic_.size();
|
||||
const size_t coordDepth = this->uic_.size();
|
||||
const size_t minSolutionDepth = find_wildcardFree_suffix (uic_);
|
||||
|
||||
auto searchAlgo = query_.getChildren (uic_, 0)
|
||||
.expandOnIteration()
|
||||
|
|
@ -144,6 +159,8 @@ namespace interact {
|
|||
})
|
||||
.filter ([&](auto& iter)
|
||||
{
|
||||
if (iter.depth() < minSolutionDepth)
|
||||
return false; // filter solutions which did not bind all wildcards
|
||||
if (iter.depth()+1 <= maxDepth) // filter for maximum solution length
|
||||
return false;
|
||||
maxDepth = 1 + iter.depth();
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ namespace test {
|
|||
UICoord uic3 = UICoord::firstWindow();
|
||||
UICoord uic4 = UICoord::currentWindow().persp("perspective-B");
|
||||
UICoord uic5 = UICoord::currentWindow().panel("panelY");
|
||||
UICoord uic6 = UICoord().view("someView").path("α/β/γ");
|
||||
UICoord uic6 = UICoord().view("someView");
|
||||
|
||||
UICoordResolver r1{uic1, tree};
|
||||
UICoordResolver r2{uic2, tree};
|
||||
|
|
@ -316,7 +316,7 @@ namespace test {
|
|||
* ** interpolate anchor and consecutive wildcards
|
||||
* ** discriminate by anchor and fill additional gap
|
||||
* - (4) failure detection
|
||||
* ** reject trailing wildcards
|
||||
* ** trailing wildcards are stripped and ignored
|
||||
* ** reject gap beyond existing real UI tree
|
||||
* ** reject gap ending at perimeter of real UI tree
|
||||
* ** reject interpolated gap on immediately following mismatch
|
||||
|
|
@ -330,7 +330,7 @@ namespace test {
|
|||
GenNodeLocationQuery tree{MakeRec()
|
||||
.set("window-1"
|
||||
, MakeRec()
|
||||
.type("perspective-A")
|
||||
.type("persp-A")
|
||||
.set("panelX"
|
||||
, MakeRec()
|
||||
.set("firstView", MakeRec())
|
||||
|
|
@ -342,23 +342,23 @@ namespace test {
|
|||
, MakeRec()
|
||||
.set("#1", MakeRec())
|
||||
.set("#2", MakeRec())
|
||||
.set("special", MakeRec())
|
||||
.set("tab", MakeRec())
|
||||
)
|
||||
)
|
||||
)
|
||||
.set("window-2"
|
||||
, MakeRec()
|
||||
.type("perspective-B")
|
||||
.type("persp-B")
|
||||
.set("panelY", MakeRec())
|
||||
)
|
||||
.set("window-3"
|
||||
, MakeRec()
|
||||
.type("perspective-C")
|
||||
.type("persp-C")
|
||||
.set("panelZ"
|
||||
, MakeRec()
|
||||
.set("thirdView"
|
||||
, MakeRec()
|
||||
.set("special"
|
||||
.set("tab"
|
||||
, MakeRec()
|
||||
.set("sub", MakeRec())
|
||||
)
|
||||
|
|
@ -370,82 +370,81 @@ namespace test {
|
|||
|
||||
/* === trivial cases === */
|
||||
UICoordResolver r11 {UICoord::window("window-1")
|
||||
.persp("perspective-A")
|
||||
.persp("persp-A")
|
||||
.panel("panelX"), tree};
|
||||
CHECK (r11.isCovered());
|
||||
CHECK (3 == r11.coverDepth());
|
||||
|
||||
|
||||
UICoordResolver r12 {UICoord::window("window-1")
|
||||
.persp("perspective-A")
|
||||
.persp("persp-A")
|
||||
.panel("panelX")
|
||||
.view("thirdView"), tree};
|
||||
CHECK (not r12.isCovered());
|
||||
CHECK ( r12.isCoveredPartially());
|
||||
CHECK (3 ==r12.coverDepth());
|
||||
CHECK ("UI:window-1[perspective-A]-panelX.thirdView" == string(r12));
|
||||
CHECK ("UI:window-1[persp-A]-panelX.thirdView" == string(r12));
|
||||
|
||||
auto r12_covered = r12.cover();
|
||||
CHECK (r12_covered.isCovered());
|
||||
CHECK (r12_covered.isCoveredPartially());
|
||||
CHECK (3 ==r12_covered.coverDepth());
|
||||
CHECK ("UI:window-1[perspective-A]-panelX" == string(r12_covered));
|
||||
CHECK ("UI:window-1[persp-A]-panelX" == string(r12_covered));
|
||||
|
||||
|
||||
/* === expand anchor === */
|
||||
UICoordResolver r21 {UICoord::firstWindow().persp("perspective-A"), tree};
|
||||
cout << r21.cover()<<endl;
|
||||
UICoordResolver r21 {UICoord::firstWindow().persp("persp-A"), tree};
|
||||
cout << r21.cover()<<endl; ///////////////////////////////////////////TODO doesn't work, yields UI:firstWindow[persp-A]
|
||||
|
||||
/* === expand anchor alone === */
|
||||
UICoordResolver r22 {UICoord::currentWindow(), tree};
|
||||
cout << r22.cover()<<endl;
|
||||
cout << r22.cover()<<endl; ///////////////////////////////////////////TODO doesn't work, yields UI:currentWindow
|
||||
|
||||
|
||||
/* === interpolate a single gap === */
|
||||
UICoordResolver r31 {UICoord::window("window-1").view("secondView"), tree};
|
||||
cout << r31.cover()<<endl;
|
||||
CHECK("UI:window-1[persp-A]-panelX.secondView" == string(r31.cover()));
|
||||
|
||||
/* === interpolate several gaps === */
|
||||
UICoordResolver r32 {UICoord().view("thirdView").path("sub"), tree};
|
||||
cout << r32.cover()<<endl;
|
||||
CHECK("UI:window-3[persp-C]-panelZ.thirdView.tab/sub" == string(r32.cover()));
|
||||
|
||||
/* === interpolate anchor and consecutive wildcards === */
|
||||
UICoordResolver r33 {UICoord::firstWindow().tab(2), tree};
|
||||
cout << r33.cover()<<endl;
|
||||
CHECK("UI:window-1[persp-A]-panelZ.thirdView.#2" == string(r33.cover()));
|
||||
|
||||
/* === discriminate by anchor and fill second gap === */
|
||||
UICoordResolver r34 {UICoord::currentWindow().view("thirdView").path("sub"), tree};
|
||||
cout << r34.cover()<<endl;
|
||||
UICoordResolver r34 {UICoord::currentWindow().panel("panelZ").tab("tab"), tree};
|
||||
CHECK("UI:window-3[persp-C]-panelZ.thirdView.tab" == string(r34.cover())); // Note: rest of the path would also match on window-1, but currentWindow == window-3
|
||||
|
||||
|
||||
/* === reject trailing wildcards === */
|
||||
/* === trailing wildcards stripped automatically === */
|
||||
UICoordResolver r41 {UICoord::window("window-2").append("*/*"), tree};
|
||||
cout << r41 <<endl;
|
||||
auto r41_extended = r41.extend("*/*");
|
||||
cout << r41_extended <<endl;
|
||||
cout << r41_extended.cover()<<endl;
|
||||
// CHECK (not r41_extended.canCover());
|
||||
CHECK("UI:window-2" == string(r41)); // Note: trailing wildcards are already discarded by PathArray / UICoord
|
||||
|
||||
auto r41_extended = r41.extend("*/*"); // if we now attempt to "sneak in" trailing wildcards...
|
||||
CHECK("UI:window-2[*]-*" == string(r41_extended));
|
||||
CHECK(not r41_extended.canCover()); // ...then the algorithm rejects any solution
|
||||
CHECK("UI:window-2" == string(r41_extended.cover())); // Note: but cover() will act on the previous coverage and just strip the extraneous suffix
|
||||
|
||||
/* === reject gap beyond existing real UI tree === */
|
||||
UICoordResolver r42 {UICoord::window("window-2").append("*/*/*/some/path"), tree};
|
||||
cout << r42.cover()<<endl;
|
||||
// CHECK (not r42.canCover());
|
||||
CHECK (not r42.canCover());
|
||||
|
||||
/* === reject gap ending at real UI tree boundary === */
|
||||
UICoordResolver r43 {UICoord::currentWindow().view("firstView").path("sub"), tree};
|
||||
UICoordResolver r43 {UICoord::currentWindow().view("firstView").tab("nonexisting"), tree};
|
||||
CHECK (not r43.canCover());
|
||||
|
||||
/* === reject interpolated gap on mismatch right behind === */
|
||||
UICoordResolver r44 {UICoord().view("otherView"), tree};
|
||||
UICoordResolver r44 {UICoord().view("otherView"), tree}; // Note: will be checked on all four existing views, but never matches
|
||||
CHECK (not r44.canCover());
|
||||
|
||||
/* === reject mismatch immediately behind second gap === */
|
||||
UICoordResolver r45 {UICoord().panel("panelZ").tab(3), tree};
|
||||
cout << r45.cover()<<endl;
|
||||
// CHECK (not r45.canCover());
|
||||
UICoordResolver r45 {UICoord().panel("panelZ").tab(3), tree}; // Note: we have two "panelZ", but none has a tab #3
|
||||
CHECK (not r45.canCover());
|
||||
|
||||
/* === mismatch of tree level === */
|
||||
UICoordResolver r46 {UICoord::currentWindow().append("*/*/panelZ/thirdView"), tree};
|
||||
UICoordResolver r46 {UICoord::currentWindow().append("*/*/panelZ/thirdView"), tree}; // Note: one '*' too much, thus 'panelZ' is matched on view level
|
||||
CHECK (not r46.canCover());
|
||||
|
||||
/* === impossible to anchor === */
|
||||
|
|
|
|||
|
|
@ -4463,10 +4463,10 @@
|
|||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539143849" ID="ID_1632791283" MODIFIED="1515037686112" TEXT="path-resolution">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539152568" ID="ID_153711822" MODIFIED="1508539175926" TEXT="Beschreibung">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1508539143849" ID="ID_1632791283" MODIFIED="1515120970745" TEXT="path-resolution">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1508539152568" ID="ID_153711822" MODIFIED="1515120963483" TEXT="Beschreibung">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1508539226014" ID="ID_1714773115" MODIFIED="1511572072101" TEXT="informell...">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
|
@ -4489,12 +4489,12 @@
|
|||
<node CREATED="1508539330312" ID="ID_67492497" MODIFIED="1508539911843" TEXT="bewegt nur Suchmarken">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539350382" ID="ID_585593926" MODIFIED="1508539902990" TEXT="Ergebnis">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539582959" ID="ID_54646462" MODIFIED="1508539905188" TEXT="Anchor == Literal">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1508539350382" ID="ID_585593926" MODIFIED="1515120942582" TEXT="Ergebnis">
|
||||
<icon BUILTIN="info"/>
|
||||
<node CREATED="1508539582959" ID="ID_54646462" MODIFIED="1515120947568" TEXT="Anchor == Literal">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539633800" ID="ID_471699110" MODIFIED="1511572072114" TEXT="coverDepth (Zahl)">
|
||||
<node CREATED="1508539633800" ID="ID_471699110" MODIFIED="1515120953828" TEXT="coverDepth (Zahl)">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
|
|
@ -4508,9 +4508,8 @@
|
|||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1508539644775" ID="ID_186144507" MODIFIED="1511572072121" TEXT="[optional] explizite Coverage">
|
||||
<node CREATED="1508539644775" ID="ID_186144507" MODIFIED="1515120958547" TEXT="[optional] explizite Coverage">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
|
|
@ -4529,7 +4528,6 @@
|
|||
</ul>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -8779,33 +8777,36 @@
|
|||
<icon BUILTIN="flag-pink"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1515114740273" ID="ID_224432926" MODIFIED="1515114745673" TEXT="interpolieren">
|
||||
<node COLOR="#338800" CREATED="1515114740273" ID="ID_224432926" MODIFIED="1515120853113" TEXT="interpolieren">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1514329498169" ID="ID_259096801" MODIFIED="1515114763818" TEXT="einfache Lücke schließen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329504776" ID="ID_1411396073" MODIFIED="1514330072531" TEXT="doppelte Lücke schließen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1514329504776" ID="ID_1411396073" MODIFIED="1515120845626" TEXT="doppelte Lücke schließen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329542594" ID="ID_959715297" MODIFIED="1514330073572" TEXT="fehlenden Anker interpolieren">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1514329542594" ID="ID_959715297" MODIFIED="1515120847766" TEXT="fehlenden Anker interpolieren">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514745294579" ID="ID_576780085" MODIFIED="1514745338174" TEXT="fehlender Anker und folgende Lücke">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1514745294579" ID="ID_576780085" MODIFIED="1515120849514" TEXT="fehlender Anker und folgende Lücke">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329555505" ID="ID_1508437078" MODIFIED="1514330074538" TEXT="fehlender Anker plus zweite Lücke">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1514329555505" ID="ID_1508437078" MODIFIED="1515120851424" TEXT="fehlender Anker plus zweite Lücke">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1514329861519" ID="ID_946875811" MODIFIED="1514330089705" TEXT="Scheitern">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1514329465117" ID="ID_1304144230" MODIFIED="1515114583527" TEXT="trailing Wildcards scheitern">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="flag-pink"/>
|
||||
<node COLOR="#338800" CREATED="1514329861519" ID="ID_946875811" MODIFIED="1515120903633" TEXT="Scheitern">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1514329465117" ID="ID_1304144230" MODIFIED="1515120860646" TEXT="trailing Wildcards scheitern">
|
||||
<icon BUILTIN="button_cancel"/>
|
||||
<node CREATED="1515120863655" ID="ID_1222552441" MODIFIED="1515120873442" TEXT="werden stets schon vom Konstrukor bereinigt"/>
|
||||
<node COLOR="#338800" CREATED="1515120874318" ID="ID_282902710" MODIFIED="1515120893868" TEXT="kann jedoch demonstrieren, daß der Algorithmus solche Lösungen verwirft">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1514329890564" ID="ID_723199137" MODIFIED="1515114588078" TEXT="realer Pfad endet vor Wildcards">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="flag-pink"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1514329890564" ID="ID_723199137" MODIFIED="1515120898108" TEXT="realer Pfad endet vor Wildcards">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1514329901562" ID="ID_1644217459" MODIFIED="1515114671856" TEXT="realer Pfad endet bündig mit Wildcards">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
|
|
@ -8813,9 +8814,8 @@
|
|||
<node COLOR="#338800" CREATED="1514329925895" ID="ID_257945525" MODIFIED="1515114669999" TEXT="mismatch auf erstem festen element">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1514329932501" ID="ID_1190347841" MODIFIED="1515114659060" TEXT="mismatch direkt hinter zweiter Lücke">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="flag-pink"/>
|
||||
<node COLOR="#338800" CREATED="1514329932501" ID="ID_1190347841" MODIFIED="1515120900249" TEXT="mismatch direkt hinter zweiter Lücke">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1514330003204" ID="ID_443318342" MODIFIED="1515114674215" TEXT="mismatch wg. verschobenem (matchendem) Element">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue