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 csspp main unit test. 22 : * 23 : * This test suite uses catch.hpp, for details see: 24 : * 25 : * https://github.com/philsquared/Catch/blob/master/docs/tutorial.md 26 : */ 27 : 28 : // Tell catch we want it to add the runner code in this file. 29 : #define CATCH_CONFIG_RUNNER 30 : 31 : // There seem to be a conflict between our csspp headers and the catch 32 : // environment which ends up throwing an error about a missing noexcept 33 : // 34 : #pragma GCC diagnostic ignored "-Wnoexcept" 35 : 36 : 37 : // csspp 38 : // 39 : #include <csspp/csspp.h> 40 : #include <csspp/error.h> 41 : #include <csspp/node.h> 42 : 43 : 44 : // self 45 : // 46 : #include "catch_main.h" 47 : 48 : 49 : // libexcept 50 : // 51 : #include <libexcept/exception.h> 52 : 53 : 54 : // snapdev 55 : // 56 : #include <snapdev/not_used.h> 57 : 58 : 59 : // C++ 60 : // 61 : #include <cstring> 62 : 63 : 64 : // C 65 : // 66 : #include <stdlib.h> 67 : 68 : 69 : // last include 70 : // 71 : #include <snapdev/poison.h> 72 : 73 : 74 : namespace csspp_test 75 : { 76 : 77 : // static variables 78 : namespace 79 : { 80 : 81 : trace_error * g_trace_error; 82 : 83 : time_t const g_now(1435871798); // 07/02/2015 14:16:38 84 : 85 : } 86 : 87 1 : trace_error::trace_error() 88 : { 89 1 : csspp::error::instance().set_error_stream(m_error_message); 90 1 : } 91 : 92 4543650 : trace_error & trace_error::instance() 93 : { 94 4543650 : if(g_trace_error == nullptr) 95 : { 96 1 : g_trace_error = new trace_error(); 97 : } 98 4543650 : return *g_trace_error; 99 : } 100 : 101 4543649 : void trace_error::expected_error(std::string const & msg, char const * filename, int line) 102 : { 103 4543649 : std::string e(m_error_message.str()); 104 4543649 : m_error_message.str(""); 105 : 106 4543649 : std::string::size_type pos(e.find("/scripts")); 107 4543649 : if(pos != std::string::npos) 108 : { 109 7 : e = e.substr(pos + 1); 110 : } 111 : 112 : //std::cerr << "require " << msg << "\n"; 113 : //std::cerr << " got " << e << "\n"; 114 4543649 : if(e != msg) 115 : { 116 : // print a message otherwise filename & line get lost 117 : std::cerr << filename << "(" << line << "): error: error messages are not equal.\n"; // LCOV_EXCL_LINE 118 : } 119 4543649 : CATCH_REQUIRE(e == msg); 120 9087298 : } 121 : 122 69559 : our_unicode_range_t::our_unicode_range_t(csspp::wide_char_t start, csspp::wide_char_t end) 123 69559 : : f_start(start) 124 69559 : , f_end(end) 125 : { 126 69559 : } 127 : 128 3000 : void our_unicode_range_t::set_start(csspp::wide_char_t start) 129 : { 130 3000 : f_start = start; 131 3000 : } 132 : 133 3000 : void our_unicode_range_t::set_end(csspp::wide_char_t end) 134 : { 135 3000 : f_end = end; 136 3000 : } 137 : 138 0 : void our_unicode_range_t::set_range(csspp::range_value_t range) 139 : { 140 0 : f_start = static_cast<csspp::wide_char_t>(range); 141 0 : f_end = static_cast<csspp::wide_char_t>(range >> 32); 142 0 : } 143 : 144 0 : csspp::wide_char_t our_unicode_range_t::get_start() const 145 : { 146 0 : return f_start; 147 : } 148 : 149 0 : csspp::wide_char_t our_unicode_range_t::get_end() const 150 : { 151 0 : return f_end; 152 : } 153 : 154 207631 : csspp::range_value_t our_unicode_range_t::get_range() const 155 : { 156 207631 : return f_start + (static_cast<csspp::range_value_t>(f_end) << 32); 157 : } 158 : 159 8256 : void compare(std::string const & generated, std::string const & expected, char const * filename, int line) 160 : { 161 8256 : char const *g(generated.c_str()); 162 8256 : char const *e(expected.c_str()); 163 : 164 8256 : int pos(1); 165 4487943 : for(; *g != '\0' && *e != '\0'; ++pos) 166 : { 167 : // one line from the left 168 : char const *start; 169 115697428 : for(start = g; *g != '\n' && *g != '\0'; ++g); 170 8959374 : std::string gs(start, g - start); 171 4479687 : if(*g == '\n') 172 : { 173 4479687 : ++g; 174 : } 175 : 176 : // one line from the right 177 4479687 : start = e; 178 115697428 : for(start = e; *e != '\n' && *e != '\0'; ++e); 179 8959374 : std::string es(start, e - start); 180 4479687 : if(*e == '\n') 181 : { 182 4479687 : ++e; 183 : } 184 : 185 4479687 : if(gs != es) 186 : { 187 : std::cerr << filename << "(" << line << "):error: compare trees: on line " << pos << ": \"" << gs << "\" != \"" << es << "\".\n"; // LCOV_EXCL_LINE 188 : } 189 4479687 : CATCH_REQUIRE(gs == es); 190 4479687 : } 191 : 192 8256 : if(*g != '\0' && *e != '\0') 193 : { 194 : throw std::logic_error("we reached this line when the previous while() implies at least one of g or e is pointing to '\\0'."); // LCOV_EXCL_LINE 195 : } 196 : 197 8256 : if(*g != '\0') 198 : { 199 : std::cerr << filename << "(" << line << "):error: compare trees: on line " << pos << ": end of expected reached, still have \"" << g << "\" left in generated.\n"; // LCOV_EXCL_LINE 200 : } 201 8256 : CATCH_REQUIRE(*g == '\0'); 202 : 203 8256 : if(*e != '\0') 204 : { 205 : std::cerr << filename << "(" << line << "):error: compare trees: on line " << pos << ": end of generated reached, still have \"" << e << "\" left in expected.\n"; // LCOV_EXCL_LINE 206 : } 207 8256 : CATCH_REQUIRE(*e == '\0'); 208 8256 : } 209 : 210 : 211 : std::string g_script_path; 212 : std::string g_version_script_path; 213 : bool g_show_errors; 214 : 215 : 216 9177 : std::string get_script_path() 217 : { 218 9177 : return g_script_path; 219 : } 220 : 221 : 222 9177 : std::string get_version_script_path() 223 : { 224 9177 : return g_version_script_path; 225 : } 226 : 227 : 228 7584 : std::string get_default_variables(default_variables_flags_t const flags) 229 : { 230 : #define STRINGIFY_CONTENT(str) #str 231 : #define STRINGIFY(str) STRINGIFY_CONTENT(str) 232 : return 233 : 234 15168 : std::string() + 235 : 236 : " V:_csspp_day\n" 237 : " LIST\n" 238 : " VARIABLE \"_csspp_day\"\n" 239 : " STRING \"02\"\n" 240 : " V:_csspp_e\n" 241 : " LIST\n" 242 : " VARIABLE \"_csspp_e\"\n" 243 : " DECIMAL_NUMBER \"\" D:2.718\n" 244 : " V:_csspp_hour\n" 245 : " LIST\n" 246 : " VARIABLE \"_csspp_hour\"\n" 247 : " STRING \"14\"\n" 248 : " V:_csspp_ln10e\n" 249 : " LIST\n" 250 : " VARIABLE \"_csspp_ln10e\"\n" 251 : " DECIMAL_NUMBER \"\" D:2.303\n" 252 : " V:_csspp_ln2e\n" 253 : " LIST\n" 254 : " VARIABLE \"_csspp_ln2e\"\n" 255 : " DECIMAL_NUMBER \"\" D:0.693\n" 256 : " V:_csspp_log10e\n" 257 : " LIST\n" 258 : " VARIABLE \"_csspp_log10e\"\n" 259 : " DECIMAL_NUMBER \"\" D:0.434\n" 260 : " V:_csspp_log2e\n" 261 : " LIST\n" 262 : " VARIABLE \"_csspp_log2e\"\n" 263 : " DECIMAL_NUMBER \"\" D:1.443\n" 264 : " V:_csspp_major\n" 265 : " LIST\n" 266 : " VARIABLE \"_csspp_major\"\n" 267 : " INTEGER \"\" I:" STRINGIFY(CSSPP_VERSION_MAJOR) "\n" 268 : " V:_csspp_minor\n" 269 : " LIST\n" 270 : " VARIABLE \"_csspp_minor\"\n" 271 : " INTEGER \"\" I:" STRINGIFY(CSSPP_VERSION_MINOR) "\n" 272 : " V:_csspp_minute\n" 273 : " LIST\n" 274 : " VARIABLE \"_csspp_minute\"\n" 275 : " STRING \"16\"\n" 276 : " V:_csspp_month\n" 277 : " LIST\n" 278 : " VARIABLE \"_csspp_month\"\n" 279 : " STRING \"07\"\n" 280 : " V:_csspp_no_logo\n" 281 : " LIST\n" 282 : " VARIABLE \"_csspp_no_logo\"\n" 283 22752 : " BOOLEAN B:" + ((flags & flag_no_logo_true) != 0 ? "true" : "false") + "\n" 284 : " V:_csspp_patch\n" 285 : " LIST\n" 286 : " VARIABLE \"_csspp_patch\"\n" 287 : " INTEGER \"\" I:" STRINGIFY(CSSPP_VERSION_PATCH) "\n" 288 : " V:_csspp_pi\n" 289 : " LIST\n" 290 : " VARIABLE \"_csspp_pi\"\n" 291 : " DECIMAL_NUMBER \"\" D:3.142\n" 292 : " V:_csspp_pi_rad\n" 293 : " LIST\n" 294 : " VARIABLE \"_csspp_pi_rad\"\n" 295 : " DECIMAL_NUMBER \"rad\" D:3.142\n" 296 : " V:_csspp_second\n" 297 : " LIST\n" 298 : " VARIABLE \"_csspp_second\"\n" 299 : " STRING \"38\"\n" 300 : " V:_csspp_sqrt2\n" 301 : " LIST\n" 302 : " VARIABLE \"_csspp_sqrt2\"\n" 303 : " DECIMAL_NUMBER \"\" D:1.414\n" 304 : " V:_csspp_time\n" 305 : " LIST\n" 306 : " VARIABLE \"_csspp_time\"\n" 307 : " STRING \"14:16:38\"\n" 308 : " V:_csspp_usdate\n" 309 : " LIST\n" 310 : " VARIABLE \"_csspp_usdate\"\n" 311 : " STRING \"07/02/2015\"\n" 312 : " V:_csspp_version\n" 313 : " LIST\n" 314 : " VARIABLE \"_csspp_version\"\n" 315 : " STRING \"" CSSPP_VERSION "\"\n" 316 : " V:_csspp_year\n" 317 : " LIST\n" 318 : " VARIABLE \"_csspp_year\"\n" 319 : " STRING \"2015\"\n" 320 : " V:adjust_hue\n" 321 : " LIST\n" 322 : " FUNCTION \"adjust_hue\"\n" 323 : " ARG\n" 324 : " VARIABLE \"color\"\n" 325 : " ARG\n" 326 : " VARIABLE \"angle\"\n" 327 : " OPEN_CURLYBRACKET B:false\n" 328 : " COMPONENT_VALUE\n" 329 : " AT_KEYWORD \"return\" I:0\n" 330 : " FUNCTION \"hsla\"\n" 331 : " FUNCTION \"deg2rad\"\n" 332 : " FUNCTION \"hue\"\n" 333 : " VARIABLE \"color\"\n" 334 : " WHITESPACE\n" 335 : " ADD\n" 336 : " WHITESPACE\n" 337 : " VARIABLE \"angle\"\n" 338 : " COMMA\n" 339 : " WHITESPACE\n" 340 : " FUNCTION \"saturation\"\n" 341 : " VARIABLE \"color\"\n" 342 : " COMMA\n" 343 : " WHITESPACE\n" 344 : " FUNCTION \"lightness\"\n" 345 : " VARIABLE \"color\"\n" 346 : " COMMA\n" 347 : " WHITESPACE\n" 348 : " FUNCTION \"alpha\"\n" 349 : " VARIABLE \"color\"\n" 350 : " V:complement\n" 351 : " LIST\n" 352 : " FUNCTION \"complement\"\n" 353 : " ARG\n" 354 : " VARIABLE \"color\"\n" 355 : " OPEN_CURLYBRACKET B:false\n" 356 : " COMPONENT_VALUE\n" 357 : " AT_KEYWORD \"return\" I:0\n" 358 : " FUNCTION \"adjust_hue\"\n" 359 : " VARIABLE \"color\"\n" 360 : " COMMA\n" 361 : " WHITESPACE\n" 362 : " VARIABLE \"_csspp_pi_rad\"\n" 363 : " V:darken\n" 364 : " LIST\n" 365 : " FUNCTION \"darken\"\n" 366 : " ARG\n" 367 : " VARIABLE \"color\"\n" 368 : " ARG\n" 369 : " VARIABLE \"percent\"\n" 370 : " OPEN_CURLYBRACKET B:false\n" 371 : " COMPONENT_VALUE\n" 372 : " AT_KEYWORD \"return\" I:0\n" 373 : " FUNCTION \"lighten\"\n" 374 : " VARIABLE \"color\"\n" 375 : " COMMA\n" 376 : " WHITESPACE\n" 377 : " SUBTRACT\n" 378 : " WHITESPACE\n" 379 : " VARIABLE \"percent\"\n" 380 : " V:deg2rad\n" 381 : " LIST\n" 382 : " FUNCTION \"deg2rad\"\n" 383 : " ARG\n" 384 : " VARIABLE \"angle\"\n" 385 : " OPEN_CURLYBRACKET B:false\n" 386 : " COMPONENT_VALUE\n" 387 : " AT_KEYWORD \"return\" I:0\n" 388 : " VARIABLE \"angle\"\n" 389 : " WHITESPACE\n" 390 : " MULTIPLY\n" 391 : " WHITESPACE\n" 392 : " VARIABLE \"_csspp_pi_rad\"\n" 393 : " WHITESPACE\n" 394 : " DIVIDE\n" 395 : " WHITESPACE\n" 396 : " INTEGER \"deg\" I:180\n" 397 : " V:desaturate\n" 398 : " LIST\n" 399 : " FUNCTION \"desaturate\"\n" 400 : " ARG\n" 401 : " VARIABLE \"color\"\n" 402 : " ARG\n" 403 : " VARIABLE \"percent\"\n" 404 : " OPEN_CURLYBRACKET B:false\n" 405 : " COMPONENT_VALUE\n" 406 : " AT_KEYWORD \"return\" I:0\n" 407 : " FUNCTION \"saturate\"\n" 408 : " VARIABLE \"color\"\n" 409 : " COMMA\n" 410 : " WHITESPACE\n" 411 : " SUBTRACT\n" 412 : " WHITESPACE\n" 413 : " VARIABLE \"percent\"\n" 414 : " V:fade_in\n" 415 : " LIST\n" 416 : " FUNCTION \"fade_in\"\n" 417 : " ARG\n" 418 : " VARIABLE \"color\"\n" 419 : " ARG\n" 420 : " VARIABLE \"number\"\n" 421 : " OPEN_CURLYBRACKET B:false\n" 422 : " COMPONENT_VALUE\n" 423 : " AT_KEYWORD \"return\" I:0\n" 424 : " FUNCTION \"opacify\"\n" 425 : " VARIABLE \"color\"\n" 426 : " COMMA\n" 427 : " WHITESPACE\n" 428 : " VARIABLE \"number\"\n" 429 : " V:fade_out\n" 430 : " LIST\n" 431 : " FUNCTION \"fade_out\"\n" 432 : " ARG\n" 433 : " VARIABLE \"color\"\n" 434 : " ARG\n" 435 : " VARIABLE \"number\"\n" 436 : " OPEN_CURLYBRACKET B:false\n" 437 : " COMPONENT_VALUE\n" 438 : " AT_KEYWORD \"return\" I:0\n" 439 : " FUNCTION \"transparentize\"\n" 440 : " VARIABLE \"color\"\n" 441 : " COMMA\n" 442 : " WHITESPACE\n" 443 : " VARIABLE \"number\"\n" 444 : " V:grayscale\n" 445 : " LIST\n" 446 : " FUNCTION \"grayscale\"\n" 447 : " ARG\n" 448 : " VARIABLE \"color\"\n" 449 : " OPEN_CURLYBRACKET B:false\n" 450 : " COMPONENT_VALUE\n" 451 : " AT_KEYWORD \"return\" I:0\n" 452 : " FUNCTION \"saturate\"\n" 453 : " VARIABLE \"color\"\n" 454 : " COMMA\n" 455 : " WHITESPACE\n" 456 : " SUBTRACT\n" 457 : " WHITESPACE\n" 458 : " FUNCTION \"saturation\"\n" 459 : " VARIABLE \"color\"\n" 460 : " V:invert\n" 461 : " LIST\n" 462 : " FUNCTION \"invert\"\n" 463 : " ARG\n" 464 : " VARIABLE \"color\"\n" 465 : " OPEN_CURLYBRACKET B:false\n" 466 : " COMPONENT_VALUE\n" 467 : " AT_KEYWORD \"return\" I:0\n" 468 : " FUNCTION \"rgba\"\n" 469 : " DECIMAL_NUMBER \"\" D:255\n" 470 : " WHITESPACE\n" 471 : " SUBTRACT\n" 472 : " WHITESPACE\n" 473 : " FUNCTION \"red\"\n" 474 : " VARIABLE \"color\"\n" 475 : " COMMA\n" 476 : " WHITESPACE\n" 477 : " DECIMAL_NUMBER \"\" D:255\n" 478 : " WHITESPACE\n" 479 : " SUBTRACT\n" 480 : " WHITESPACE\n" 481 : " FUNCTION \"green\"\n" 482 : " VARIABLE \"color\"\n" 483 : " COMMA\n" 484 : " WHITESPACE\n" 485 : " DECIMAL_NUMBER \"\" D:255\n" 486 : " WHITESPACE\n" 487 : " SUBTRACT\n" 488 : " WHITESPACE\n" 489 : " FUNCTION \"blue\"\n" 490 : " VARIABLE \"color\"\n" 491 : " COMMA\n" 492 : " WHITESPACE\n" 493 : " FUNCTION \"alpha\"\n" 494 : " VARIABLE \"color\"\n" 495 : " V:lighten\n" 496 : " LIST\n" 497 : " FUNCTION \"lighten\"\n" 498 : " ARG\n" 499 : " VARIABLE \"color\"\n" 500 : " ARG\n" 501 : " VARIABLE \"percent\"\n" 502 : " OPEN_CURLYBRACKET B:false\n" 503 : " COMPONENT_VALUE\n" 504 : " AT_KEYWORD \"return\" I:0\n" 505 : " FUNCTION \"hsla\"\n" 506 : " FUNCTION \"hue\"\n" 507 : " VARIABLE \"color\"\n" 508 : " COMMA\n" 509 : " WHITESPACE\n" 510 : " FUNCTION \"saturation\"\n" 511 : " VARIABLE \"color\"\n" 512 : " COMMA\n" 513 : " WHITESPACE\n" 514 : " FUNCTION \"lightness\"\n" 515 : " VARIABLE \"color\"\n" 516 : " WHITESPACE\n" 517 : " ADD\n" 518 : " WHITESPACE\n" 519 : " VARIABLE \"percent\"\n" 520 : " COMMA\n" 521 : " WHITESPACE\n" 522 : " FUNCTION \"alpha\"\n" 523 : " VARIABLE \"color\"\n" 524 : " V:mix\n" 525 : " LIST\n" 526 : " FUNCTION \"mix\"\n" 527 : " ARG\n" 528 : " VARIABLE \"color1\"\n" 529 : " ARG\n" 530 : " VARIABLE \"color2\"\n" 531 : " ARG\n" 532 : " VARIABLE \"weight\"\n" 533 : " DECIMAL_NUMBER \"\" D:0.5\n" 534 : " OPEN_CURLYBRACKET B:false\n" 535 : " COMPONENT_VALUE\n" 536 : " AT_KEYWORD \"return\" I:0\n" 537 : " VARIABLE \"color1\"\n" 538 : " WHITESPACE\n" 539 : " MULTIPLY\n" 540 : " WHITESPACE\n" 541 : " VARIABLE \"weight\"\n" 542 : " WHITESPACE\n" 543 : " ADD\n" 544 : " WHITESPACE\n" 545 : " VARIABLE \"color2\"\n" 546 : " WHITESPACE\n" 547 : " MULTIPLY\n" 548 : " OPEN_PARENTHESIS\n" 549 : " DECIMAL_NUMBER \"\" D:1\n" 550 : " WHITESPACE\n" 551 : " SUBTRACT\n" 552 : " WHITESPACE\n" 553 : " VARIABLE \"weight\"\n" 554 : " V:opacify\n" 555 : " LIST\n" 556 : " FUNCTION \"opacify\"\n" 557 : " ARG\n" 558 : " VARIABLE \"color\"\n" 559 : " ARG\n" 560 : " VARIABLE \"number\"\n" 561 : " OPEN_CURLYBRACKET B:false\n" 562 : " COMPONENT_VALUE\n" 563 : " AT_KEYWORD \"return\" I:0\n" 564 : " FUNCTION \"rgba\"\n" 565 : " VARIABLE \"color\"\n" 566 : " COMMA\n" 567 : " WHITESPACE\n" 568 : " FUNCTION \"alpha\"\n" 569 : " VARIABLE \"color\"\n" 570 : " WHITESPACE\n" 571 : " ADD\n" 572 : " WHITESPACE\n" 573 : " VARIABLE \"number\"\n" 574 : " V:opacity\n" 575 : " LIST\n" 576 : " FUNCTION \"opacity\"\n" 577 : " ARG\n" 578 : " VARIABLE \"color\"\n" 579 : " OPEN_CURLYBRACKET B:false\n" 580 : " COMPONENT_VALUE\n" 581 : " AT_KEYWORD \"return\" I:0\n" 582 : " FUNCTION \"alpha\"\n" 583 : " VARIABLE \"color\"\n" 584 : " V:quote\n" 585 : " LIST\n" 586 : " FUNCTION \"quote\"\n" 587 : " ARG\n" 588 : " VARIABLE \"identifier\"\n" 589 : " OPEN_CURLYBRACKET B:false\n" 590 : " COMPONENT_VALUE\n" 591 : " AT_KEYWORD \"return\" I:0\n" 592 : " FUNCTION \"string\"\n" 593 : " VARIABLE \"identifier\"\n" 594 : " V:remove_unit\n" 595 : " LIST\n" 596 : " FUNCTION \"remove_unit\"\n" 597 : " ARG\n" 598 : " VARIABLE \"value\"\n" 599 : " OPEN_CURLYBRACKET B:false\n" 600 : " COMPONENT_VALUE\n" 601 : " AT_KEYWORD \"return\" I:0\n" 602 : " FUNCTION \"unit\"\n" 603 : " VARIABLE \"value\"\n" 604 : " WHITESPACE\n" 605 : " EQUAL\n" 606 : " WHITESPACE\n" 607 : " STRING \"%\"\n" 608 : " WHITESPACE\n" 609 : " CONDITIONAL\n" 610 : " WHITESPACE\n" 611 : " FUNCTION \"decimal_number\"\n" 612 : " VARIABLE \"value\"\n" 613 : " WHITESPACE\n" 614 : " COLON\n" 615 : " WHITESPACE\n" 616 : " FUNCTION \"type_of\"\n" 617 : " VARIABLE \"value\"\n" 618 : " WHITESPACE\n" 619 : " EQUAL\n" 620 : " WHITESPACE\n" 621 : " STRING \"integer\"\n" 622 : " WHITESPACE\n" 623 : " CONDITIONAL\n" 624 : " WHITESPACE\n" 625 : " VARIABLE \"value\"\n" 626 : " WHITESPACE\n" 627 : " DIVIDE\n" 628 : " WHITESPACE\n" 629 : " FUNCTION \"integer\"\n" 630 : " STRING \"1\"\n" 631 : " WHITESPACE\n" 632 : " ADD\n" 633 : " WHITESPACE\n" 634 : " FUNCTION \"unit\"\n" 635 : " VARIABLE \"value\"\n" 636 : " WHITESPACE\n" 637 : " COLON\n" 638 : " WHITESPACE\n" 639 : " VARIABLE \"value\"\n" 640 : " WHITESPACE\n" 641 : " DIVIDE\n" 642 : " WHITESPACE\n" 643 : " FUNCTION \"decimal_number\"\n" 644 : " STRING \"1\"\n" 645 : " WHITESPACE\n" 646 : " ADD\n" 647 : " WHITESPACE\n" 648 : " FUNCTION \"unit\"\n" 649 : " VARIABLE \"value\"\n" 650 : " V:saturate\n" 651 : " LIST\n" 652 : " FUNCTION \"saturate\"\n" 653 : " ARG\n" 654 : " VARIABLE \"color\"\n" 655 : " ARG\n" 656 : " VARIABLE \"percent\"\n" 657 : " OPEN_CURLYBRACKET B:false\n" 658 : " COMPONENT_VALUE\n" 659 : " AT_KEYWORD \"return\" I:0\n" 660 : " FUNCTION \"hsla\"\n" 661 : " FUNCTION \"hue\"\n" 662 : " VARIABLE \"color\"\n" 663 : " COMMA\n" 664 : " WHITESPACE\n" 665 : " FUNCTION \"saturation\"\n" 666 : " VARIABLE \"color\"\n" 667 : " WHITESPACE\n" 668 : " ADD\n" 669 : " WHITESPACE\n" 670 : " VARIABLE \"percent\"\n" 671 : " COMMA\n" 672 : " WHITESPACE\n" 673 : " FUNCTION \"lightness\"\n" 674 : " VARIABLE \"color\"\n" 675 : " COMMA\n" 676 : " WHITESPACE\n" 677 : " FUNCTION \"alpha\"\n" 678 : " VARIABLE \"color\"\n" 679 : " V:set_unit\n" 680 : " LIST\n" 681 : " FUNCTION \"set_unit\"\n" 682 : " ARG\n" 683 : " VARIABLE \"value\"\n" 684 : " ARG\n" 685 : " VARIABLE \"unit\"\n" 686 : " OPEN_CURLYBRACKET B:false\n" 687 : " COMPONENT_VALUE\n" 688 : " AT_KEYWORD \"return\" I:0\n" 689 : " FUNCTION \"string\"\n" 690 : " VARIABLE \"unit\"\n" 691 : " WHITESPACE\n" 692 : " EQUAL\n" 693 : " WHITESPACE\n" 694 : " STRING \"%\"\n" 695 : " WHITESPACE\n" 696 : " CONDITIONAL\n" 697 : " WHITESPACE\n" 698 : " FUNCTION \"percentage\"\n" 699 : " VARIABLE \"value\"\n" 700 : " WHITESPACE\n" 701 : " COLON\n" 702 : " WHITESPACE\n" 703 : " FUNCTION \"type_of\"\n" 704 : " VARIABLE \"value\"\n" 705 : " WHITESPACE\n" 706 : " EQUAL\n" 707 : " WHITESPACE\n" 708 : " STRING \"integer\"\n" 709 : " WHITESPACE\n" 710 : " CONDITIONAL\n" 711 : " WHITESPACE\n" 712 : " FUNCTION \"integer\"\n" 713 : " FUNCTION \"string\"\n" 714 : " FUNCTION \"remove_unit\"\n" 715 : " VARIABLE \"value\"\n" 716 : " WHITESPACE\n" 717 : " ADD\n" 718 : " WHITESPACE\n" 719 : " FUNCTION \"string\"\n" 720 : " VARIABLE \"unit\"\n" 721 : " WHITESPACE\n" 722 : " COLON\n" 723 : " WHITESPACE\n" 724 : " FUNCTION \"decimal_number\"\n" 725 : " FUNCTION \"string\"\n" 726 : " FUNCTION \"remove_unit\"\n" 727 : " VARIABLE \"value\"\n" 728 : " WHITESPACE\n" 729 : " ADD\n" 730 : " WHITESPACE\n" 731 : " FUNCTION \"string\"\n" 732 : " VARIABLE \"unit\"\n" 733 : " V:transparentize\n" 734 : " LIST\n" 735 : " FUNCTION \"transparentize\"\n" 736 : " ARG\n" 737 : " VARIABLE \"color\"\n" 738 : " ARG\n" 739 : " VARIABLE \"number\"\n" 740 : " OPEN_CURLYBRACKET B:false\n" 741 : " COMPONENT_VALUE\n" 742 : " AT_KEYWORD \"return\" I:0\n" 743 : " FUNCTION \"rgba\"\n" 744 : " VARIABLE \"color\"\n" 745 : " COMMA\n" 746 : " WHITESPACE\n" 747 : " FUNCTION \"alpha\"\n" 748 : " VARIABLE \"color\"\n" 749 : " WHITESPACE\n" 750 : " SUBTRACT\n" 751 : " WHITESPACE\n" 752 : " VARIABLE \"number\"\n" 753 : " V:unitless\n" 754 : " LIST\n" 755 : " FUNCTION \"unitless\"\n" 756 : " ARG\n" 757 : " VARIABLE \"number\"\n" 758 : " OPEN_CURLYBRACKET B:false\n" 759 : " COMPONENT_VALUE\n" 760 : " AT_KEYWORD \"return\" I:0\n" 761 : " FUNCTION \"unit\"\n" 762 : " VARIABLE \"number\"\n" 763 : " WHITESPACE\n" 764 : " EQUAL\n" 765 : " WHITESPACE\n" 766 : " STRING \"\"\n" 767 : " V:unquote\n" 768 : " LIST\n" 769 : " FUNCTION \"unquote\"\n" 770 : " ARG\n" 771 : " VARIABLE \"string\"\n" 772 : " OPEN_CURLYBRACKET B:false\n" 773 : " COMPONENT_VALUE\n" 774 : " AT_KEYWORD \"return\" I:0\n" 775 : " FUNCTION \"identifier\"\n" 776 22752 : " VARIABLE \"string\"\n" 777 : 778 : ; 779 : 780 : #undef STRINGIFY 781 : #undef STRINGIFY_CONTENT 782 : } 783 : 784 15423 : std::string get_close_comment(bool token) 785 : { 786 15423 : if(token) 787 : { 788 7582 : return " COMMENT \"@preserve -- CSS file parsed by http://csspp.org/ v" CSSPP_VERSION " on 07/02/2015\" I:1\n"; 789 : } 790 : else 791 : { 792 7841 : return "/* @preserve -- CSS file parsed by http://csspp.org/ v" CSSPP_VERSION " on 07/02/2015 */\n"; 793 : } 794 : } 795 : 796 8496 : time_t get_now() 797 : { 798 8496 : return g_now; 799 : } 800 : 801 2 : Catch::Clara::Parser add_command_line_options(Catch::Clara::Parser const & cli) 802 : { 803 : return cli 804 6 : | Catch::Clara::Opt(g_show_errors) 805 4 : ["--show-errors"] 806 4 : ("make the csspp compile more verbose, which means printing all errors.") 807 8 : | Catch::Clara::Opt(g_script_path, "scripts") 808 4 : ["--scripts"] 809 4 : ("specify the location of the CSS Preprocessor system scripts.") 810 4 : | Catch::Clara::Opt(g_version_script_path, "version-script") 811 4 : ["--version-script"] 812 12 : ("define the path to the version script.") 813 : ; 814 : } 815 : 816 1 : int init_test(Catch::Session & session) 817 : { 818 1 : snapdev::NOT_USED(session); 819 : 820 : // unless we get a loop going forever, we should never hit this limit 821 : // 822 1 : csspp::node::limit_nodes_to(1'000'000); 823 : 824 1 : csspp::error::instance().set_verbose(g_show_errors); 825 : 826 : // before running we need to initialize the error tracker 827 : // 828 1 : snapdev::NOT_USED(csspp_test::trace_error::instance()); 829 : 830 1 : return 0; 831 : } 832 : 833 : } // csspp_test namespace 834 : 835 2 : int main(int argc, char *argv[]) 836 : { 837 2 : return SNAP_CATCH2_NAMESPACE::snap_catch2_main( 838 : "eventdispatcher" 839 : , CSSPP_VERSION 840 : , argc 841 : , argv 842 2 : , []() { libexcept::set_collect_stack(libexcept::collect_stack_t::COLLECT_STACK_NO); } 843 : , &csspp_test::add_command_line_options 844 : , &csspp_test::init_test 845 2 : ); 846 : } 847 : 848 : // vim: ts=4 sw=4 et