1 /*=============================================================================
2 Copyright (c) 2001-2015 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/spirit/home/x3.hpp>
9
10 #include <iostream>
11 #include "test.hpp"
12
13 int
main()14 main()
15 {
16 using spirit_test::test;
17 using boost::spirit::x3::eps;
18 using boost::spirit::x3::unused_type;
19
20 {
21 BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(eps);
22 BOOST_TEST((test("", eps)));
23 BOOST_TEST((test("xxx", eps, false)));
24 //~ BOOST_TEST((!test("", !eps))); // not predicate $$$ Implement me! $$$
25 }
26
27 { // test non-lazy semantic predicate
28
29 BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(eps(true));
30 BOOST_TEST((test("", eps(true))));
31 BOOST_TEST((!test("", eps(false))));
32 BOOST_TEST((test("", !eps(false))));
33 }
34
35 { // test lazy semantic predicate
36
37 auto true_ = [](unused_type) { return true; };
38 auto false_ = [](unused_type) { return false; };
39
40 // cannot use lambda in constant expression before C++17
41 BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(eps(std::true_type{}));
42 BOOST_TEST((test("", eps(true_))));
43 BOOST_TEST((!test("", eps(false_))));
44 BOOST_TEST((test("", !eps(false_))));
45 }
46
47 return boost::report_errors();
48 }
49