logical_tests.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/phoenix/core.hpp>
  8. #include <boost/phoenix/operator.hpp>
  9. namespace phoenix = boost::phoenix;
  10. int
  11. main()
  12. {
  13. using phoenix::arg_names::arg1;
  14. using phoenix::arg_names::arg2;
  15. {
  16. bool x = false;
  17. bool y = true;
  18. BOOST_TEST((!arg1)(x) == true);
  19. BOOST_TEST((!arg1)(y) == false);
  20. BOOST_TEST((arg1 || arg2)(x, y) == true);
  21. BOOST_TEST((arg1 && arg2)(x, y) == false);
  22. // short circuiting:
  23. int i = 1234;
  24. (arg1 || (arg2 = 4567))(y, i);
  25. BOOST_TEST(i == 1234);
  26. (arg1 && (arg2 = 4567))(y, i);
  27. BOOST_TEST(i == 4567);
  28. }
  29. return boost::report_errors();
  30. }