From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Q6m5Q-0003FN-8N for garchives@archives.gentoo.org; Mon, 04 Apr 2011 15:53:04 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4A7161C06A; Mon, 4 Apr 2011 15:52:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 1BF2D1C06F for ; Mon, 4 Apr 2011 15:52:41 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 709AE1BC002 for ; Mon, 4 Apr 2011 15:52:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id DBCB88006D for ; Mon, 4 Apr 2011 15:52:39 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: Subject: [gentoo-commits] proj/libbash:master commit in: src/core/, src/core/tests/ X-VCS-Repository: proj/libbash X-VCS-Files: src/core/interpreter.h src/core/tests/interpreter_test.cpp X-VCS-Directories: src/core/ src/core/tests/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: dc956e48bb51489eccf1be4793d556490aac2278 Date: Mon, 4 Apr 2011 15:52:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: f7d2aef5634533a5c63e6161dd3d1797 commit: dc956e48bb51489eccf1be4793d556490aac2278 Author: Mu Qiao gentoo org> AuthorDate: Mon Apr 4 05:29:06 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Mon Apr 4 15:09:07 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Ddc956e48 Add a method indicating whether a variable is unset --- src/core/interpreter.h | 8 ++++++++ src/core/tests/interpreter_test.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/src/core/interpreter.h b/src/core/interpreter.h index 858916e..1ce1076 100644 --- a/src/core/interpreter.h +++ b/src/core/interpreter.h @@ -371,6 +371,14 @@ public: return true; } =20 + /// \brief check whether the value of the variable is unset + /// \param variable name + /// \return whether the value of the variable is unset + bool is_unset(const std::string& name) + { + return !members.resolve(name); + } + /// \brief update the variable value, raise interpreter_exception if /// it's readonly, will define the variable if it doesn't exist /// \param variable name diff --git a/src/core/tests/interpreter_test.cpp b/src/core/tests/interpr= eter_test.cpp index c3f7888..6f8d0c4 100644 --- a/src/core/tests/interpreter_test.cpp +++ b/src/core/tests/interpreter_test.cpp @@ -53,6 +53,14 @@ TEST(interpreter, is_null) EXPECT_TRUE(walker.is_null("foo")); } =20 +TEST(interpreter, is_unset) +{ + interpreter walker; + walker.define("foo", "hello"); + EXPECT_FALSE(walker.is_unset("foo")); + EXPECT_TRUE(walker.is_unset("bar")); +} + TEST(interpreter, set_int_value) { interpreter walker;