LCOV - code coverage report
Current view: top level - tests - catch_expr_relational.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 697 697 100.0 %
Date: 2023-11-01 21:56:19 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2015-2022  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/csspp
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      19             : 
      20             : /** \file
      21             :  * \brief Test the expression.cpp file: "<", "<=", ">", ">=" operators.
      22             :  *
      23             :  * This test runs a battery of tests agains the expression.cpp "<" (less
      24             :  * than), "<=" (less or equal), ">" (greater than), ">=" (greater or equal)
      25             :  * operators to ensure full coverage and that all possible left
      26             :  * hand side and right hand side types are checked for the relational
      27             :  * CSS Preprocessor extensions.
      28             :  *
      29             :  * Note that all the tests use the full chain: lexer, parser, compiler,
      30             :  * and assembler to make sure the results are correct. So these tests
      31             :  * exercise the assembler even more than the assembler tests, except that
      32             :  * it only checks that compressed results are correct instead of all
      33             :  * output modes, since its only goal is covering all the possible
      34             :  * expression cases and not the assembler, compiler, parser, and lexer
      35             :  * classes.
      36             :  */
      37             : 
      38             : // csspp
      39             : //
      40             : #include    <csspp/assembler.h>
      41             : #include    <csspp/compiler.h>
      42             : #include    <csspp/exception.h>
      43             : #include    <csspp/parser.h>
      44             : 
      45             : 
      46             : // self
      47             : //
      48             : #include    "catch_main.h"
      49             : 
      50             : 
      51             : // C++
      52             : //
      53             : #include    <sstream>
      54             : 
      55             : 
      56             : // last include
      57             : //
      58             : #include    <snapdev/poison.h>
      59             : 
      60             : 
      61             : 
      62          19 : CATCH_TEST_CASE("Expression number <,<=,>,>= number", "[expression] [relational]")
      63             : {
      64             :     struct operator_results_t
      65             :     {
      66             :         char const *        f_operator;
      67             :         bool                f_different_result;
      68             :         bool                f_equal_result;
      69             :     };
      70             : 
      71             :     // different is true if a < b is true
      72             :     // equal is true if a == b is true
      73          19 :     operator_results_t const op[] =
      74             :     {
      75             :         { "<",      true,       false   },
      76             :         { "<=",     true,       true    },
      77             :         { ">",      false,      false   },
      78             :         { ">=",     false,      true    }
      79             :     };
      80             : 
      81          19 :     CATCH_START_SECTION("compare 10 ?? 3")
      82             :     {
      83           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
      84             :         {
      85           4 :             std::stringstream ss;
      86             :             ss << "div { z-index: 10 "
      87           4 :                << op[idx].f_operator
      88           4 :                << " 3 ? 9 : 5; }";
      89          12 :             csspp::position pos("test.css");
      90           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
      91             : 
      92           8 :             csspp::parser p(l);
      93             : 
      94           4 :             csspp::node::pointer_t n(p.stylesheet());
      95             : 
      96           4 :             csspp::compiler c;
      97           4 :             c.set_root(n);
      98           4 :             c.set_date_time_variables(csspp_test::get_now());
      99           4 :             c.add_path(csspp_test::get_script_path());
     100           4 :             c.add_path(csspp_test::get_version_script_path());
     101             : 
     102           4 :             c.compile(false);
     103             : 
     104             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     105             : 
     106             :             // to verify that the result is still an INTEGER we have to
     107             :             // test the root node here
     108           4 :             std::stringstream compiler_out;
     109           4 :             compiler_out << *n;
     110           4 :             VERIFY_TREES(compiler_out.str(),
     111             : 
     112             : "LIST\n"
     113             : + csspp_test::get_default_variables() +
     114             : "  COMPONENT_VALUE\n"
     115             : "    ARG\n"
     116             : "      IDENTIFIER \"div\"\n"
     117             : "    OPEN_CURLYBRACKET B:true\n"
     118             : "      DECLARATION \"z-index\"\n"
     119             : "        ARG\n"
     120             : "          INTEGER \"\" I:" + std::to_string(!op[idx].f_different_result ? 9 : 5) + "\n"
     121             : + csspp_test::get_close_comment(true)
     122             : 
     123             :                 );
     124             : 
     125           4 :             std::stringstream assembler_out;
     126           4 :             csspp::assembler a(assembler_out);
     127           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     128             : 
     129             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     130             : 
     131           4 :             CATCH_REQUIRE(assembler_out.str() ==
     132             : std::string("div{z-index:") + (!op[idx].f_different_result ? "9" : "5") + "}\n"
     133             : + csspp_test::get_close_comment()
     134             :                     );
     135             : 
     136           4 :             CATCH_REQUIRE(c.get_root() == n);
     137           4 :         }
     138             :     }
     139          19 :     CATCH_END_SECTION()
     140             : 
     141          19 :     CATCH_START_SECTION("compare 3 ?? 10")
     142             :     {
     143           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     144             :         {
     145           4 :             std::stringstream ss;
     146             :             ss << "div { z-index: 3 "
     147           4 :                << op[idx].f_operator
     148           4 :                << " 10 ? 9 : 5; }";
     149          12 :             csspp::position pos("test.css");
     150           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     151             : 
     152           8 :             csspp::parser p(l);
     153             : 
     154           4 :             csspp::node::pointer_t n(p.stylesheet());
     155             : 
     156           4 :             csspp::compiler c;
     157           4 :             c.set_root(n);
     158           4 :             c.set_date_time_variables(csspp_test::get_now());
     159           4 :             c.add_path(csspp_test::get_script_path());
     160           4 :             c.add_path(csspp_test::get_version_script_path());
     161             : 
     162           4 :             c.compile(false);
     163             : 
     164             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     165             : 
     166             :             // to verify that the result is still an INTEGER we have to
     167             :             // test the root node here
     168           4 :             std::stringstream compiler_out;
     169           4 :             compiler_out << *n;
     170           4 :             VERIFY_TREES(compiler_out.str(),
     171             : 
     172             : "LIST\n"
     173             : + csspp_test::get_default_variables() +
     174             : "  COMPONENT_VALUE\n"
     175             : "    ARG\n"
     176             : "      IDENTIFIER \"div\"\n"
     177             : "    OPEN_CURLYBRACKET B:true\n"
     178             : "      DECLARATION \"z-index\"\n"
     179             : "        ARG\n"
     180             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_different_result ? 9 : 5) + "\n"
     181             : + csspp_test::get_close_comment(true)
     182             : 
     183             :                 );
     184             : 
     185           4 :             std::stringstream assembler_out;
     186           4 :             csspp::assembler a(assembler_out);
     187           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     188             : 
     189             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     190             : 
     191           4 :             CATCH_REQUIRE(assembler_out.str() ==
     192             : std::string("div{z-index:") + (op[idx].f_different_result ? "9" : "5") + "}\n"
     193             : + csspp_test::get_close_comment()
     194             :                     );
     195             : 
     196           4 :             CATCH_REQUIRE(c.get_root() == n);
     197           4 :         }
     198             :     }
     199          19 :     CATCH_END_SECTION()
     200             : 
     201          19 :     CATCH_START_SECTION("compare 10 ?? 10")
     202             :     {
     203           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     204             :         {
     205           4 :             std::stringstream ss;
     206             :             ss << "div { z-index: 10 "
     207           4 :                << op[idx].f_operator
     208           4 :                << " 10 ? 9 : 5; }";
     209          12 :             csspp::position pos("test.css");
     210           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     211             : 
     212           8 :             csspp::parser p(l);
     213             : 
     214           4 :             csspp::node::pointer_t n(p.stylesheet());
     215             : 
     216           4 :             csspp::compiler c;
     217           4 :             c.set_root(n);
     218           4 :             c.set_date_time_variables(csspp_test::get_now());
     219           4 :             c.add_path(csspp_test::get_script_path());
     220           4 :             c.add_path(csspp_test::get_version_script_path());
     221             : 
     222           4 :             c.compile(false);
     223             : 
     224             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     225             : 
     226             :             // to verify that the result is still an INTEGER we have to
     227             :             // test the root node here
     228           4 :             std::stringstream compiler_out;
     229           4 :             compiler_out << *n;
     230           4 :             VERIFY_TREES(compiler_out.str(),
     231             : 
     232             : "LIST\n"
     233             : + csspp_test::get_default_variables() +
     234             : "  COMPONENT_VALUE\n"
     235             : "    ARG\n"
     236             : "      IDENTIFIER \"div\"\n"
     237             : "    OPEN_CURLYBRACKET B:true\n"
     238             : "      DECLARATION \"z-index\"\n"
     239             : "        ARG\n"
     240             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
     241             : + csspp_test::get_close_comment(true)
     242             : 
     243             :                 );
     244             : 
     245           4 :             std::stringstream assembler_out;
     246           4 :             csspp::assembler a(assembler_out);
     247           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     248             : 
     249             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     250             : 
     251           4 :             CATCH_REQUIRE(assembler_out.str() ==
     252             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
     253             : + csspp_test::get_close_comment()
     254             :                     );
     255             : 
     256           4 :             CATCH_REQUIRE(c.get_root() == n);
     257           4 :         }
     258             :     }
     259          19 :     CATCH_END_SECTION()
     260             : 
     261          19 :     CATCH_START_SECTION("compare 10% ?? 3%")
     262             :     {
     263           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     264             :         {
     265           4 :             std::stringstream ss;
     266             :             ss << "div { z-index: 10% "
     267           4 :                << op[idx].f_operator
     268           4 :                << " 3% ? 9 : 5; }";
     269          12 :             csspp::position pos("test.css");
     270           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     271             : 
     272           8 :             csspp::parser p(l);
     273             : 
     274           4 :             csspp::node::pointer_t n(p.stylesheet());
     275             : 
     276           4 :             csspp::compiler c;
     277           4 :             c.set_root(n);
     278           4 :             c.set_date_time_variables(csspp_test::get_now());
     279           4 :             c.add_path(csspp_test::get_script_path());
     280           4 :             c.add_path(csspp_test::get_version_script_path());
     281             : 
     282           4 :             c.compile(false);
     283             : 
     284             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     285             : 
     286             :             // to verify that the result is still an INTEGER we have to
     287             :             // test the root node here
     288           4 :             std::stringstream compiler_out;
     289           4 :             compiler_out << *n;
     290           4 :             VERIFY_TREES(compiler_out.str(),
     291             : 
     292             : "LIST\n"
     293             : + csspp_test::get_default_variables() +
     294             : "  COMPONENT_VALUE\n"
     295             : "    ARG\n"
     296             : "      IDENTIFIER \"div\"\n"
     297             : "    OPEN_CURLYBRACKET B:true\n"
     298             : "      DECLARATION \"z-index\"\n"
     299             : "        ARG\n"
     300             : "          INTEGER \"\" I:" + std::to_string(!op[idx].f_different_result ? 9 : 5) + "\n"
     301             : + csspp_test::get_close_comment(true)
     302             : 
     303             :                 );
     304             : 
     305           4 :             std::stringstream assembler_out;
     306           4 :             csspp::assembler a(assembler_out);
     307           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     308             : 
     309             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     310             : 
     311           4 :             CATCH_REQUIRE(assembler_out.str() ==
     312             : std::string("div{z-index:") + (!op[idx].f_different_result ? "9" : "5") + "}\n"
     313             : + csspp_test::get_close_comment()
     314             :                     );
     315             : 
     316           4 :             CATCH_REQUIRE(c.get_root() == n);
     317           4 :         }
     318             :     }
     319          19 :     CATCH_END_SECTION()
     320             : 
     321          19 :     CATCH_START_SECTION("compare 3% ?? 10%")
     322             :     {
     323           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     324             :         {
     325           4 :             std::stringstream ss;
     326             :             ss << "div { z-index: 3% "
     327           4 :                << op[idx].f_operator
     328           4 :                << " 10% ? 9 : 5; }";
     329          12 :             csspp::position pos("test.css");
     330           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     331             : 
     332           8 :             csspp::parser p(l);
     333             : 
     334           4 :             csspp::node::pointer_t n(p.stylesheet());
     335             : 
     336           4 :             csspp::compiler c;
     337           4 :             c.set_root(n);
     338           4 :             c.set_date_time_variables(csspp_test::get_now());
     339           4 :             c.add_path(csspp_test::get_script_path());
     340           4 :             c.add_path(csspp_test::get_version_script_path());
     341             : 
     342           4 :             c.compile(false);
     343             : 
     344             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     345             : 
     346             :             // to verify that the result is still an INTEGER we have to
     347             :             // test the root node here
     348           4 :             std::stringstream compiler_out;
     349           4 :             compiler_out << *n;
     350           4 :             VERIFY_TREES(compiler_out.str(),
     351             : 
     352             : "LIST\n"
     353             : + csspp_test::get_default_variables() +
     354             : "  COMPONENT_VALUE\n"
     355             : "    ARG\n"
     356             : "      IDENTIFIER \"div\"\n"
     357             : "    OPEN_CURLYBRACKET B:true\n"
     358             : "      DECLARATION \"z-index\"\n"
     359             : "        ARG\n"
     360             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_different_result ? 9 : 5) + "\n"
     361             : + csspp_test::get_close_comment(true)
     362             : 
     363             :                 );
     364             : 
     365           4 :             std::stringstream assembler_out;
     366           4 :             csspp::assembler a(assembler_out);
     367           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     368             : 
     369             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     370             : 
     371           4 :             CATCH_REQUIRE(assembler_out.str() ==
     372             : std::string("div{z-index:") + (op[idx].f_different_result ? "9" : "5") + "}\n"
     373             : + csspp_test::get_close_comment()
     374             :                     );
     375             : 
     376           4 :             CATCH_REQUIRE(c.get_root() == n);
     377           4 :         }
     378             :     }
     379          19 :     CATCH_END_SECTION()
     380             : 
     381          19 :     CATCH_START_SECTION("compare 10% ?? 10%")
     382             :     {
     383           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     384             :         {
     385           4 :             std::stringstream ss;
     386             :             ss << "div { z-index: 10% "
     387           4 :                << op[idx].f_operator
     388           4 :                << " 10% ? 9 : 5; }";
     389          12 :             csspp::position pos("test.css");
     390           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     391             : 
     392           8 :             csspp::parser p(l);
     393             : 
     394           4 :             csspp::node::pointer_t n(p.stylesheet());
     395             : 
     396           4 :             csspp::compiler c;
     397           4 :             c.set_root(n);
     398           4 :             c.set_date_time_variables(csspp_test::get_now());
     399           4 :             c.add_path(csspp_test::get_script_path());
     400           4 :             c.add_path(csspp_test::get_version_script_path());
     401             : 
     402           4 :             c.compile(false);
     403             : 
     404             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     405             : 
     406             :             // to verify that the result is still an INTEGER we have to
     407             :             // test the root node here
     408           4 :             std::stringstream compiler_out;
     409           4 :             compiler_out << *n;
     410           4 :             VERIFY_TREES(compiler_out.str(),
     411             : 
     412             : "LIST\n"
     413             : + csspp_test::get_default_variables() +
     414             : "  COMPONENT_VALUE\n"
     415             : "    ARG\n"
     416             : "      IDENTIFIER \"div\"\n"
     417             : "    OPEN_CURLYBRACKET B:true\n"
     418             : "      DECLARATION \"z-index\"\n"
     419             : "        ARG\n"
     420             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
     421             : + csspp_test::get_close_comment(true)
     422             : 
     423             :                 );
     424             : 
     425           4 :             std::stringstream assembler_out;
     426           4 :             csspp::assembler a(assembler_out);
     427           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     428             : 
     429             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     430             : 
     431           4 :             CATCH_REQUIRE(assembler_out.str() ==
     432             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
     433             : + csspp_test::get_close_comment()
     434             :                     );
     435             : 
     436           4 :             CATCH_REQUIRE(c.get_root() == n);
     437           4 :         }
     438             :     }
     439          19 :     CATCH_END_SECTION()
     440             : 
     441          19 :     CATCH_START_SECTION("compare 10.5 ?? 3.15")
     442             :     {
     443           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     444             :         {
     445           4 :             std::stringstream ss;
     446             :             ss << "div { z-index: 10.5 "
     447           4 :                << op[idx].f_operator
     448           4 :                << " 3.15 ? 9 : 5; }";
     449          12 :             csspp::position pos("test.css");
     450           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     451             : 
     452           8 :             csspp::parser p(l);
     453             : 
     454           4 :             csspp::node::pointer_t n(p.stylesheet());
     455             : 
     456           4 :             csspp::compiler c;
     457           4 :             c.set_root(n);
     458           4 :             c.set_date_time_variables(csspp_test::get_now());
     459           4 :             c.add_path(csspp_test::get_script_path());
     460           4 :             c.add_path(csspp_test::get_version_script_path());
     461             : 
     462           4 :             c.compile(false);
     463             : 
     464             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     465             : 
     466             :             // to verify that the result is still an INTEGER we have to
     467             :             // test the root node here
     468           4 :             std::stringstream compiler_out;
     469           4 :             compiler_out << *n;
     470           4 :             VERIFY_TREES(compiler_out.str(),
     471             : 
     472             : "LIST\n"
     473             : + csspp_test::get_default_variables() +
     474             : "  COMPONENT_VALUE\n"
     475             : "    ARG\n"
     476             : "      IDENTIFIER \"div\"\n"
     477             : "    OPEN_CURLYBRACKET B:true\n"
     478             : "      DECLARATION \"z-index\"\n"
     479             : "        ARG\n"
     480             : "          INTEGER \"\" I:" + std::to_string(!op[idx].f_different_result ? 9 : 5) + "\n"
     481             : + csspp_test::get_close_comment(true)
     482             : 
     483             :                 );
     484             : 
     485           4 :             std::stringstream assembler_out;
     486           4 :             csspp::assembler a(assembler_out);
     487           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     488             : 
     489             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     490             : 
     491           4 :             CATCH_REQUIRE(assembler_out.str() ==
     492             : std::string("div{z-index:") + (!op[idx].f_different_result ? "9" : "5") + "}\n"
     493             : + csspp_test::get_close_comment()
     494             :                     );
     495             : 
     496           4 :             CATCH_REQUIRE(c.get_root() == n);
     497           4 :         }
     498             :     }
     499          19 :     CATCH_END_SECTION()
     500             : 
     501          19 :     CATCH_START_SECTION("compare 3.15 ?? 10.5")
     502             :     {
     503           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     504             :         {
     505           4 :             std::stringstream ss;
     506             :             ss << "div { z-index: 3.15 "
     507           4 :                << op[idx].f_operator
     508           4 :                << " 10.5 ? 9 : 5; }";
     509          12 :             csspp::position pos("test.css");
     510           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     511             : 
     512           8 :             csspp::parser p(l);
     513             : 
     514           4 :             csspp::node::pointer_t n(p.stylesheet());
     515             : 
     516           4 :             csspp::compiler c;
     517           4 :             c.set_root(n);
     518           4 :             c.set_date_time_variables(csspp_test::get_now());
     519           4 :             c.add_path(csspp_test::get_script_path());
     520           4 :             c.add_path(csspp_test::get_version_script_path());
     521             : 
     522           4 :             c.compile(false);
     523             : 
     524             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     525             : 
     526             :             // to verify that the result is still an INTEGER we have to
     527             :             // test the root node here
     528           4 :             std::stringstream compiler_out;
     529           4 :             compiler_out << *n;
     530           4 :             VERIFY_TREES(compiler_out.str(),
     531             : 
     532             : "LIST\n"
     533             : + csspp_test::get_default_variables() +
     534             : "  COMPONENT_VALUE\n"
     535             : "    ARG\n"
     536             : "      IDENTIFIER \"div\"\n"
     537             : "    OPEN_CURLYBRACKET B:true\n"
     538             : "      DECLARATION \"z-index\"\n"
     539             : "        ARG\n"
     540             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_different_result ? 9 : 5) + "\n"
     541             : + csspp_test::get_close_comment(true)
     542             : 
     543             :                 );
     544             : 
     545           4 :             std::stringstream assembler_out;
     546           4 :             csspp::assembler a(assembler_out);
     547           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     548             : 
     549             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     550             : 
     551           4 :             CATCH_REQUIRE(assembler_out.str() ==
     552             : std::string("div{z-index:") + (op[idx].f_different_result ? "9" : "5") + "}\n"
     553             : + csspp_test::get_close_comment()
     554             :                     );
     555             : 
     556           4 :             CATCH_REQUIRE(c.get_root() == n);
     557           4 :         }
     558             :     }
     559          19 :     CATCH_END_SECTION()
     560             : 
     561          19 :     CATCH_START_SECTION("compare 10.5 ?? 10.5")
     562             :     {
     563           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     564             :         {
     565           4 :             std::stringstream ss;
     566             :             ss << "div { z-index: 10.5 "
     567           4 :                << op[idx].f_operator
     568           4 :                << " 10.5 ? 9 : 5; }";
     569          12 :             csspp::position pos("test.css");
     570           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     571             : 
     572           8 :             csspp::parser p(l);
     573             : 
     574           4 :             csspp::node::pointer_t n(p.stylesheet());
     575             : 
     576           4 :             csspp::compiler c;
     577           4 :             c.set_root(n);
     578           4 :             c.set_date_time_variables(csspp_test::get_now());
     579           4 :             c.add_path(csspp_test::get_script_path());
     580           4 :             c.add_path(csspp_test::get_version_script_path());
     581             : 
     582           4 :             c.compile(false);
     583             : 
     584             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     585             : 
     586             :             // to verify that the result is still an INTEGER we have to
     587             :             // test the root node here
     588           4 :             std::stringstream compiler_out;
     589           4 :             compiler_out << *n;
     590           4 :             VERIFY_TREES(compiler_out.str(),
     591             : 
     592             : "LIST\n"
     593             : + csspp_test::get_default_variables() +
     594             : "  COMPONENT_VALUE\n"
     595             : "    ARG\n"
     596             : "      IDENTIFIER \"div\"\n"
     597             : "    OPEN_CURLYBRACKET B:true\n"
     598             : "      DECLARATION \"z-index\"\n"
     599             : "        ARG\n"
     600             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
     601             : + csspp_test::get_close_comment(true)
     602             : 
     603             :                 );
     604             : 
     605           4 :             std::stringstream assembler_out;
     606           4 :             csspp::assembler a(assembler_out);
     607           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     608             : 
     609             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     610             : 
     611           4 :             CATCH_REQUIRE(assembler_out.str() ==
     612             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
     613             : + csspp_test::get_close_comment()
     614             :                     );
     615             : 
     616           4 :             CATCH_REQUIRE(c.get_root() == n);
     617           4 :         }
     618             :     }
     619          19 :     CATCH_END_SECTION()
     620             : 
     621          19 :     CATCH_START_SECTION("compare 10 ?? 3.15")
     622             :     {
     623           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     624             :         {
     625           4 :             std::stringstream ss;
     626             :             ss << "div { z-index: 10 "
     627           4 :                << op[idx].f_operator
     628           4 :                << " 3.15 ? 9 : 5; }";
     629          12 :             csspp::position pos("test.css");
     630           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     631             : 
     632           8 :             csspp::parser p(l);
     633             : 
     634           4 :             csspp::node::pointer_t n(p.stylesheet());
     635             : 
     636           4 :             csspp::compiler c;
     637           4 :             c.set_root(n);
     638           4 :             c.set_date_time_variables(csspp_test::get_now());
     639           4 :             c.add_path(csspp_test::get_script_path());
     640           4 :             c.add_path(csspp_test::get_version_script_path());
     641             : 
     642           4 :             c.compile(false);
     643             : 
     644             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     645             : 
     646             :             // to verify that the result is still an INTEGER we have to
     647             :             // test the root node here
     648           4 :             std::stringstream compiler_out;
     649           4 :             compiler_out << *n;
     650           4 :             VERIFY_TREES(compiler_out.str(),
     651             : 
     652             : "LIST\n"
     653             : + csspp_test::get_default_variables() +
     654             : "  COMPONENT_VALUE\n"
     655             : "    ARG\n"
     656             : "      IDENTIFIER \"div\"\n"
     657             : "    OPEN_CURLYBRACKET B:true\n"
     658             : "      DECLARATION \"z-index\"\n"
     659             : "        ARG\n"
     660             : "          INTEGER \"\" I:" + std::to_string(!op[idx].f_different_result ? 9 : 5) + "\n"
     661             : + csspp_test::get_close_comment(true)
     662             : 
     663             :                 );
     664             : 
     665           4 :             std::stringstream assembler_out;
     666           4 :             csspp::assembler a(assembler_out);
     667           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     668             : 
     669             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     670             : 
     671           4 :             CATCH_REQUIRE(assembler_out.str() ==
     672             : std::string("div{z-index:") + (!op[idx].f_different_result ? "9" : "5") + "}\n"
     673             : + csspp_test::get_close_comment()
     674             :                     );
     675             : 
     676           4 :             CATCH_REQUIRE(c.get_root() == n);
     677           4 :         }
     678             :     }
     679          19 :     CATCH_END_SECTION()
     680             : 
     681          19 :     CATCH_START_SECTION("compare 3.15 ?? 10")
     682             :     {
     683           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     684             :         {
     685           4 :             std::stringstream ss;
     686             :             ss << "div { z-index: 3.15 "
     687           4 :                << op[idx].f_operator
     688           4 :                << " 10 ? 9 : 5; }";
     689          12 :             csspp::position pos("test.css");
     690           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     691             : 
     692           8 :             csspp::parser p(l);
     693             : 
     694           4 :             csspp::node::pointer_t n(p.stylesheet());
     695             : 
     696           4 :             csspp::compiler c;
     697           4 :             c.set_root(n);
     698           4 :             c.set_date_time_variables(csspp_test::get_now());
     699           4 :             c.add_path(csspp_test::get_script_path());
     700           4 :             c.add_path(csspp_test::get_version_script_path());
     701             : 
     702           4 :             c.compile(false);
     703             : 
     704             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     705             : 
     706             :             // to verify that the result is still an INTEGER we have to
     707             :             // test the root node here
     708           4 :             std::stringstream compiler_out;
     709           4 :             compiler_out << *n;
     710           4 :             VERIFY_TREES(compiler_out.str(),
     711             : 
     712             : "LIST\n"
     713             : + csspp_test::get_default_variables() +
     714             : "  COMPONENT_VALUE\n"
     715             : "    ARG\n"
     716             : "      IDENTIFIER \"div\"\n"
     717             : "    OPEN_CURLYBRACKET B:true\n"
     718             : "      DECLARATION \"z-index\"\n"
     719             : "        ARG\n"
     720             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_different_result ? 9 : 5) + "\n"
     721             : + csspp_test::get_close_comment(true)
     722             : 
     723             :                 );
     724             : 
     725           4 :             std::stringstream assembler_out;
     726           4 :             csspp::assembler a(assembler_out);
     727           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     728             : 
     729             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     730             : 
     731           4 :             CATCH_REQUIRE(assembler_out.str() ==
     732             : std::string("div{z-index:") + (op[idx].f_different_result ? "9" : "5") + "}\n"
     733             : + csspp_test::get_close_comment()
     734             :                     );
     735             : 
     736           4 :             CATCH_REQUIRE(c.get_root() == n);
     737           4 :         }
     738             :     }
     739          19 :     CATCH_END_SECTION()
     740             : 
     741          19 :     CATCH_START_SECTION("compare 10 ?? 10.0")
     742             :     {
     743           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     744             :         {
     745           4 :             std::stringstream ss;
     746             :             ss << "div { z-index: 10 "
     747           4 :                << op[idx].f_operator
     748           4 :                << " 10.0 ? 9 : 5; }";
     749          12 :             csspp::position pos("test.css");
     750           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     751             : 
     752           8 :             csspp::parser p(l);
     753             : 
     754           4 :             csspp::node::pointer_t n(p.stylesheet());
     755             : 
     756           4 :             csspp::compiler c;
     757           4 :             c.set_root(n);
     758           4 :             c.set_date_time_variables(csspp_test::get_now());
     759           4 :             c.add_path(csspp_test::get_script_path());
     760           4 :             c.add_path(csspp_test::get_version_script_path());
     761             : 
     762           4 :             c.compile(false);
     763             : 
     764             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     765             : 
     766             :             // to verify that the result is still an INTEGER we have to
     767             :             // test the root node here
     768           4 :             std::stringstream compiler_out;
     769           4 :             compiler_out << *n;
     770           4 :             VERIFY_TREES(compiler_out.str(),
     771             : 
     772             : "LIST\n"
     773             : + csspp_test::get_default_variables() +
     774             : "  COMPONENT_VALUE\n"
     775             : "    ARG\n"
     776             : "      IDENTIFIER \"div\"\n"
     777             : "    OPEN_CURLYBRACKET B:true\n"
     778             : "      DECLARATION \"z-index\"\n"
     779             : "        ARG\n"
     780             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
     781             : + csspp_test::get_close_comment(true)
     782             : 
     783             :                 );
     784             : 
     785           4 :             std::stringstream assembler_out;
     786           4 :             csspp::assembler a(assembler_out);
     787           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     788             : 
     789             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     790             : 
     791           4 :             CATCH_REQUIRE(assembler_out.str() ==
     792             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
     793             : + csspp_test::get_close_comment()
     794             :                     );
     795             : 
     796           4 :             CATCH_REQUIRE(c.get_root() == n);
     797           4 :         }
     798             :     }
     799          19 :     CATCH_END_SECTION()
     800             : 
     801          19 :     CATCH_START_SECTION("compare 10.5 ?? 3")
     802             :     {
     803           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     804             :         {
     805           4 :             std::stringstream ss;
     806             :             ss << "div { z-index: 10.5 "
     807           4 :                << op[idx].f_operator
     808           4 :                << " 3 ? 9 : 5; }";
     809          12 :             csspp::position pos("test.css");
     810           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     811             : 
     812           8 :             csspp::parser p(l);
     813             : 
     814           4 :             csspp::node::pointer_t n(p.stylesheet());
     815             : 
     816           4 :             csspp::compiler c;
     817           4 :             c.set_root(n);
     818           4 :             c.set_date_time_variables(csspp_test::get_now());
     819           4 :             c.add_path(csspp_test::get_script_path());
     820           4 :             c.add_path(csspp_test::get_version_script_path());
     821             : 
     822           4 :             c.compile(false);
     823             : 
     824             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     825             : 
     826             :             // to verify that the result is still an INTEGER we have to
     827             :             // test the root node here
     828           4 :             std::stringstream compiler_out;
     829           4 :             compiler_out << *n;
     830           4 :             VERIFY_TREES(compiler_out.str(),
     831             : 
     832             : "LIST\n"
     833             : + csspp_test::get_default_variables() +
     834             : "  COMPONENT_VALUE\n"
     835             : "    ARG\n"
     836             : "      IDENTIFIER \"div\"\n"
     837             : "    OPEN_CURLYBRACKET B:true\n"
     838             : "      DECLARATION \"z-index\"\n"
     839             : "        ARG\n"
     840             : "          INTEGER \"\" I:" + std::to_string(!op[idx].f_different_result ? 9 : 5) + "\n"
     841             : + csspp_test::get_close_comment(true)
     842             : 
     843             :                 );
     844             : 
     845           4 :             std::stringstream assembler_out;
     846           4 :             csspp::assembler a(assembler_out);
     847           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     848             : 
     849             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     850             : 
     851           4 :             CATCH_REQUIRE(assembler_out.str() ==
     852             : std::string("div{z-index:") + (!op[idx].f_different_result ? "9" : "5") + "}\n"
     853             : + csspp_test::get_close_comment()
     854             :                     );
     855             : 
     856           4 :             CATCH_REQUIRE(c.get_root() == n);
     857           4 :         }
     858             :     }
     859          19 :     CATCH_END_SECTION()
     860             : 
     861          19 :     CATCH_START_SECTION("compare 3 ?? 10.5")
     862             :     {
     863           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     864             :         {
     865           4 :             std::stringstream ss;
     866             :             ss << "div { z-index: 3 "
     867           4 :                << op[idx].f_operator
     868           4 :                << " 10.5 ? 9 : 5; }";
     869          12 :             csspp::position pos("test.css");
     870           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     871             : 
     872           8 :             csspp::parser p(l);
     873             : 
     874           4 :             csspp::node::pointer_t n(p.stylesheet());
     875             : 
     876           4 :             csspp::compiler c;
     877           4 :             c.set_root(n);
     878           4 :             c.set_date_time_variables(csspp_test::get_now());
     879           4 :             c.add_path(csspp_test::get_script_path());
     880           4 :             c.add_path(csspp_test::get_version_script_path());
     881             : 
     882           4 :             c.compile(false);
     883             : 
     884             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     885             : 
     886             :             // to verify that the result is still an INTEGER we have to
     887             :             // test the root node here
     888           4 :             std::stringstream compiler_out;
     889           4 :             compiler_out << *n;
     890           4 :             VERIFY_TREES(compiler_out.str(),
     891             : 
     892             : "LIST\n"
     893             : + csspp_test::get_default_variables() +
     894             : "  COMPONENT_VALUE\n"
     895             : "    ARG\n"
     896             : "      IDENTIFIER \"div\"\n"
     897             : "    OPEN_CURLYBRACKET B:true\n"
     898             : "      DECLARATION \"z-index\"\n"
     899             : "        ARG\n"
     900             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_different_result ? 9 : 5) + "\n"
     901             : + csspp_test::get_close_comment(true)
     902             : 
     903             :                 );
     904             : 
     905           4 :             std::stringstream assembler_out;
     906           4 :             csspp::assembler a(assembler_out);
     907           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     908             : 
     909             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     910             : 
     911           4 :             CATCH_REQUIRE(assembler_out.str() ==
     912             : std::string("div{z-index:") + (op[idx].f_different_result ? "9" : "5") + "}\n"
     913             : + csspp_test::get_close_comment()
     914             :                     );
     915             : 
     916           4 :             CATCH_REQUIRE(c.get_root() == n);
     917           4 :         }
     918             :     }
     919          19 :     CATCH_END_SECTION()
     920             : 
     921          19 :     CATCH_START_SECTION("compare 10 ?? 10.0")
     922             :     {
     923           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     924             :         {
     925           4 :             std::stringstream ss;
     926             :             ss << "div { z-index: 10.0 "
     927           4 :                << op[idx].f_operator
     928           4 :                << " 10 ? 9 : 5; }";
     929          12 :             csspp::position pos("test.css");
     930           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     931             : 
     932           8 :             csspp::parser p(l);
     933             : 
     934           4 :             csspp::node::pointer_t n(p.stylesheet());
     935             : 
     936           4 :             csspp::compiler c;
     937           4 :             c.set_root(n);
     938           4 :             c.set_date_time_variables(csspp_test::get_now());
     939           4 :             c.add_path(csspp_test::get_script_path());
     940           4 :             c.add_path(csspp_test::get_version_script_path());
     941             : 
     942           4 :             c.compile(false);
     943             : 
     944             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
     945             : 
     946             :             // to verify that the result is still an INTEGER we have to
     947             :             // test the root node here
     948           4 :             std::stringstream compiler_out;
     949           4 :             compiler_out << *n;
     950           4 :             VERIFY_TREES(compiler_out.str(),
     951             : 
     952             : "LIST\n"
     953             : + csspp_test::get_default_variables() +
     954             : "  COMPONENT_VALUE\n"
     955             : "    ARG\n"
     956             : "      IDENTIFIER \"div\"\n"
     957             : "    OPEN_CURLYBRACKET B:true\n"
     958             : "      DECLARATION \"z-index\"\n"
     959             : "        ARG\n"
     960             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
     961             : + csspp_test::get_close_comment(true)
     962             : 
     963             :                 );
     964             : 
     965           4 :             std::stringstream assembler_out;
     966           4 :             csspp::assembler a(assembler_out);
     967           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
     968             : 
     969             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
     970             : 
     971           4 :             CATCH_REQUIRE(assembler_out.str() ==
     972             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
     973             : + csspp_test::get_close_comment()
     974             :                     );
     975             : 
     976           4 :             CATCH_REQUIRE(c.get_root() == n);
     977           4 :         }
     978             :     }
     979          19 :     CATCH_END_SECTION()
     980             : 
     981          19 :     CATCH_START_SECTION("compare true ?? false")
     982             :     {
     983           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
     984             :         {
     985           4 :             std::stringstream ss;
     986             :             ss << "div { z-index: false "
     987           4 :                << op[idx].f_operator
     988           4 :                << " true ? 9 : 5; }";
     989          12 :             csspp::position pos("test.css");
     990           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
     991             : 
     992           8 :             csspp::parser p(l);
     993             : 
     994           4 :             csspp::node::pointer_t n(p.stylesheet());
     995             : 
     996           4 :             csspp::compiler c;
     997           4 :             c.set_root(n);
     998           4 :             c.set_date_time_variables(csspp_test::get_now());
     999           4 :             c.add_path(csspp_test::get_script_path());
    1000           4 :             c.add_path(csspp_test::get_version_script_path());
    1001             : 
    1002           4 :             c.compile(false);
    1003             : 
    1004             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1005             : 
    1006             :             // to verify that the result is still an INTEGER we have to
    1007             :             // test the root node here
    1008           4 :             std::stringstream compiler_out;
    1009           4 :             compiler_out << *n;
    1010           4 :             VERIFY_TREES(compiler_out.str(),
    1011             : 
    1012             : "LIST\n"
    1013             : + csspp_test::get_default_variables() +
    1014             : "  COMPONENT_VALUE\n"
    1015             : "    ARG\n"
    1016             : "      IDENTIFIER \"div\"\n"
    1017             : "    OPEN_CURLYBRACKET B:true\n"
    1018             : "      DECLARATION \"z-index\"\n"
    1019             : "        ARG\n"
    1020             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_different_result ? 9 : 5) + "\n"
    1021             : + csspp_test::get_close_comment(true)
    1022             : 
    1023             :                 );
    1024             : 
    1025           4 :             std::stringstream assembler_out;
    1026           4 :             csspp::assembler a(assembler_out);
    1027           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
    1028             : 
    1029             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
    1030             : 
    1031           4 :             CATCH_REQUIRE(assembler_out.str() ==
    1032             : std::string("div{z-index:") + (op[idx].f_different_result ? "9" : "5") + "}\n"
    1033             : + csspp_test::get_close_comment()
    1034             :                     );
    1035             : 
    1036           4 :             CATCH_REQUIRE(c.get_root() == n);
    1037           4 :         }
    1038             : 
    1039           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1040             :         {
    1041           4 :             std::stringstream ss;
    1042             :             ss << "div { z-index: true "
    1043           4 :                << op[idx].f_operator
    1044           4 :                << " false ? 9 : 5; }";
    1045          12 :             csspp::position pos("test.css");
    1046           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1047             : 
    1048           8 :             csspp::parser p(l);
    1049             : 
    1050           4 :             csspp::node::pointer_t n(p.stylesheet());
    1051             : 
    1052           4 :             csspp::compiler c;
    1053           4 :             c.set_root(n);
    1054           4 :             c.set_date_time_variables(csspp_test::get_now());
    1055           4 :             c.add_path(csspp_test::get_script_path());
    1056           4 :             c.add_path(csspp_test::get_version_script_path());
    1057             : 
    1058           4 :             c.compile(false);
    1059             : 
    1060             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1061             : 
    1062             :             // to verify that the result is still an INTEGER we have to
    1063             :             // test the root node here
    1064           4 :             std::stringstream compiler_out;
    1065           4 :             compiler_out << *n;
    1066           4 :             VERIFY_TREES(compiler_out.str(),
    1067             : 
    1068             : "LIST\n"
    1069             : + csspp_test::get_default_variables() +
    1070             : "  COMPONENT_VALUE\n"
    1071             : "    ARG\n"
    1072             : "      IDENTIFIER \"div\"\n"
    1073             : "    OPEN_CURLYBRACKET B:true\n"
    1074             : "      DECLARATION \"z-index\"\n"
    1075             : "        ARG\n"
    1076             : "          INTEGER \"\" I:" + std::to_string(!op[idx].f_different_result ? 9 : 5) + "\n"
    1077             : + csspp_test::get_close_comment(true)
    1078             : 
    1079             :                 );
    1080             : 
    1081           4 :             std::stringstream assembler_out;
    1082           4 :             csspp::assembler a(assembler_out);
    1083           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
    1084             : 
    1085             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
    1086             : 
    1087           4 :             CATCH_REQUIRE(assembler_out.str() ==
    1088             : std::string("div{z-index:") + (!op[idx].f_different_result ? "9" : "5") + "}\n"
    1089             : + csspp_test::get_close_comment()
    1090             :                     );
    1091             : 
    1092           4 :             CATCH_REQUIRE(c.get_root() == n);
    1093           4 :         }
    1094             : 
    1095           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1096             :         {
    1097           4 :             std::stringstream ss;
    1098             :             ss << "div { z-index: true "
    1099           4 :                << op[idx].f_operator
    1100           4 :                << " true ? 9 : 5; }";
    1101          12 :             csspp::position pos("test.css");
    1102           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1103             : 
    1104           8 :             csspp::parser p(l);
    1105             : 
    1106           4 :             csspp::node::pointer_t n(p.stylesheet());
    1107             : 
    1108           4 :             csspp::compiler c;
    1109           4 :             c.set_root(n);
    1110           4 :             c.set_date_time_variables(csspp_test::get_now());
    1111           4 :             c.add_path(csspp_test::get_script_path());
    1112           4 :             c.add_path(csspp_test::get_version_script_path());
    1113             : 
    1114           4 :             c.compile(false);
    1115             : 
    1116             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1117             : 
    1118             :             // to verify that the result is still an INTEGER we have to
    1119             :             // test the root node here
    1120           4 :             std::stringstream compiler_out;
    1121           4 :             compiler_out << *n;
    1122           4 :             VERIFY_TREES(compiler_out.str(),
    1123             : 
    1124             : "LIST\n"
    1125             : + csspp_test::get_default_variables() +
    1126             : "  COMPONENT_VALUE\n"
    1127             : "    ARG\n"
    1128             : "      IDENTIFIER \"div\"\n"
    1129             : "    OPEN_CURLYBRACKET B:true\n"
    1130             : "      DECLARATION \"z-index\"\n"
    1131             : "        ARG\n"
    1132             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
    1133             : + csspp_test::get_close_comment(true)
    1134             : 
    1135             :                 );
    1136             : 
    1137           4 :             std::stringstream assembler_out;
    1138           4 :             csspp::assembler a(assembler_out);
    1139           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
    1140             : 
    1141             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
    1142             : 
    1143           4 :             CATCH_REQUIRE(assembler_out.str() ==
    1144             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
    1145             : + csspp_test::get_close_comment()
    1146             :                     );
    1147             : 
    1148           4 :             CATCH_REQUIRE(c.get_root() == n);
    1149           4 :         }
    1150             : 
    1151           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1152             :         {
    1153           4 :             std::stringstream ss;
    1154             :             ss << "div { z-index: false "
    1155           4 :                << op[idx].f_operator
    1156           4 :                << " false ? 9 : 5; }";
    1157          12 :             csspp::position pos("test.css");
    1158           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1159             : 
    1160           8 :             csspp::parser p(l);
    1161             : 
    1162           4 :             csspp::node::pointer_t n(p.stylesheet());
    1163             : 
    1164           4 :             csspp::compiler c;
    1165           4 :             c.set_root(n);
    1166           4 :             c.set_date_time_variables(csspp_test::get_now());
    1167           4 :             c.add_path(csspp_test::get_script_path());
    1168           4 :             c.add_path(csspp_test::get_version_script_path());
    1169             : 
    1170           4 :             c.compile(false);
    1171             : 
    1172             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1173             : 
    1174             :             // to verify that the result is still an INTEGER we have to
    1175             :             // test the root node here
    1176           4 :             std::stringstream compiler_out;
    1177           4 :             compiler_out << *n;
    1178           4 :             VERIFY_TREES(compiler_out.str(),
    1179             : 
    1180             : "LIST\n"
    1181             : + csspp_test::get_default_variables() +
    1182             : "  COMPONENT_VALUE\n"
    1183             : "    ARG\n"
    1184             : "      IDENTIFIER \"div\"\n"
    1185             : "    OPEN_CURLYBRACKET B:true\n"
    1186             : "      DECLARATION \"z-index\"\n"
    1187             : "        ARG\n"
    1188             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
    1189             : + csspp_test::get_close_comment(true)
    1190             : 
    1191             :                 );
    1192             : 
    1193           4 :             std::stringstream assembler_out;
    1194           4 :             csspp::assembler a(assembler_out);
    1195           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
    1196             : 
    1197             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
    1198             : 
    1199           4 :             CATCH_REQUIRE(assembler_out.str() ==
    1200             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
    1201             : + csspp_test::get_close_comment()
    1202             :                     );
    1203             : 
    1204           4 :             CATCH_REQUIRE(c.get_root() == n);
    1205           4 :         }
    1206             :     }
    1207          19 :     CATCH_END_SECTION()
    1208             : 
    1209          19 :     CATCH_START_SECTION("compare 'xyz' ?? 'abc'")
    1210             :     {
    1211           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1212             :         {
    1213           4 :             std::stringstream ss;
    1214             :             ss << "div { z-index: 'xyz' "
    1215           4 :                << op[idx].f_operator
    1216           4 :                << " 'abc' ? 9 : 5; }";
    1217          12 :             csspp::position pos("test.css");
    1218           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1219             : 
    1220           8 :             csspp::parser p(l);
    1221             : 
    1222           4 :             csspp::node::pointer_t n(p.stylesheet());
    1223             : 
    1224           4 :             csspp::compiler c;
    1225           4 :             c.set_root(n);
    1226           4 :             c.set_date_time_variables(csspp_test::get_now());
    1227           4 :             c.add_path(csspp_test::get_script_path());
    1228           4 :             c.add_path(csspp_test::get_version_script_path());
    1229             : 
    1230           4 :             c.compile(false);
    1231             : 
    1232             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1233             : 
    1234             :             // to verify that the result is still an INTEGER we have to
    1235             :             // test the root node here
    1236           4 :             std::stringstream compiler_out;
    1237           4 :             compiler_out << *n;
    1238           4 :             VERIFY_TREES(compiler_out.str(),
    1239             : 
    1240             : "LIST\n"
    1241             : + csspp_test::get_default_variables() +
    1242             : "  COMPONENT_VALUE\n"
    1243             : "    ARG\n"
    1244             : "      IDENTIFIER \"div\"\n"
    1245             : "    OPEN_CURLYBRACKET B:true\n"
    1246             : "      DECLARATION \"z-index\"\n"
    1247             : "        ARG\n"
    1248             : "          INTEGER \"\" I:" + std::to_string(!op[idx].f_different_result ? 9 : 5) + "\n"
    1249             : + csspp_test::get_close_comment(true)
    1250             : 
    1251             :                 );
    1252             : 
    1253           4 :             std::stringstream assembler_out;
    1254           4 :             csspp::assembler a(assembler_out);
    1255           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
    1256             : 
    1257             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
    1258             : 
    1259           4 :             CATCH_REQUIRE(assembler_out.str() ==
    1260             : std::string("div{z-index:") + (!op[idx].f_different_result ? "9" : "5") + "}\n"
    1261             : + csspp_test::get_close_comment()
    1262             :                     );
    1263             : 
    1264           4 :             CATCH_REQUIRE(c.get_root() == n);
    1265           4 :         }
    1266             :     }
    1267          19 :     CATCH_END_SECTION()
    1268             : 
    1269          19 :     CATCH_START_SECTION("compare 'abc' ?? 'xyz'")
    1270             :     {
    1271           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1272             :         {
    1273           4 :             std::stringstream ss;
    1274             :             ss << "div { z-index: 'abc' "
    1275           4 :                << op[idx].f_operator
    1276           4 :                << " 'xyz' ? 9 : 5; }";
    1277          12 :             csspp::position pos("test.css");
    1278           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1279             : 
    1280           8 :             csspp::parser p(l);
    1281             : 
    1282           4 :             csspp::node::pointer_t n(p.stylesheet());
    1283             : 
    1284           4 :             csspp::compiler c;
    1285           4 :             c.set_root(n);
    1286           4 :             c.set_date_time_variables(csspp_test::get_now());
    1287           4 :             c.add_path(csspp_test::get_script_path());
    1288           4 :             c.add_path(csspp_test::get_version_script_path());
    1289             : 
    1290           4 :             c.compile(false);
    1291             : 
    1292             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1293             : 
    1294             :             // to verify that the result is still an INTEGER we have to
    1295             :             // test the root node here
    1296           4 :             std::stringstream compiler_out;
    1297           4 :             compiler_out << *n;
    1298           4 :             VERIFY_TREES(compiler_out.str(),
    1299             : 
    1300             : "LIST\n"
    1301             : + csspp_test::get_default_variables() +
    1302             : "  COMPONENT_VALUE\n"
    1303             : "    ARG\n"
    1304             : "      IDENTIFIER \"div\"\n"
    1305             : "    OPEN_CURLYBRACKET B:true\n"
    1306             : "      DECLARATION \"z-index\"\n"
    1307             : "        ARG\n"
    1308             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_different_result ? 9 : 5) + "\n"
    1309             : + csspp_test::get_close_comment(true)
    1310             : 
    1311             :                 );
    1312             : 
    1313           4 :             std::stringstream assembler_out;
    1314           4 :             csspp::assembler a(assembler_out);
    1315           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
    1316             : 
    1317             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
    1318             : 
    1319           4 :             CATCH_REQUIRE(assembler_out.str() ==
    1320             : std::string("div{z-index:") + (op[idx].f_different_result ? "9" : "5") + "}\n"
    1321             : + csspp_test::get_close_comment()
    1322             :                     );
    1323             : 
    1324           4 :             CATCH_REQUIRE(c.get_root() == n);
    1325           4 :         }
    1326             :     }
    1327          19 :     CATCH_END_SECTION()
    1328             : 
    1329          19 :     CATCH_START_SECTION("compare 'abc' ?? 'abc'")
    1330             :     {
    1331           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1332             :         {
    1333           4 :             std::stringstream ss;
    1334             :             ss << "div { z-index: 'abc' "
    1335           4 :                << op[idx].f_operator
    1336           4 :                << " 'abc' ? 9 : 5; }";
    1337          12 :             csspp::position pos("test.css");
    1338           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1339             : 
    1340           8 :             csspp::parser p(l);
    1341             : 
    1342           4 :             csspp::node::pointer_t n(p.stylesheet());
    1343             : 
    1344           4 :             csspp::compiler c;
    1345           4 :             c.set_root(n);
    1346           4 :             c.set_date_time_variables(csspp_test::get_now());
    1347           4 :             c.add_path(csspp_test::get_script_path());
    1348           4 :             c.add_path(csspp_test::get_version_script_path());
    1349             : 
    1350           4 :             c.compile(false);
    1351             : 
    1352             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1353             : 
    1354             :             // to verify that the result is still an INTEGER we have to
    1355             :             // test the root node here
    1356           4 :             std::stringstream compiler_out;
    1357           4 :             compiler_out << *n;
    1358           4 :             VERIFY_TREES(compiler_out.str(),
    1359             : 
    1360             : "LIST\n"
    1361             : + csspp_test::get_default_variables() +
    1362             : "  COMPONENT_VALUE\n"
    1363             : "    ARG\n"
    1364             : "      IDENTIFIER \"div\"\n"
    1365             : "    OPEN_CURLYBRACKET B:true\n"
    1366             : "      DECLARATION \"z-index\"\n"
    1367             : "        ARG\n"
    1368             : "          INTEGER \"\" I:" + std::to_string(op[idx].f_equal_result ? 9 : 5) + "\n"
    1369             : + csspp_test::get_close_comment(true)
    1370             : 
    1371             :                 );
    1372             : 
    1373           4 :             std::stringstream assembler_out;
    1374           4 :             csspp::assembler a(assembler_out);
    1375           4 :             a.output(n, csspp::output_mode_t::COMPRESSED);
    1376             : 
    1377             : //std::cerr << "----------------- Result is " << static_cast<csspp::output_mode_t>(i) << "\n[" << out.str() << "]\n";
    1378             : 
    1379           4 :             CATCH_REQUIRE(assembler_out.str() ==
    1380             : std::string("div{z-index:") + (op[idx].f_equal_result ? "9" : "5") + "}\n"
    1381             : + csspp_test::get_close_comment()
    1382             :                     );
    1383             : 
    1384           4 :             CATCH_REQUIRE(c.get_root() == n);
    1385           4 :         }
    1386             :     }
    1387          19 :     CATCH_END_SECTION()
    1388             : 
    1389             :     // no error left over
    1390          19 :     VERIFY_ERRORS("");
    1391          19 : }
    1392             : 
    1393           2 : CATCH_TEST_CASE("Expression number/invalid <,<=,>,>= number/invalid", "[expression] [relational] [invalid]")
    1394             : {
    1395           2 :     char const * op[] =
    1396             :     {
    1397             :         "<",
    1398             :         "<=",
    1399             :         ">",
    1400             :         ">="
    1401             :     };
    1402             : 
    1403           2 :     CATCH_START_SECTION("just ? is not a valid number")
    1404             :     {
    1405           1 :         std::stringstream ss;
    1406           1 :         ss << "div { border: ?; }";
    1407           3 :         csspp::position pos("test.css");
    1408           1 :         csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1409             : 
    1410           2 :         csspp::parser p(l);
    1411             : 
    1412           1 :         csspp::node::pointer_t n(p.stylesheet());
    1413             : 
    1414           1 :         csspp::compiler c;
    1415           1 :         c.set_root(n);
    1416           1 :         c.set_date_time_variables(csspp_test::get_now());
    1417           1 :         c.add_path(csspp_test::get_script_path());
    1418           1 :         c.add_path(csspp_test::get_version_script_path());
    1419             : 
    1420           1 :         c.compile(false);
    1421             : 
    1422             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1423             : 
    1424           1 :         VERIFY_ERRORS("test.css(1): error: unsupported type CONDITIONAL as a unary expression token.\n");
    1425             : 
    1426           1 :         CATCH_REQUIRE(c.get_root() == n);
    1427           1 :     }
    1428           2 :     CATCH_END_SECTION()
    1429             : 
    1430           2 :     CATCH_START_SECTION("number ?? ? is invalid")
    1431             :     {
    1432           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1433             :         {
    1434           4 :             std::stringstream ss;
    1435             :             ss << "div { width: 10px "
    1436             :                << op[idx]
    1437           4 :                << " ?; }";
    1438          12 :             csspp::position pos("test.css");
    1439           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1440             : 
    1441           8 :             csspp::parser p(l);
    1442             : 
    1443           4 :             csspp::node::pointer_t n(p.stylesheet());
    1444             : 
    1445           4 :             csspp::compiler c;
    1446           4 :             c.set_root(n);
    1447           4 :             c.set_date_time_variables(csspp_test::get_now());
    1448           4 :             c.add_path(csspp_test::get_script_path());
    1449           4 :             c.add_path(csspp_test::get_version_script_path());
    1450             : 
    1451           4 :             c.compile(false);
    1452             : 
    1453             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1454             : 
    1455           4 :             VERIFY_ERRORS("test.css(1): error: unsupported type CONDITIONAL as a unary expression token.\n");
    1456             : 
    1457           4 :             CATCH_REQUIRE(c.get_root() == n);
    1458           4 :         }
    1459             :     }
    1460           2 :     CATCH_END_SECTION()
    1461             : 
    1462             :     // no error left over
    1463           2 :     VERIFY_ERRORS("");
    1464           2 : }
    1465             : 
    1466           2 : CATCH_TEST_CASE("Relational expressions with invalid dimensions or decimal numbers", "[expression] [relational] [invalid]")
    1467             : {
    1468           2 :     char const * op[] =
    1469             :     {
    1470             :         "<",
    1471             :         "<=",
    1472             :         ">",
    1473             :         ">="
    1474             :     };
    1475             : 
    1476           2 :     CATCH_START_SECTION("left and right must have the same dimension")
    1477             :     {
    1478           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1479             :         {
    1480           4 :             std::stringstream ss;
    1481             :             ss << "div { border: 3px "
    1482             :                << op[idx]
    1483           4 :                << " 2em; }";
    1484          12 :             csspp::position pos("test.css");
    1485           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1486             : 
    1487           8 :             csspp::parser p(l);
    1488             : 
    1489           4 :             csspp::node::pointer_t n(p.stylesheet());
    1490             : 
    1491           4 :             csspp::compiler c;
    1492           4 :             c.set_root(n);
    1493           4 :             c.set_date_time_variables(csspp_test::get_now());
    1494           4 :             c.add_path(csspp_test::get_script_path());
    1495           4 :             c.add_path(csspp_test::get_version_script_path());
    1496             : 
    1497           4 :             c.compile(false);
    1498             : 
    1499             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1500             : 
    1501           4 :             VERIFY_ERRORS("test.css(1): error: incompatible types or dimensions between INTEGER and INTEGER for operator '=', '!=', '<', '<=', '>', '>=', '~=', '^=', '$=', '*=', or '|='.\n");
    1502             : 
    1503           4 :             CATCH_REQUIRE(c.get_root() == n);
    1504           4 :         }
    1505             :     }
    1506           2 :     CATCH_END_SECTION()
    1507             : 
    1508           2 :     CATCH_START_SECTION("try again with a percent number")
    1509             :     {
    1510           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1511             :         {
    1512           4 :             std::stringstream ss;
    1513             :             ss << "div { z-index: 10 "
    1514             :                << op[idx]
    1515           4 :                << " 5%; }";
    1516          12 :             csspp::position pos("test.css");
    1517           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1518             : 
    1519           8 :             csspp::parser p(l);
    1520             : 
    1521           4 :             csspp::node::pointer_t n(p.stylesheet());
    1522             : 
    1523           4 :             csspp::compiler c;
    1524           4 :             c.set_root(n);
    1525           4 :             c.set_date_time_variables(csspp_test::get_now());
    1526           4 :             c.add_path(csspp_test::get_script_path());
    1527           4 :             c.add_path(csspp_test::get_version_script_path());
    1528             : 
    1529           4 :             c.compile(false);
    1530             : 
    1531             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1532             : 
    1533           4 :             VERIFY_ERRORS(
    1534             :                     "test.css(1): error: incompatible types or dimensions between INTEGER and PERCENT for operator '=', '!=', '<', '<=', '>', '>=', '~=', '^=', '$=', '*=', or '|='.\n"
    1535             :                 );
    1536             : 
    1537           4 :             CATCH_REQUIRE(c.get_root() == n);
    1538           4 :         }
    1539             : 
    1540           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1541             :         {
    1542           4 :             std::stringstream ss;
    1543             :             ss << "div { z-index: 10em "
    1544             :                << op[idx]
    1545           4 :                << " 5%; }";
    1546          12 :             csspp::position pos("test.css");
    1547           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1548             : 
    1549           8 :             csspp::parser p(l);
    1550             : 
    1551           4 :             csspp::node::pointer_t n(p.stylesheet());
    1552             : 
    1553           4 :             csspp::compiler c;
    1554           4 :             c.set_root(n);
    1555           4 :             c.set_date_time_variables(csspp_test::get_now());
    1556           4 :             c.add_path(csspp_test::get_script_path());
    1557           4 :             c.add_path(csspp_test::get_version_script_path());
    1558             : 
    1559           4 :             c.compile(false);
    1560             : 
    1561             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1562             : 
    1563           4 :             VERIFY_ERRORS("test.css(1): error: incompatible types or dimensions between INTEGER and PERCENT for operator '=', '!=', '<', '<=', '>', '>=', '~=', '^=', '$=', '*=', or '|='.\n");
    1564             : 
    1565           4 :             CATCH_REQUIRE(c.get_root() == n);
    1566           4 :         }
    1567             : 
    1568           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1569             :         {
    1570           4 :             std::stringstream ss;
    1571             :             ss << "div { z-index: 10% "
    1572             :                << op[idx]
    1573           4 :                << " 5; }";
    1574          12 :             csspp::position pos("test.css");
    1575           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1576             : 
    1577           8 :             csspp::parser p(l);
    1578             : 
    1579           4 :             csspp::node::pointer_t n(p.stylesheet());
    1580             : 
    1581           4 :             csspp::compiler c;
    1582           4 :             c.set_root(n);
    1583           4 :             c.set_date_time_variables(csspp_test::get_now());
    1584           4 :             c.add_path(csspp_test::get_script_path());
    1585           4 :             c.add_path(csspp_test::get_version_script_path());
    1586             : 
    1587           4 :             c.compile(false);
    1588             : 
    1589             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1590             : 
    1591           4 :             VERIFY_ERRORS("test.css(1): error: incompatible types or dimensions between PERCENT and INTEGER for operator '=', '!=', '<', '<=', '>', '>=', '~=', '^=', '$=', '*=', or '|='.\n");
    1592             : 
    1593           4 :             CATCH_REQUIRE(c.get_root() == n);
    1594           4 :         }
    1595             : 
    1596           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1597             :         {
    1598           4 :             std::stringstream ss;
    1599             :             ss << "div { z-index: 10% "
    1600             :                << op[idx]
    1601           4 :                << " 5px; }";
    1602          12 :             csspp::position pos("test.css");
    1603           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1604             : 
    1605           8 :             csspp::parser p(l);
    1606             : 
    1607           4 :             csspp::node::pointer_t n(p.stylesheet());
    1608             : 
    1609           4 :             csspp::compiler c;
    1610           4 :             c.set_root(n);
    1611           4 :             c.set_date_time_variables(csspp_test::get_now());
    1612           4 :             c.add_path(csspp_test::get_script_path());
    1613           4 :             c.add_path(csspp_test::get_version_script_path());
    1614             : 
    1615           4 :             c.compile(false);
    1616             : 
    1617             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1618             : 
    1619           4 :             VERIFY_ERRORS("test.css(1): error: incompatible types or dimensions between PERCENT and INTEGER for operator '=', '!=', '<', '<=', '>', '>=', '~=', '^=', '$=', '*=', or '|='.\n");
    1620             : 
    1621           4 :             CATCH_REQUIRE(c.get_root() == n);
    1622           4 :         }
    1623             :     }
    1624           2 :     CATCH_END_SECTION()
    1625             : 
    1626             :     // no error left over
    1627           2 :     VERIFY_ERRORS("");
    1628           2 : }
    1629             : 
    1630           1 : CATCH_TEST_CASE("Relational expressions with colors fail", "[expression] [relational] [invalid]")
    1631             : {
    1632           1 :     char const * op[] =
    1633             :     {
    1634             :         "<",
    1635             :         "<=",
    1636             :         ">",
    1637             :         ">="
    1638             :     };
    1639             : 
    1640           1 :     CATCH_START_SECTION("color op color always fails")
    1641             :     {
    1642           5 :         for(size_t idx(0); idx < sizeof(op) / sizeof(op[0]); ++idx)
    1643             :         {
    1644           4 :             std::stringstream ss;
    1645             :             ss << "div { border: red "
    1646             :                << op[idx]
    1647           4 :                << " white; }";
    1648          12 :             csspp::position pos("test.css");
    1649           4 :             csspp::lexer::pointer_t l(new csspp::lexer(ss, pos));
    1650             : 
    1651           8 :             csspp::parser p(l);
    1652             : 
    1653           4 :             csspp::node::pointer_t n(p.stylesheet());
    1654             : 
    1655           4 :             csspp::compiler c;
    1656           4 :             c.set_root(n);
    1657           4 :             c.set_date_time_variables(csspp_test::get_now());
    1658           4 :             c.add_path(csspp_test::get_script_path());
    1659           4 :             c.add_path(csspp_test::get_version_script_path());
    1660             : 
    1661           4 :             c.compile(false);
    1662             : 
    1663             : //std::cerr << "Compiler result is: [" << *c.get_root() << "]\n";
    1664             : 
    1665           4 :             VERIFY_ERRORS("test.css(1): error: incompatible types between COLOR and COLOR for operator '<', '<=', '>', or '>='.\n");
    1666             : 
    1667           4 :             CATCH_REQUIRE(c.get_root() == n);
    1668           4 :         }
    1669             :     }
    1670           1 :     CATCH_END_SECTION()
    1671             : 
    1672             :     // no error left over
    1673           1 :     VERIFY_ERRORS("");
    1674           1 : }
    1675             : 
    1676             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.14