Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/libbash:master commit in: src/core/, src/core/tests/
Date: Sun, 08 May 2011 13:08:08
Message-Id: c15de9151925dd3ede93ac00ebac07e629c86b6c.betelgeuse@gentoo
1 commit: c15de9151925dd3ede93ac00ebac07e629c86b6c
2 Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
3 AuthorDate: Fri Apr 29 08:45:05 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Sat May 7 07:03:23 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=c15de915
7
8 Core: return 0 if boost::lexical_cast<int> fails
9
10 Instead of throw an exception, we should return 0 as bash does. The
11 exact bash implementation is a bit different so we need to
12 specialize boost::lexical_cast<int> in future.
13
14 ---
15 src/core/symbols.hpp | 2 +-
16 src/core/tests/symbols_test.cpp | 2 ++
17 2 files changed, 3 insertions(+), 1 deletions(-)
18
19 diff --git a/src/core/symbols.hpp b/src/core/symbols.hpp
20 index 89fd657..2d6b6a5 100644
21 --- a/src/core/symbols.hpp
22 +++ b/src/core/symbols.hpp
23 @@ -73,7 +73,7 @@ public:
24 }
25 catch(boost::bad_lexical_cast& e)
26 {
27 - throw interpreter_exception("can't cast " + value + " to int");
28 + std::cerr << "can't cast " << value << " to int" << std::endl;
29 }
30 return result;
31 }
32
33 diff --git a/src/core/tests/symbols_test.cpp b/src/core/tests/symbols_test.cpp
34 index f151318..5853a4f 100644
35 --- a/src/core/tests/symbols_test.cpp
36 +++ b/src/core/tests/symbols_test.cpp
37 @@ -63,6 +63,8 @@ TEST(symbol_test, string_variable)
38 // string contains integer value
39 variable int_string("string", "123");
40 EXPECT_EQ(123, int_string.get_value<int>());
41 + int_string.set_value("abc");
42 + EXPECT_EQ(0, int_string.get_value<int>());
43 }
44
45 TEST(symbol_test, array_variable)