amend harmless PlacementIndex test failures. Test Suite PASS
c++11 uses another hashtable implementation. This uncovered some poorly written tests, which relied on objects being returned in a specific order. As far as poissible, we're using generic query functions now to get our test objects. But these tests still rely on a specifically crafted test index content, which as such is acceptable IMHO. The only remaining problem is that we check the order of generated output in some tests, and this order is still implementation dependent.
This commit is contained in:
parent
a421cf45de
commit
c2ea15695e
8 changed files with 55 additions and 36 deletions
|
|
@ -486,7 +486,7 @@ namespace session {
|
||||||
/** Retrieve all the elements attached to the given entry (scope)
|
/** Retrieve all the elements attached to the given entry (scope)
|
||||||
* Each element (Placement) can act as a scope, containing other Placements,
|
* Each element (Placement) can act as a scope, containing other Placements,
|
||||||
* which will be discovered by this query one level deep (not recursive).
|
* which will be discovered by this query one level deep (not recursive).
|
||||||
* @return an Lumiera Forward Iterator, yielding the children,
|
* @return a Lumiera Forward Iterator, yielding the children,
|
||||||
* possibly empty if the denoted element is a leaf.
|
* possibly empty if the denoted element is a leaf.
|
||||||
* @note results are returned in arbitrary order (hashtable)
|
* @note results are returned in arbitrary order (hashtable)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ namespace session {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specialised version of the ContentsQuery to pick some objects
|
|
||||||
* from the session, based on a filter predicate. As the parent type,
|
* from the session, based on a filter predicate. As the parent type,
|
||||||
* ContentsQuery, the resolution of this query requires to explore the
|
* ContentsQuery, the resolution of this query requires to explore the
|
||||||
* given scope depth first; but in addition to filter based on type,
|
* given scope depth first; but in addition to filter based on type,
|
||||||
|
|
@ -145,7 +144,7 @@ namespace session {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** convenience shortcut to issue a SpecialContentsQuery,
|
/** convenience shortcut to issue a SpecificContentsQuery,
|
||||||
* figuring out the actual return/filter type automatically,
|
* figuring out the actual return/filter type automatically,
|
||||||
* based on the predicate given as parameter
|
* based on the predicate given as parameter
|
||||||
*/
|
*/
|
||||||
|
|
@ -159,7 +158,7 @@ namespace session {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** convenience shortcut (variant), automatically to build
|
/** convenience shortcut (variant), automatically to build
|
||||||
* and execute a suitable SpecialContentsQuery
|
* and execute a suitable SpecificContentsQuery
|
||||||
* @return iterator yielding placements of the type as
|
* @return iterator yielding placements of the type as
|
||||||
* defined through the parameter of the predicate
|
* defined through the parameter of the predicate
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -127,10 +127,10 @@ END
|
||||||
|
|
||||||
TEST "Querying the index" PlacementIndexQuery_test <<END
|
TEST "Querying the index" PlacementIndexQuery_test <<END
|
||||||
out: explore contents depth-first...
|
out: explore contents depth-first...
|
||||||
out: Placement<.+TestSubMO21.> ..... use-cnt=1
|
|
||||||
out: Placement<.+TestSubMO2.> ...... use-cnt=1
|
out: Placement<.+TestSubMO2.> ...... use-cnt=1
|
||||||
out: Placement<.+TestSubMO1.> ...... use-cnt=1
|
out: Placement<.+TestSubMO1.> ...... use-cnt=1
|
||||||
out: Placement<.+DummyMO.> .......... use-cnt=1
|
out: Placement<.+DummyMO.> .......... use-cnt=1
|
||||||
|
out: Placement<.+TestSubMO21.> ..... use-cnt=1
|
||||||
out: path to root starting at Placement<.+TestSubMO1
|
out: path to root starting at Placement<.+TestSubMO1
|
||||||
out: Placement<.+TestSubMO2.> ...... use-cnt=1
|
out: Placement<.+TestSubMO2.> ...... use-cnt=1
|
||||||
out: Placement<.+session.Label.> ......... use-cnt=1
|
out: Placement<.+session.Label.> ......... use-cnt=1
|
||||||
|
|
@ -139,24 +139,24 @@ END
|
||||||
|
|
||||||
TEST "discovering scopes" ScopeQuery_test <<END
|
TEST "discovering scopes" ScopeQuery_test <<END
|
||||||
out: --------------------------------Test-1: contents depth-first
|
out: --------------------------------Test-1: contents depth-first
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Placement<.+TestSubMO2.>
|
out: Placement<.+TestSubMO2.>
|
||||||
out: Placement<.+TestSubMO1.>
|
out: Placement<.+TestSubMO1.>
|
||||||
out: Placement<.+DummyMO.>
|
out: Placement<.+DummyMO.>
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
out: --------------------------------Test-2: contents depth-first, filtered to Clip
|
out: --------------------------------Test-2: contents depth-first, filtered to Clip
|
||||||
out: --------------------------------Test-3: contents depth-first, filtered to DummyMO
|
out: --------------------------------Test-3: contents depth-first, filtered to DummyMO
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Placement<.+TestSubMO2.>
|
out: Placement<.+TestSubMO2.>
|
||||||
out: Placement<.+TestSubMO1.>
|
out: Placement<.+TestSubMO1.>
|
||||||
out: Placement<.+DummyMO.>
|
out: Placement<.+DummyMO.>
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
out: --------------------------------Test-4: contents depth-first, filtered to TestSubMO1
|
out: --------------------------------Test-4: contents depth-first, filtered to TestSubMO1
|
||||||
out: Placement<.+TestSubMO1.>
|
out: Placement<.+TestSubMO1.>
|
||||||
out: --------------------------------Test-5: contents depth-first, filtered to TestSubMO2
|
out: --------------------------------Test-5: contents depth-first, filtered to TestSubMO2
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Placement<.+TestSubMO2.>
|
out: Placement<.+TestSubMO2.>
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
out: --------------------------------Test-6: contents depth-first, custom filtered DummyMO
|
out: --------------------------------Test-6: contents depth-first, custom filtered DummyMO
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Placement<.+TestSubMO2.>
|
out: Placement<.+TestSubMO2.>
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
out: --------------------------------Test-7: parents of the second TestSubMO2 element found
|
out: --------------------------------Test-7: parents of the second TestSubMO2 element found
|
||||||
out: Placement<.+TestSubMO21.>
|
out: Placement<.+TestSubMO21.>
|
||||||
out: Placement<.+mobject.session.Label.>
|
out: Placement<.+mobject.session.Label.>
|
||||||
|
|
@ -175,21 +175,21 @@ END
|
||||||
|
|
||||||
TEST "Placement search scope" PlacementScope_test <<END
|
TEST "Placement search scope" PlacementScope_test <<END
|
||||||
out: Scope: \[Label\.[0-9]{3}\]
|
out: Scope: \[Label\.[0-9]{3}\]
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
|
||||||
out: Placement<.+TestSubMO21.>
|
|
||||||
out: Scope: \[Label\.[0-9]{3}\]
|
|
||||||
out: Placement<.+TestSubMO2.>
|
out: Placement<.+TestSubMO2.>
|
||||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||||
out: Placement<.+TestSubMO1.>
|
out: Placement<.+TestSubMO1.>
|
||||||
out: Scope: \[Label\.[0-9]{3}\]
|
out: Scope: \[Label\.[0-9]{3}\]
|
||||||
out: Placement<.+DummyMO.>
|
out: Placement<.+DummyMO.>
|
||||||
|
out: Scope: \[Label\.[0-9]{3}\]
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
|
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
|
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
|
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
|
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||||
|
out: Placement<.+TestSubMO21.>
|
||||||
return: 0
|
return: 0
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,13 @@ namespace test {
|
||||||
PlacementMO& root2 = SessionServiceExploreScope::getScopeRoot();
|
PlacementMO& root2 = SessionServiceExploreScope::getScopeRoot();
|
||||||
CHECK (isSameObject (root1, root2));
|
CHECK (isSameObject (root1, root2));
|
||||||
|
|
||||||
PlacementMO& elm1 = *ContentsQuery<TestSubMO21>(root1).resolveBy(resolver1);
|
PlacementMO& elm1 = *ContentsQuery<TestSubMO2>(root1).resolveBy(resolver1);
|
||||||
PlacementMO& elm2 = *(index->getReferrers(root1));
|
PlacementMO& elm2 = *ContentsQuery<TestSubMO1>(root1).resolveBy(resolver1);
|
||||||
CHECK (isSameObject (elm1, elm2));
|
PlacementMO& elm3 = *(index->getReferrers(elm1));
|
||||||
|
CHECK (isSameObject (elm3, elm2));
|
||||||
|
// relying on the specific setup of the test index
|
||||||
|
// MO1 is the sole "referrer" of MO2 (the only content within MO2's scope)
|
||||||
|
// root \ TestSubMO2 \ TestSubMO1
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -370,8 +370,7 @@ namespace test {
|
||||||
// now explore a completely separate branch....
|
// now explore a completely separate branch....
|
||||||
PMO& separatePlacement = *explore_testScope (
|
PMO& separatePlacement = *explore_testScope (
|
||||||
*explore_testScope (
|
*explore_testScope (
|
||||||
*explore_testScope (
|
retrieve_firstTestSubMO21()));
|
||||||
root.getTop())));
|
|
||||||
path.navigate (separatePlacement);
|
path.navigate (separatePlacement);
|
||||||
CHECK (path);
|
CHECK (path);
|
||||||
CHECK (disjoint (path,refPath));
|
CHECK (disjoint (path,refPath));
|
||||||
|
|
|
||||||
|
|
@ -55,18 +55,18 @@ namespace test {
|
||||||
|
|
||||||
/** a filter predicate to pick some objects from a resultset,
|
/** a filter predicate to pick some objects from a resultset,
|
||||||
* based on string match with the element's self-display string.
|
* based on string match with the element's self-display string.
|
||||||
* @note using the specific API of DummyMO, without cast! */
|
* @note the query system allows us to use the specific API of DummyMO,
|
||||||
bool
|
* without the need for any cast. It is sufficient to declare
|
||||||
filter_typeID (PDummy candidate, string expectedText)
|
* a suitable signature on the query predicate! */
|
||||||
{
|
|
||||||
string desc = candidate->operator string();
|
|
||||||
return contains(desc, expectedText);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline function<bool(PDummy)>
|
inline function<bool(PDummy)>
|
||||||
elementID_contains (string expectedText)
|
elementID_contains (string expectedText)
|
||||||
{
|
{
|
||||||
return bind (filter_typeID, _1, expectedText);
|
return [=] (PDummy candidate)
|
||||||
|
{
|
||||||
|
REQUIRE (candidate.isValid());
|
||||||
|
string desc(candidate->operator string());
|
||||||
|
return contains(desc, expectedText);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +127,7 @@ namespace test {
|
||||||
MORef<DummyMO> findAgain = queryAPI.pick (elementID_contains(specificID));
|
MORef<DummyMO> findAgain = queryAPI.pick (elementID_contains(specificID));
|
||||||
CHECK (!findAgain); // empty result because searched element was removed from session...
|
CHECK (!findAgain); // empty result because searched element was removed from session...
|
||||||
|
|
||||||
MORef<DummyMO> otherElm = queryAPI.pick (elementID_contains("MO1"));
|
MORef<DummyMO> otherElm = queryAPI.pick (elementID_contains("MO21"));
|
||||||
CHECK (otherElm); // now pick just some other arbitrary element
|
CHECK (otherElm); // now pick just some other arbitrary element
|
||||||
|
|
||||||
testSession->insert(newPlacement, otherElm);
|
testSession->insert(newPlacement, otherElm);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,16 @@ namespace test {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
template<class MO>
|
||||||
|
PlacementMO&
|
||||||
|
retrieve_firstElmOfType()
|
||||||
|
{
|
||||||
|
return *ContentsQuery<MO>(SessionServiceExploreScope::getScopeRoot())
|
||||||
|
.resolveBy(SessionServiceExploreScope::getResolver());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @note this test helper only works if build_testScopes is invoked
|
/** @note this test helper only works if build_testScopes is invoked
|
||||||
* beforehand, and the returned smart-ptr to the created test/dummy index
|
* beforehand, and the returned smart-ptr to the created test/dummy index
|
||||||
|
|
@ -79,8 +89,13 @@ namespace test {
|
||||||
PlacementMO&
|
PlacementMO&
|
||||||
retrieve_startElm()
|
retrieve_startElm()
|
||||||
{
|
{
|
||||||
return *ContentsQuery<TestSubMO1>(SessionServiceExploreScope::getScopeRoot())
|
return retrieve_firstElmOfType<TestSubMO1>();
|
||||||
.resolveBy(SessionServiceExploreScope::getResolver());
|
}
|
||||||
|
|
||||||
|
PlacementMO&
|
||||||
|
retrieve_firstTestSubMO21()
|
||||||
|
{
|
||||||
|
return retrieve_firstElmOfType<TestSubMO21>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ namespace test {
|
||||||
* which is a Placement<> and way down into the hierarchy
|
* which is a Placement<> and way down into the hierarchy
|
||||||
*/
|
*/
|
||||||
PlacementMO& retrieve_startElm();
|
PlacementMO& retrieve_startElm();
|
||||||
|
|
||||||
|
PlacementMO& retrieve_firstTestSubMO21();
|
||||||
|
|
||||||
|
|
||||||
/** shortcut to explore the contents of a scope within the current index.
|
/** shortcut to explore the contents of a scope within the current index.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue