diff --git a/src/proc/mobject/session/query-focus-stack.hpp b/src/proc/mobject/session/query-focus-stack.hpp index 7bac96683..d58b02481 100644 --- a/src/proc/mobject/session/query-focus-stack.hpp +++ b/src/proc/mobject/session/query-focus-stack.hpp @@ -112,6 +112,7 @@ namespace session { QueryFocusStack::clear () { paths_.clear(); + openDefaultFrame(); } diff --git a/src/proc/mobject/session/scope-path.hpp b/src/proc/mobject/session/scope-path.hpp index b807e7ea0..d23d286cf 100644 --- a/src/proc/mobject/session/scope-path.hpp +++ b/src/proc/mobject/session/scope-path.hpp @@ -159,6 +159,7 @@ namespace session { /* == state diagnostics == */ bool isValid() const; bool empty() const; + bool isRoot() const; size_t size() const; size_t length() const; size_t ref_count()const; @@ -267,6 +268,17 @@ namespace session { return path_.empty(); } + inline bool + ScopePath::isRoot() const + { + return (1 == size()) +#if NOBUG_MODE_ALPHA + && path_[0].isRoot() +#endif + ; + } + + /** @note actually this is an Lumiera Forward Iterator, * yielding the path up to root as a sequence of diff --git a/tests/43session.tests b/tests/43session.tests index e70ae0af6..6f69b10b2 100644 --- a/tests/43session.tests +++ b/tests/43session.tests @@ -193,7 +193,8 @@ PLANNED "Query focus management" QueryFocus_test < (*new DummyMO)); + Scope const& unrelatedScope = fabricate_invalidScope(); // try to navigate to an invalid place - VERIFY_ERROR (INVALID, stack.top().navigate (unrelatedScope) ); + VERIFY_ERROR (INVALID_SCOPE, stack.top().navigate (unrelatedScope) ); ASSERT (1 == stack.size()); ASSERT (1 == firstFrame.ref_count()); ASSERT (stack.top().getLeaf() == startPoint); // try to push an invalid place - VERIFY_ERROR (INVALID, stack.push (unrelatedScope) ); + VERIFY_ERROR (INVALID_SCOPE, stack.push (unrelatedScope) ); ASSERT (1 == stack.size()); ASSERT (1 == firstFrame.ref_count()); ASSERT (stack.top().getLeaf() == startPoint); diff --git a/tests/components/proc/mobject/session/scope-path-test.cpp b/tests/components/proc/mobject/session/scope-path-test.cpp index 30cc7fc92..d425e394c 100644 --- a/tests/components/proc/mobject/session/scope-path-test.cpp +++ b/tests/components/proc/mobject/session/scope-path-test.cpp @@ -26,6 +26,7 @@ #include "proc/mobject/session/test-scopes.hpp" #include "proc/mobject/session/placement-index.hpp" #include "proc/mobject/session/scope-path.hpp" +#include "proc/mobject/session/test-scope-invalid.hpp" #include "lib/util.hpp" @@ -41,30 +42,6 @@ namespace test { using lumiera::error::LUMIERA_ERROR_INVALID; - namespace { // subversive test helper... - - Scope const& - fabricate_invalidScope() - { /** - * assumed to have identical memory layout - * to a Scope object, as the latter is implemented - * by a PlacementRef, which in turn is just an - * encapsulated Placement-ID - */ - struct Ambush - { - /** random ID assumed to be - * nowhere in the model */ - PlacementMO::ID derailed_; - }; - - static Ambush _kinky_; - return *reinterpret_cast (&_kinky_); - } - } - - - /*************************************************************************** diff --git a/tests/components/proc/mobject/session/test-scope-invalid.hpp b/tests/components/proc/mobject/session/test-scope-invalid.hpp new file mode 100644 index 000000000..ecfa18f04 --- /dev/null +++ b/tests/components/proc/mobject/session/test-scope-invalid.hpp @@ -0,0 +1,63 @@ +/* + TEST-SCOPE-INVALID.hpp - helper for placement scope and scope stack tests + + Copyright (C) Lumiera.org + 2010, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +#ifndef MOBJECT_SESSION_TEST_SCOPE_INVALID_H +#define MOBJECT_SESSION_TEST_SCOPE_INVALID_H + + +#include "proc/mobject/placement.hpp" +#include "proc/mobject/session/scope.hpp" + + + +namespace mobject { +namespace session { +namespace test { + + + namespace { // nifty subversive test helper... + + Scope const& + fabricate_invalidScope() + { /** + * assumed to have identical memory layout + * to a Scope object, as the latter is implemented + * by a PlacementRef, which in turn is just an + * encapsulated Placement-ID + */ + struct Ambush + { + /** random ID assumed to be + * nowhere in the model */ + PlacementMO::ID derailed_; + }; + + static Ambush _kinky_; + return *reinterpret_cast (&_kinky_); + } + } + + + +}}} // namespace mobject::session::test +#endif