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:
Fischlurch 2014-05-11 02:08:53 +02:00
parent a421cf45de
commit c2ea15695e
8 changed files with 55 additions and 36 deletions

View file

@ -486,7 +486,7 @@ namespace session {
/** Retrieve all the elements attached to the given entry (scope)
* Each element (Placement) can act as a scope, containing other Placements,
* 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.
* @note results are returned in arbitrary order (hashtable)
*/

View file

@ -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,
* ContentsQuery, the resolution of this query requires to explore the
* 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,
* based on the predicate given as parameter
*/
@ -159,7 +158,7 @@ namespace session {
}
/** convenience shortcut (variant), automatically to build
* and execute a suitable SpecialContentsQuery
* and execute a suitable SpecificContentsQuery
* @return iterator yielding placements of the type as
* defined through the parameter of the predicate
*/

View file

@ -127,10 +127,10 @@ END
TEST "Querying the index" PlacementIndexQuery_test <<END
out: explore contents depth-first...
out: Placement<.+TestSubMO21.> ..... use-cnt=1
out: Placement<.+TestSubMO2.> ...... use-cnt=1
out: Placement<.+TestSubMO1.> ...... use-cnt=1
out: Placement<.+DummyMO.> .......... use-cnt=1
out: Placement<.+TestSubMO21.> ..... use-cnt=1
out: path to root starting at Placement<.+TestSubMO1
out: Placement<.+TestSubMO2.> ...... use-cnt=1
out: Placement<.+session.Label.> ......... use-cnt=1
@ -139,24 +139,24 @@ END
TEST "discovering scopes" ScopeQuery_test <<END
out: --------------------------------Test-1: contents depth-first
out: Placement<.+TestSubMO21.>
out: Placement<.+TestSubMO2.>
out: Placement<.+TestSubMO1.>
out: Placement<.+DummyMO.>
out: Placement<.+TestSubMO21.>
out: --------------------------------Test-2: contents depth-first, filtered to Clip
out: --------------------------------Test-3: contents depth-first, filtered to DummyMO
out: Placement<.+TestSubMO21.>
out: Placement<.+TestSubMO2.>
out: Placement<.+TestSubMO1.>
out: Placement<.+DummyMO.>
out: Placement<.+TestSubMO21.>
out: --------------------------------Test-4: contents depth-first, filtered to TestSubMO1
out: Placement<.+TestSubMO1.>
out: --------------------------------Test-5: contents depth-first, filtered to TestSubMO2
out: Placement<.+TestSubMO21.>
out: Placement<.+TestSubMO2.>
out: Placement<.+TestSubMO21.>
out: --------------------------------Test-6: contents depth-first, custom filtered DummyMO
out: Placement<.+TestSubMO21.>
out: Placement<.+TestSubMO2.>
out: Placement<.+TestSubMO21.>
out: --------------------------------Test-7: parents of the second TestSubMO2 element found
out: Placement<.+TestSubMO21.>
out: Placement<.+mobject.session.Label.>
@ -175,21 +175,21 @@ END
TEST "Placement search scope" PlacementScope_test <<END
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: Scope: \[DummyMO\.[0-9]{3}\]
out: Placement<.+TestSubMO1.>
out: Scope: \[Label\.[0-9]{3}\]
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
END

View file

@ -81,9 +81,13 @@ namespace test {
PlacementMO& root2 = SessionServiceExploreScope::getScopeRoot();
CHECK (isSameObject (root1, root2));
PlacementMO& elm1 = *ContentsQuery<TestSubMO21>(root1).resolveBy(resolver1);
PlacementMO& elm2 = *(index->getReferrers(root1));
CHECK (isSameObject (elm1, elm2));
PlacementMO& elm1 = *ContentsQuery<TestSubMO2>(root1).resolveBy(resolver1);
PlacementMO& elm2 = *ContentsQuery<TestSubMO1>(root1).resolveBy(resolver1);
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

View file

@ -370,8 +370,7 @@ namespace test {
// now explore a completely separate branch....
PMO& separatePlacement = *explore_testScope (
*explore_testScope (
*explore_testScope (
root.getTop())));
retrieve_firstTestSubMO21()));
path.navigate (separatePlacement);
CHECK (path);
CHECK (disjoint (path,refPath));

View file

@ -55,18 +55,18 @@ namespace test {
/** a filter predicate to pick some objects from a resultset,
* based on string match with the element's self-display string.
* @note using the specific API of DummyMO, without cast! */
bool
filter_typeID (PDummy candidate, string expectedText)
{
string desc = candidate->operator string();
return contains(desc, expectedText);
}
* @note the query system allows us to use the specific API of DummyMO,
* without the need for any cast. It is sufficient to declare
* a suitable signature on the query predicate! */
inline function<bool(PDummy)>
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));
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
testSession->insert(newPlacement, otherElm);

View file

@ -69,6 +69,16 @@ namespace test {
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
* beforehand, and the returned smart-ptr to the created test/dummy index
@ -79,8 +89,13 @@ namespace test {
PlacementMO&
retrieve_startElm()
{
return *ContentsQuery<TestSubMO1>(SessionServiceExploreScope::getScopeRoot())
.resolveBy(SessionServiceExploreScope::getResolver());
return retrieve_firstElmOfType<TestSubMO1>();
}
PlacementMO&
retrieve_firstTestSubMO21()
{
return retrieve_firstElmOfType<TestSubMO21>();
}

View file

@ -63,6 +63,8 @@ namespace test {
* which is a Placement<> and way down into the hierarchy
*/
PlacementMO& retrieve_startElm();
PlacementMO& retrieve_firstTestSubMO21();
/** shortcut to explore the contents of a scope within the current index.