1 /*=============================================================================
2 Copyright (c) 2005-2007 Dan Marsden
3 Copyright (c) 2005-2007 Joel de Guzman
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
12 #include <boost/spirit/include/phoenix_core.hpp>
13 #include <boost/spirit/include/phoenix_operator.hpp>
14 #include <boost/spirit/include/phoenix_statement.hpp>
16 #include <boost/detail/lightweight_test.hpp>
20 using namespace boost::phoenix;
21 using namespace boost::phoenix::arg_names;
27 throw_(runtime_error("error"))();
28 BOOST_ERROR("exception should have been thrown");
30 catch(runtime_error& err)
32 BOOST_TEST(err.what() == string("error"));
41 throw runtime_error("error");
46 BOOST_ERROR("exception should have been rethrown");
51 BOOST_TEST(err.what() == string("error"));
56 bool caught_exception = false;
59 [ throw_(runtime_error("error")) ]
61 [ ref(caught_exception) = true ]();
63 BOOST_TEST(caught_exception);
67 bool caught_exception = false;
69 [ throw_(runtime_error("error")) ]
71 [ ref(caught_exception) = true ]();
72 BOOST_TEST(caught_exception);
76 bool caught_correct_exception = false;
78 [ throw_(runtime_error("error")) ]
80 [ ref(caught_correct_exception) = false ]
82 [ ref(caught_correct_exception) = true]();
84 BOOST_TEST(caught_correct_exception);
88 bool caught_correct_exception = false;
90 [ throw_(runtime_error("error")) ]
92 [ ref(caught_correct_exception) = false ]
94 [ ref(caught_correct_exception) = true]();
96 BOOST_TEST(caught_correct_exception);
99 return boost::report_errors();