diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-10 16:33:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-10 16:33:12 +0200 |
commit | a084c6650036db9f2a8cd69e31492c5dae237793 (patch) | |
tree | ba3e34f6e85ae9e0073476b0dc46956c51039189 /build2/test/script/script | |
parent | f1cbb7c9d5c750366fa1918a53d0682f0633b1d9 (diff) |
Implement scope-if in testscript
Diffstat (limited to 'build2/test/script/script')
-rw-r--r-- | build2/test/script/script | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/build2/test/script/script b/build2/test/script/script index 93ae661..241f148 100644 --- a/build2/test/script/script +++ b/build2/test/script/script @@ -246,6 +246,10 @@ namespace build2 scope* const parent; // NULL for the root (script) scope. script* const root; // Self for the root (script) scope. + // The chain of if-else scope alternatives. See also if_cond_ below. + // + unique_ptr<scope> if_chain; + // Note that if we pass the variable name as a string, then it will // be looked up in the wrong pool. // @@ -309,11 +313,17 @@ namespace build2 // Pre-parse data. // - private: + public: + virtual bool + empty () const = 0; + + protected: friend class parser; location start_loc_; location end_loc_; + + optional<line> if_cond_; }; // group @@ -331,15 +341,23 @@ namespace build2 // Pre-parse data. // - private: - friend class parser; - - bool - empty () const + public: + virtual bool + empty () const override { - return scopes.empty () && setup_.empty () && tdown_.empty (); + return + setup_.empty () && + tdown_.empty () && + find_if (scopes.begin (), scopes.end (), + [] (const unique_ptr<scope>& s) + { + return !s->empty (); + }) == scopes.end (); } + private: + friend class parser; + lines setup_; lines tdown_; }; @@ -353,6 +371,13 @@ namespace build2 // Pre-parse data. // + public: + virtual bool + empty () const override + { + return tests_.empty (); + } + private: friend class parser; |