LCOV - code coverage report
Current view: top level - tests - test_as2js_parser.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 412 539 76.4 %
Date: 2014-11-22 Functions: 23 28 82.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* test_as2js_parser.cpp -- written by Alexis WILKE for Made to Order Software Corp. (c) 2005-2014 */
       2             : 
       3             : /*
       4             : 
       5             : Copyright (c) 2005-2014 Made to Order Software Corp.
       6             : 
       7             : http://snapwebsites.org/project/as2js
       8             : 
       9             : Permission is hereby granted, free of charge, to any
      10             : person obtaining a copy of this software and
      11             : associated documentation files (the "Software"), to
      12             : deal in the Software without restriction, including
      13             : without limitation the rights to use, copy, modify,
      14             : merge, publish, distribute, sublicense, and/or sell
      15             : copies of the Software, and to permit persons to whom
      16             : the Software is furnished to do so, subject to the
      17             : following conditions:
      18             : 
      19             : The above copyright notice and this permission notice
      20             : shall be included in all copies or substantial
      21             : portions of the Software.
      22             : 
      23             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
      24             : ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
      25             : LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
      26             : FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
      27             : EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
      28             : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      29             : WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      30             : ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      31             : SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      32             : SOFTWARE.
      33             : 
      34             : */
      35             : 
      36             : #include    "test_as2js_parser.h"
      37             : #include    "test_as2js_main.h"
      38             : 
      39             : #include    "as2js/parser.h"
      40             : #include    "as2js/exceptions.h"
      41             : #include    "as2js/message.h"
      42             : #include    "as2js/json.h"
      43             : 
      44             : #include    <controlled_vars/controlled_vars_limited_auto_enum_init.h>
      45             : 
      46             : #include    <unistd.h>
      47             : #include    <sys/stat.h>
      48             : 
      49             : #include    <cstring>
      50             : #include    <algorithm>
      51             : #include    <iomanip>
      52             : 
      53             : #include    <cppunit/config/SourcePrefix.h>
      54           4 : CPPUNIT_TEST_SUITE_REGISTRATION( As2JsParserUnitTests );
      55             : 
      56             : namespace
      57             : {
      58             : 
      59             : 
      60           0 : int32_t generate_string(as2js::String& str, bool ascii)
      61             : {
      62             :     as2js::as_char_t c;
      63           0 :     int32_t used(0);
      64           0 :     int ctrl(rand() % 7);
      65           0 :     int const max_chars(rand() % 25 + 20);
      66           0 :     for(int j(0); j < max_chars; ++j)
      67             :     {
      68           0 :         do
      69             :         {
      70           0 :             c = rand() & 0x1FFFFF;
      71           0 :             if(ascii)
      72             :             {
      73           0 :                 c &= 0x7F;
      74             :             }
      75           0 :             if(ctrl == 0)
      76             :             {
      77           0 :                 ctrl = rand() % 7;
      78           0 :                 if((ctrl & 3) == 1)
      79             :                 {
      80           0 :                     c = c & 1 ? '"' : '\'';
      81             :                 }
      82             :                 else
      83             :                 {
      84           0 :                     c &= 0x1F;
      85             :                 }
      86             :             }
      87             :             else
      88             :             {
      89           0 :                 --ctrl;
      90             :             }
      91             :         }
      92             :         while(c >= 0x110000
      93           0 :            || (c >= 0xD800 && c <= 0xDFFF)
      94           0 :            || ((c & 0xFFFE) == 0xFFFE)
      95           0 :            || c == '\0');
      96           0 :         str += c;
      97           0 :         switch(c)
      98             :         {
      99             :         case '\b':
     100           0 :             used |= 0x01;
     101           0 :             break;
     102             : 
     103             :         case '\f':
     104           0 :             used |= 0x02;
     105           0 :             break;
     106             : 
     107             :         case '\n':
     108           0 :             used |= 0x04;
     109           0 :             break;
     110             : 
     111             :         case '\r':
     112           0 :             used |= 0x08;
     113           0 :             break;
     114             : 
     115             :         case '\t':
     116           0 :             used |= 0x10;
     117           0 :             break;
     118             : 
     119             :         case '"':
     120           0 :             used |= 0x20;
     121           0 :             break;
     122             : 
     123             :         case '\'':
     124           0 :             used |= 0x40;
     125           0 :             break;
     126             : 
     127             :         default:
     128           0 :             if(c < 0x0020)
     129             :             {
     130             :                 // other controls must be escaped using Unicode
     131           0 :                 used |= 0x80;
     132             :             }
     133           0 :             break;
     134             : 
     135             :         }
     136             :     }
     137             : 
     138           0 :     return used;
     139             : }
     140             : 
     141             : 
     142             : struct err_to_string_t
     143             : {
     144             :     as2js::err_code_t       f_code;
     145             :     char const *            f_name;
     146             :     int                     f_line;
     147             : };
     148             : 
     149             : #define    TO_STR_sub(s)            #s
     150             : #define    ERROR_NAME(err)     { as2js::err_code_t::AS_ERR_##err, TO_STR_sub(err), __LINE__ }
     151             : 
     152             : err_to_string_t const g_error_table[] =
     153             : {
     154             :     ERROR_NAME(NONE),
     155             :     ERROR_NAME(ABSTRACT),
     156             :     ERROR_NAME(BAD_NUMERIC_TYPE),
     157             :     ERROR_NAME(BAD_PRAGMA),
     158             :     ERROR_NAME(CANNOT_COMPILE),
     159             :     ERROR_NAME(CANNOT_MATCH),
     160             :     ERROR_NAME(CANNOT_OVERLOAD),
     161             :     ERROR_NAME(CANNOT_OVERWRITE_CONST),
     162             :     ERROR_NAME(CASE_LABEL),
     163             :     ERROR_NAME(COLON_EXPECTED),
     164             :     ERROR_NAME(COMMA_EXPECTED),
     165             :     ERROR_NAME(CURVLY_BRACKETS_EXPECTED),
     166             :     ERROR_NAME(DEFAULT_LABEL),
     167             :     ERROR_NAME(DIVIDE_BY_ZERO),
     168             :     ERROR_NAME(DUPLICATES),
     169             :     ERROR_NAME(DYNAMIC),
     170             :     ERROR_NAME(EXPRESSION_EXPECTED),
     171             :     ERROR_NAME(FINAL),
     172             :     ERROR_NAME(IMPROPER_STATEMENT),
     173             :     ERROR_NAME(INACCESSIBLE_STATEMENT),
     174             :     ERROR_NAME(INCOMPATIBLE),
     175             :     ERROR_NAME(INCOMPATIBLE_PRAGMA_ARGUMENT),
     176             :     ERROR_NAME(INSTALLATION),
     177             :     ERROR_NAME(INSTANCE_EXPECTED),
     178             :     ERROR_NAME(INTERNAL_ERROR),
     179             :     ERROR_NAME(NATIVE),
     180             :     ERROR_NAME(INVALID_ARRAY_FUNCTION),
     181             :     ERROR_NAME(INVALID_ATTRIBUTES),
     182             :     ERROR_NAME(INVALID_CATCH),
     183             :     ERROR_NAME(INVALID_CLASS),
     184             :     ERROR_NAME(INVALID_CONDITIONAL),
     185             :     ERROR_NAME(INVALID_DEFINITION),
     186             :     ERROR_NAME(INVALID_DO),
     187             :     ERROR_NAME(INVALID_ENUM),
     188             :     ERROR_NAME(INVALID_EXPRESSION),
     189             :     ERROR_NAME(INVALID_FIELD),
     190             :     ERROR_NAME(INVALID_FIELD_NAME),
     191             :     ERROR_NAME(INVALID_FRAME),
     192             :     ERROR_NAME(INVALID_FUNCTION),
     193             :     ERROR_NAME(INVALID_GOTO),
     194             :     ERROR_NAME(INVALID_IMPORT),
     195             :     ERROR_NAME(INVALID_INPUT_STREAM),
     196             :     ERROR_NAME(INVALID_KEYWORD),
     197             :     ERROR_NAME(INVALID_LABEL),
     198             :     ERROR_NAME(INVALID_NAMESPACE),
     199             :     ERROR_NAME(INVALID_NODE),
     200             :     ERROR_NAME(INVALID_NUMBER),
     201             :     ERROR_NAME(INVALID_OPERATOR),
     202             :     ERROR_NAME(INVALID_PACKAGE_NAME),
     203             :     ERROR_NAME(INVALID_PARAMETERS),
     204             :     ERROR_NAME(INVALID_REST),
     205             :     ERROR_NAME(INVALID_RETURN_TYPE),
     206             :     ERROR_NAME(INVALID_SCOPE),
     207             :     ERROR_NAME(INVALID_TRY),
     208             :     ERROR_NAME(INVALID_TYPE),
     209             :     ERROR_NAME(INVALID_UNICODE_ESCAPE_SEQUENCE),
     210             :     ERROR_NAME(INVALID_VARIABLE),
     211             :     ERROR_NAME(IO_ERROR),
     212             :     ERROR_NAME(LABEL_NOT_FOUND),
     213             :     ERROR_NAME(LOOPING_REFERENCE),
     214             :     ERROR_NAME(MISMATCH_FUNC_VAR),
     215             :     ERROR_NAME(MISSSING_VARIABLE_NAME),
     216             :     ERROR_NAME(NEED_CONST),
     217             :     ERROR_NAME(NOT_ALLOWED),
     218             :     ERROR_NAME(NOT_ALLOWED_IN_STRICT_MODE),
     219             :     ERROR_NAME(NOT_FOUND),
     220             :     ERROR_NAME(NOT_SUPPORTED),
     221             :     ERROR_NAME(OBJECT_MEMBER_DEFINED_TWICE),
     222             :     ERROR_NAME(PARENTHESIS_EXPECTED),
     223             :     ERROR_NAME(PRAGMA_FAILED),
     224             :     ERROR_NAME(SEMICOLON_EXPECTED),
     225             :     ERROR_NAME(SQUARE_BRACKETS_EXPECTED),
     226             :     ERROR_NAME(STRING_EXPECTED),
     227             :     ERROR_NAME(STATIC),
     228             :     ERROR_NAME(TYPE_NOT_LINKED),
     229             :     ERROR_NAME(UNKNOWN_ESCAPE_SEQUENCE),
     230             :     ERROR_NAME(UNKNOWN_OPERATOR),
     231             :     ERROR_NAME(UNTERMINATED_STRING),
     232             :     ERROR_NAME(UNEXPECTED_EOF),
     233             :     ERROR_NAME(UNEXPECTED_PUNCTUATION),
     234             :     ERROR_NAME(UNEXPECTED_TOKEN),
     235             :     ERROR_NAME(UNEXPECTED_DATABASE),
     236             :     ERROR_NAME(UNEXPECTED_RC)
     237             : };
     238             : size_t const g_error_table_size = sizeof(g_error_table) / sizeof(g_error_table[0]);
     239             : 
     240             : 
     241     2889728 : as2js::err_code_t str_to_error_code(as2js::String const& error_name)
     242             : {
     243   129654784 :     for(size_t idx(0); idx < g_error_table_size; ++idx)
     244             :     {
     245   129654784 :         if(error_name == g_error_table[idx].f_name)
     246             :         {
     247     2889728 :             return g_error_table[idx].f_code;
     248             :         }
     249             :     }
     250           0 :     std::cerr << "Error name \"" << error_name << "\" not found.\n";
     251           0 :     CPPUNIT_ASSERT(!"error name not found, test_as2js_parser.cpp bug");
     252           0 :     return as2js::err_code_t::AS_ERR_NONE;
     253             : }
     254             : 
     255             : 
     256           0 : char const *error_code_to_str(as2js::err_code_t const& error_code)
     257             : {
     258           0 :     for(size_t idx(0); idx < g_error_table_size; ++idx)
     259             :     {
     260           0 :         if(error_code == g_error_table[idx].f_code)
     261             :         {
     262           0 :             return g_error_table[idx].f_name;
     263             :         }
     264             :     }
     265           0 :     std::cerr << "Error code \"" << static_cast<int>(error_code) << "\" not found.\n";
     266           0 :     CPPUNIT_ASSERT(!"error code not found, test_as2js_parser.cpp bug");
     267           0 :     return "unknown";
     268             : }
     269             : 
     270             : 
     271             : 
     272             : class test_callback : public as2js::MessageCallback
     273             : {
     274             : public:
     275     1236992 :     test_callback(bool verbose)
     276     1236992 :         : f_verbose(verbose)
     277             :     {
     278     1236992 :         as2js::Message::set_message_callback(this);
     279     1236992 :         g_warning_count = as2js::Message::warning_count();
     280     1236992 :         g_error_count = as2js::Message::error_count();
     281     1236992 :     }
     282             : 
     283     1236992 :     ~test_callback()
     284     2473984 :     {
     285             :         // make sure the pointer gets reset!
     286     1236992 :         as2js::Message::set_message_callback(nullptr);
     287     1236992 :     }
     288             : 
     289             :     // implementation of the output
     290     2889728 :     virtual void output(as2js::message_level_t message_level, as2js::err_code_t error_code, as2js::Position const& pos, std::string const& message)
     291             :     {
     292             :         // skip trace messages which happen all the time because of the
     293             :         // lexer debug option
     294     2889728 :         if(message_level == as2js::message_level_t::MESSAGE_LEVEL_TRACE)
     295             :         {
     296     2889728 :             return;
     297             :         }
     298             : 
     299     2889728 :         if(f_expected.empty())
     300             :         {
     301           0 :             std::cerr << "\n*** STILL NECESSARY ***\n";
     302           0 :             std::cerr << "filename = " << pos.get_filename() << "\n";
     303           0 :             std::cerr << "msg = " << message << "\n";
     304           0 :             std::cerr << "page = " << pos.get_page() << "\n";
     305           0 :             std::cerr << "line = " << pos.get_line() << "\n";
     306           0 :             std::cerr << "error_code = " << static_cast<int>(error_code) << " (" << error_code_to_str(error_code) << ")\n";
     307             :         }
     308             : 
     309     2889728 :         CPPUNIT_ASSERT(!f_expected.empty());
     310             : 
     311     2889728 :         if(f_verbose)
     312             :         {
     313           0 :             std::cerr << "filename = " << pos.get_filename() << " (node) / " << f_expected[0].f_pos.get_filename() << " (JSON)\n";
     314           0 :             std::cerr << "msg = " << message << " / " << f_expected[0].f_message << "\n";
     315           0 :             std::cerr << "page = " << pos.get_page() << " / " << f_expected[0].f_pos.get_page() << "\n";
     316           0 :             std::cerr << "line = " << pos.get_line() << " / " << f_expected[0].f_pos.get_line() << "\n";
     317           0 :             std::cerr << "page line = " << pos.get_page_line() << " / " << f_expected[0].f_pos.get_page_line() << "\n";
     318           0 :             std::cerr << "error_code = " << static_cast<int>(error_code) << " (" << error_code_to_str(error_code) << ") / " << static_cast<int>(f_expected[0].f_error_code) << " (" << error_code_to_str(f_expected[0].f_error_code) << ")\n";
     319             :         }
     320             : 
     321     2889728 :         CPPUNIT_ASSERT(f_expected[0].f_call);
     322     2889728 :         CPPUNIT_ASSERT(message_level == f_expected[0].f_message_level);
     323     2889728 :         CPPUNIT_ASSERT(error_code == f_expected[0].f_error_code);
     324     2889728 :         CPPUNIT_ASSERT(pos.get_filename() == f_expected[0].f_pos.get_filename());
     325     2889728 :         CPPUNIT_ASSERT(pos.get_function() == f_expected[0].f_pos.get_function());
     326     2889728 :         CPPUNIT_ASSERT(pos.get_page() == f_expected[0].f_pos.get_page());
     327     2889728 :         CPPUNIT_ASSERT(pos.get_page_line() == f_expected[0].f_pos.get_page_line());
     328     2889728 :         CPPUNIT_ASSERT(pos.get_paragraph() == f_expected[0].f_pos.get_paragraph());
     329     2889728 :         CPPUNIT_ASSERT(pos.get_line() == f_expected[0].f_pos.get_line());
     330     2889728 :         CPPUNIT_ASSERT(message == f_expected[0].f_message.to_utf8());
     331             : 
     332     2889728 :         if(message_level == as2js::message_level_t::MESSAGE_LEVEL_WARNING)
     333             :         {
     334       32768 :             ++g_warning_count;
     335       32768 :             CPPUNIT_ASSERT(g_warning_count == as2js::Message::warning_count());
     336             :         }
     337             : 
     338     2889728 :         if(message_level == as2js::message_level_t::MESSAGE_LEVEL_FATAL
     339     2889728 :         || message_level == as2js::message_level_t::MESSAGE_LEVEL_ERROR)
     340             :         {
     341     2856960 :             ++g_error_count;
     342             : //std::cerr << "error: " << g_error_count << " / " << as2js::Message::error_count() << "\n";
     343     2856960 :             CPPUNIT_ASSERT(g_error_count == as2js::Message::error_count());
     344             :         }
     345             : 
     346     2889728 :         f_expected.erase(f_expected.begin());
     347             :     }
     348             : 
     349     1236992 :     void got_called()
     350             :     {
     351     1236992 :         if(!f_expected.empty())
     352             :         {
     353           0 :             std::cerr << "\n*** STILL " << f_expected.size() << " EXPECTED ***\n";
     354           0 :             std::cerr << "filename = " << f_expected[0].f_pos.get_filename() << "\n";
     355           0 :             std::cerr << "msg = " << f_expected[0].f_message << "\n";
     356           0 :             std::cerr << "page = " << f_expected[0].f_pos.get_page() << "\n";
     357           0 :             std::cerr << "error_code = " << static_cast<int>(f_expected[0].f_error_code) << "\n";
     358             :         }
     359     1236992 :         CPPUNIT_ASSERT(f_expected.empty());
     360     1236992 :     }
     361             : 
     362    30604288 :     struct expected_t
     363             :     {
     364             :         controlled_vars::tlbool_t   f_call;
     365             :         as2js::message_level_t      f_message_level;
     366             :         as2js::err_code_t           f_error_code;
     367             :         as2js::Position             f_pos;
     368             :         as2js::String               f_message; // UTF-8 string
     369             :     };
     370             : 
     371             :     std::vector<expected_t>     f_expected;
     372             :     controlled_vars::fbool_t    f_verbose;
     373             : 
     374             :     static controlled_vars::zint32_t   g_warning_count;
     375             :     static controlled_vars::zint32_t   g_error_count;
     376             : };
     377             : 
     378           4 : controlled_vars::zint32_t   test_callback::g_warning_count;
     379           4 : controlled_vars::zint32_t   test_callback::g_error_count;
     380             : 
     381           4 : controlled_vars::zint32_t   g_empty_home_too_late;
     382             : 
     383             : 
     384             : //
     385             : // we have two special pragmas that accept 0, 1, 2, or 3
     386             : // namely, those are:
     387             : //
     388             : //  . OPTION_EXTENDED_STATEMENTS -- force '{' ... '}' in
     389             : //    blocks for: if, while, do, for, with...
     390             : //
     391             : //  . OPTION_EXTENDED_OPERATORS -- force ':=' instead of '='
     392             : //
     393             : // for this reason we support and f_value which is viewed
     394             : // as a set of flags
     395             : //
     396             : struct named_options
     397             : {
     398             :     as2js::Options::option_t    f_option;
     399             :     char const *                f_name;
     400             :     char const *                f_neg_name;
     401             :     int                         f_value;
     402             : };
     403             : named_options const g_options[] =
     404             : {
     405             :     {
     406             :         as2js::Options::option_t::OPTION_ALLOW_WITH,
     407             :         "allow_with",
     408             :         "no_allow_with",
     409             :         1
     410             :     },
     411             :     {
     412             :         as2js::Options::option_t::OPTION_BINARY,
     413             :         "binary",
     414             :         "no_binary",
     415             :         1
     416             :     },
     417             :     {
     418             :         as2js::Options::option_t::OPTION_COVERAGE,
     419             :         "coverage",
     420             :         "no_coverage",
     421             :         1
     422             :     },
     423             :     {
     424             :         as2js::Options::option_t::OPTION_DEBUG,
     425             :         "debug",
     426             :         "no_debug",
     427             :         1
     428             :     },
     429             :     {
     430             :         as2js::Options::option_t::OPTION_EXTENDED_ESCAPE_SEQUENCES,
     431             :         "extended_escape_sequences",
     432             :         "no_extended_escape_sequences",
     433             :         1
     434             :     },
     435             :     {
     436             :         as2js::Options::option_t::OPTION_EXTENDED_OPERATORS,
     437             :         "extended_operators",
     438             :         "no_extended_operators",
     439             :         1
     440             :     },
     441             :     {
     442             :         as2js::Options::option_t::OPTION_EXTENDED_OPERATORS,
     443             :         "extended_operators_safe",
     444             :         "no_extended_operators_safe",
     445             :         2
     446             :     },
     447             :     {
     448             :         as2js::Options::option_t::OPTION_EXTENDED_STATEMENTS,
     449             :         "extended_statements",
     450             :         "no_extended_statements",
     451             :         1
     452             :     },
     453             :     {
     454             :         as2js::Options::option_t::OPTION_EXTENDED_STATEMENTS,
     455             :         "extended_statements_safe",
     456             :         "no_extended_statements_safe",
     457             :         2
     458             :     },
     459             :     //{ -- this one does not make sense here
     460             :     //    as2js::Options::option_t::OPTION_JSON,
     461             :     //    "json",
     462             :     //    "no_json"
     463             :     //},
     464             :     {
     465             :         as2js::Options::option_t::OPTION_OCTAL,
     466             :         "octal",
     467             :         "no_octal",
     468             :         1
     469             :     },
     470             :     {
     471             :         as2js::Options::option_t::OPTION_STRICT,
     472             :         "strict",
     473             :         "no_strict",
     474             :         1
     475             :     },
     476             :     {
     477             :         as2js::Options::option_t::OPTION_TRACE,
     478             :         "trace",
     479             :         "no_trace",
     480             :         1
     481             :     },
     482             :     {
     483             :         as2js::Options::option_t::OPTION_UNSAFE_MATH,
     484             :         "unsafe_math",
     485             :         "no_unsafe_math",
     486             :         1
     487             :     }
     488             : };
     489             : size_t const g_options_size(sizeof(g_options) / sizeof(g_options[0]));
     490             : 
     491             : 
     492             : struct flg_to_string_t
     493             : {
     494             :     as2js::Node::flag_t     f_flag;
     495             :     char const *            f_name;
     496             :     int                     f_line;
     497             : };
     498             : 
     499             : #define    FLAG_NAME(flg)     { as2js::Node::flag_t::NODE_##flg, TO_STR_sub(flg), __LINE__ }
     500             : 
     501             : flg_to_string_t const g_flag_table[] =
     502             : {
     503             :     FLAG_NAME(CATCH_FLAG_TYPED),
     504             :     FLAG_NAME(DIRECTIVE_LIST_FLAG_NEW_VARIABLES),
     505             :     FLAG_NAME(ENUM_FLAG_CLASS),
     506             :     FLAG_NAME(FOR_FLAG_CONST),
     507             :     FLAG_NAME(FOR_FLAG_FOREACH),
     508             :     FLAG_NAME(FOR_FLAG_IN),
     509             :     FLAG_NAME(FUNCTION_FLAG_GETTER),
     510             :     FLAG_NAME(FUNCTION_FLAG_SETTER),
     511             :     FLAG_NAME(FUNCTION_FLAG_OUT),
     512             :     FLAG_NAME(FUNCTION_FLAG_VOID),
     513             :     FLAG_NAME(FUNCTION_FLAG_NEVER),
     514             :     FLAG_NAME(FUNCTION_FLAG_NOPARAMS),
     515             :     FLAG_NAME(FUNCTION_FLAG_OPERATOR),
     516             :     FLAG_NAME(IDENTIFIER_FLAG_WITH),
     517             :     FLAG_NAME(IDENTIFIER_FLAG_TYPED),
     518             :     FLAG_NAME(IMPORT_FLAG_IMPLEMENTS),
     519             :     FLAG_NAME(PACKAGE_FLAG_FOUND_LABELS),
     520             :     FLAG_NAME(PACKAGE_FLAG_REFERENCED),
     521             :     FLAG_NAME(PARAM_FLAG_CONST),
     522             :     FLAG_NAME(PARAM_FLAG_IN),
     523             :     FLAG_NAME(PARAM_FLAG_OUT),
     524             :     FLAG_NAME(PARAM_FLAG_NAMED),
     525             :     FLAG_NAME(PARAM_FLAG_REST),
     526             :     FLAG_NAME(PARAM_FLAG_UNCHECKED),
     527             :     FLAG_NAME(PARAM_FLAG_UNPROTOTYPED),
     528             :     FLAG_NAME(PARAM_FLAG_REFERENCED),
     529             :     FLAG_NAME(PARAM_FLAG_PARAMREF),
     530             :     FLAG_NAME(PARAM_FLAG_CATCH),
     531             :     FLAG_NAME(PARAM_MATCH_FLAG_UNPROTOTYPED),
     532             :     FLAG_NAME(SWITCH_FLAG_DEFAULT),
     533             :     FLAG_NAME(TYPE_FLAG_MODULO),
     534             :     FLAG_NAME(VARIABLE_FLAG_CONST),
     535             :     FLAG_NAME(VARIABLE_FLAG_LOCAL),
     536             :     FLAG_NAME(VARIABLE_FLAG_MEMBER),
     537             :     FLAG_NAME(VARIABLE_FLAG_ATTRIBUTES),
     538             :     FLAG_NAME(VARIABLE_FLAG_ENUM),
     539             :     FLAG_NAME(VARIABLE_FLAG_COMPILED),
     540             :     FLAG_NAME(VARIABLE_FLAG_INUSE),
     541             :     FLAG_NAME(VARIABLE_FLAG_ATTRS),
     542             :     FLAG_NAME(VARIABLE_FLAG_DEFINED),
     543             :     FLAG_NAME(VARIABLE_FLAG_DEFINING),
     544             :     FLAG_NAME(VARIABLE_FLAG_TOADD)
     545             : };
     546             : size_t const g_flag_table_size = sizeof(g_flag_table) / sizeof(g_flag_table[0]);
     547             : 
     548             : 
     549     1859584 : as2js::Node::flag_t str_to_flag_code(as2js::String const& flag_name)
     550             : {
     551    37339136 :     for(size_t idx(0); idx < g_flag_table_size; ++idx)
     552             :     {
     553    37339136 :         if(flag_name == g_flag_table[idx].f_name)
     554             :         {
     555     1859584 :             return g_flag_table[idx].f_flag;
     556             :         }
     557             :     }
     558           0 :     CPPUNIT_ASSERT(!"flag code not found, test_as2js_parser.cpp bug");
     559           0 :     return as2js::Node::flag_t::NODE_FLAG_max;
     560             : }
     561             : 
     562             : 
     563           0 : as2js::String flag_to_str(as2js::Node::flag_t& flg)
     564             : {
     565           0 :     for(size_t idx(0); idx < g_flag_table_size; ++idx)
     566             :     {
     567           0 :         if(flg == g_flag_table[idx].f_flag)
     568             :         {
     569           0 :             return g_flag_table[idx].f_name;
     570             :         }
     571             :     }
     572           0 :     CPPUNIT_ASSERT(!"flag code not found, test_as2js_parser.cpp bug");
     573           0 :     return "";
     574             : }
     575             : 
     576             : 
     577             : 
     578             : 
     579    23158784 : void verify_flags(as2js::Node::pointer_t node, as2js::String const& flags_set, bool verbose)
     580             : {
     581             :     // list of flags that have to be set
     582    23158784 :     std::vector<as2js::Node::flag_t> flgs;
     583    23158784 :     as2js::as_char_t const *f(flags_set.c_str());
     584    23158784 :     as2js::as_char_t const *s(f);
     585             :     for(;;)
     586             :     {
     587    57843712 :         if(*f == ',' || *f == '\0')
     588             :         {
     589    23601152 :             if(s == f)
     590             :             {
     591    44900352 :                 break;
     592             :             }
     593     1859584 :             as2js::String name(s, f - s);
     594             : //std::cerr << "Checking " << name << " -> " << static_cast<int>(str_to_flag_code(name)) << "\n";
     595     1859584 :             flgs.push_back(str_to_flag_code(name));
     596     1859584 :             if(*f == '\0')
     597             :             {
     598     1417216 :                 break;
     599             :             }
     600      442368 :             do // skip commas
     601             :             {
     602      442368 :                 ++f;
     603             :             }
     604      442368 :             while(*f == ',');
     605      442368 :             s = f;
     606             :         }
     607             :         else
     608             :         {
     609    34242560 :             ++f;
     610             :         }
     611    34684928 :     }
     612             : 
     613             :     // list of flags that must be checked
     614    46317568 :     std::vector<as2js::Node::flag_t> flgs_to_check;
     615    23158784 :     switch(node->get_type())
     616             :     {
     617             :     case as2js::Node::node_t::NODE_CATCH:
     618       73728 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_CATCH_FLAG_TYPED);
     619       73728 :         break;
     620             : 
     621             :     case as2js::Node::node_t::NODE_DIRECTIVE_LIST:
     622     2531328 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_DIRECTIVE_LIST_FLAG_NEW_VARIABLES);
     623     2531328 :         break;
     624             : 
     625             :     case as2js::Node::node_t::NODE_ENUM:
     626      122880 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_ENUM_FLAG_CLASS);
     627      122880 :         break;
     628             : 
     629             :     case as2js::Node::node_t::NODE_FOR:
     630      106496 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FOR_FLAG_CONST);
     631      106496 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FOR_FLAG_FOREACH);
     632      106496 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FOR_FLAG_IN);
     633      106496 :         break;
     634             : 
     635             :     case as2js::Node::node_t::NODE_FUNCTION:
     636      950272 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FUNCTION_FLAG_GETTER);
     637      950272 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FUNCTION_FLAG_NEVER);
     638      950272 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FUNCTION_FLAG_NOPARAMS);
     639      950272 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FUNCTION_FLAG_OPERATOR);
     640      950272 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FUNCTION_FLAG_OUT);
     641      950272 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FUNCTION_FLAG_SETTER);
     642      950272 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_FUNCTION_FLAG_VOID);
     643      950272 :         break;
     644             : 
     645             :     case as2js::Node::node_t::NODE_IDENTIFIER:
     646             :     case as2js::Node::node_t::NODE_VIDENTIFIER:
     647             :     case as2js::Node::node_t::NODE_STRING:
     648     4841472 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_IDENTIFIER_FLAG_WITH);
     649     4841472 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_IDENTIFIER_FLAG_TYPED);
     650     4841472 :         break;
     651             : 
     652             :     case as2js::Node::node_t::NODE_IMPORT:
     653      163840 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_IMPORT_FLAG_IMPLEMENTS);
     654      163840 :         break;
     655             : 
     656             :     case as2js::Node::node_t::NODE_PACKAGE:
     657      131072 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PACKAGE_FLAG_FOUND_LABELS);
     658      131072 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PACKAGE_FLAG_REFERENCED);
     659      131072 :         break;
     660             : 
     661             :     case as2js::Node::node_t::NODE_PARAM_MATCH:
     662           0 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_MATCH_FLAG_UNPROTOTYPED);
     663           0 :         break;
     664             : 
     665             :     case as2js::Node::node_t::NODE_PARAM:
     666     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_CATCH);
     667     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_CONST);
     668     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_IN);
     669     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_OUT);
     670     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_NAMED);
     671     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_PARAMREF);
     672     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_REFERENCED);
     673     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_REST);
     674     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_UNCHECKED);
     675     1040384 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_PARAM_FLAG_UNPROTOTYPED);
     676     1040384 :         break;
     677             : 
     678             :     case as2js::Node::node_t::NODE_SWITCH:
     679       81920 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_SWITCH_FLAG_DEFAULT);
     680       81920 :         break;
     681             : 
     682             :     case as2js::Node::node_t::NODE_TYPE:
     683      671744 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_TYPE_FLAG_MODULO);
     684      671744 :         break;
     685             : 
     686             :     case as2js::Node::node_t::NODE_VARIABLE:
     687             :     case as2js::Node::node_t::NODE_VAR_ATTRIBUTES:
     688      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_CONST);
     689      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_LOCAL);
     690      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_MEMBER);
     691      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_ATTRIBUTES);
     692      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_ENUM);
     693      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_COMPILED);
     694      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_INUSE);
     695      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_ATTRS);
     696      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_DEFINED);
     697      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_DEFINING);
     698      540672 :         flgs_to_check.push_back(as2js::Node::flag_t::NODE_VARIABLE_FLAG_TOADD);
     699      540672 :         break;
     700             : 
     701             :     default:
     702             :         // no flags supported
     703    11902976 :         break;
     704             : 
     705             :     }
     706             : 
     707    23158784 :     CPPUNIT_ASSERT(flgs.size() <= flgs_to_check.size());
     708             : 
     709    60071936 :     for(size_t idx(0); idx < flgs_to_check.size(); ++idx)
     710             :     {
     711    36913152 :         as2js::Node::flag_t flg(flgs_to_check[idx]);
     712    36913152 :         std::vector<as2js::Node::flag_t>::iterator it(std::find(flgs.begin(), flgs.end(), flg));
     713    36913152 :         if(it == flgs.end())
     714             :         {
     715             :             // expected to be unset
     716    35053568 :             if(verbose && node->get_flag(flg))
     717             :             {
     718           0 :                 std::cerr << "*** Comparing flags " << flag_to_str(flg) << " (should not be set)\n";
     719             :             }
     720    35053568 :             CPPUNIT_ASSERT(!node->get_flag(flg));
     721             :         }
     722             :         else
     723             :         {
     724             :             // expected to be set
     725     1859584 :             flgs.erase(it);
     726     1859584 :             if(verbose && !node->get_flag(flg))
     727             :             {
     728           0 :                 std::cerr << "*** Comparing flags " << flag_to_str(flg) << " (it should be set in this case)\n";
     729             :             }
     730     1859584 :             CPPUNIT_ASSERT(node->get_flag(flg));
     731             :         }
     732             :     }
     733             : 
     734    46317568 :     CPPUNIT_ASSERT(flgs.empty());
     735    23158784 : }
     736             : 
     737             : 
     738             : 
     739             : 
     740             : struct attr_to_string_t
     741             : {
     742             :     as2js::Node::attribute_t    f_attribute;
     743             :     char const *                f_name;
     744             :     int                         f_line;
     745             : };
     746             : 
     747             : #define    ATTRIBUTE_NAME(attr)      { as2js::Node::attribute_t::NODE_ATTR_##attr, TO_STR_sub(attr), __LINE__ }
     748             : 
     749             : attr_to_string_t const g_attribute_table[] =
     750             : {
     751             :     ATTRIBUTE_NAME(PUBLIC),
     752             :     ATTRIBUTE_NAME(PRIVATE),
     753             :     ATTRIBUTE_NAME(PROTECTED),
     754             :     ATTRIBUTE_NAME(INTERNAL),
     755             :     ATTRIBUTE_NAME(TRANSIENT),
     756             :     ATTRIBUTE_NAME(VOLATILE),
     757             :     ATTRIBUTE_NAME(STATIC),
     758             :     ATTRIBUTE_NAME(ABSTRACT),
     759             :     ATTRIBUTE_NAME(VIRTUAL),
     760             :     ATTRIBUTE_NAME(ARRAY),
     761             :     ATTRIBUTE_NAME(REQUIRE_ELSE),
     762             :     ATTRIBUTE_NAME(ENSURE_THEN),
     763             :     ATTRIBUTE_NAME(NATIVE),
     764             :     ATTRIBUTE_NAME(DEPRECATED),
     765             :     ATTRIBUTE_NAME(UNSAFE),
     766             :     ATTRIBUTE_NAME(CONSTRUCTOR),
     767             :     ATTRIBUTE_NAME(FINAL),
     768             :     ATTRIBUTE_NAME(ENUMERABLE),
     769             :     ATTRIBUTE_NAME(TRUE),
     770             :     ATTRIBUTE_NAME(FALSE),
     771             :     ATTRIBUTE_NAME(UNUSED),
     772             :     ATTRIBUTE_NAME(DYNAMIC),
     773             :     ATTRIBUTE_NAME(FOREACH),
     774             :     ATTRIBUTE_NAME(NOBREAK),
     775             :     ATTRIBUTE_NAME(AUTOBREAK),
     776             :     ATTRIBUTE_NAME(DEFINED)
     777             : };
     778             : size_t const g_attribute_table_size = sizeof(g_attribute_table) / sizeof(g_attribute_table[0]);
     779             : 
     780             : 
     781       16384 : as2js::Node::attribute_t str_to_attribute_code(as2js::String const& attr_name)
     782             : {
     783      188416 :     for(size_t idx(0); idx < g_attribute_table_size; ++idx)
     784             :     {
     785      188416 :         if(attr_name == g_attribute_table[idx].f_name)
     786             :         {
     787       16384 :             return g_attribute_table[idx].f_attribute;
     788             :         }
     789             :     }
     790           0 :     CPPUNIT_ASSERT(!"attribute code not found, test_as2js_parser.cpp bug");
     791           0 :     return as2js::Node::attribute_t::NODE_ATTR_max;
     792             : }
     793             : 
     794             : 
     795           0 : as2js::String attribute_to_str(as2js::Node::attribute_t& attr)
     796             : {
     797           0 :     for(size_t idx(0); idx < g_attribute_table_size; ++idx)
     798             :     {
     799           0 :         if(attr == g_attribute_table[idx].f_attribute)
     800             :         {
     801           0 :             return g_attribute_table[idx].f_name;
     802             :         }
     803             :     }
     804           0 :     CPPUNIT_ASSERT(!"attribute code not found, test_as2js_parser.cpp bug");
     805           0 :     return "";
     806             : }
     807             : 
     808             : 
     809             : 
     810             : 
     811    23158784 : void verify_attributes(as2js::Node::pointer_t node, as2js::String const& attributes_set, bool verbose)
     812             : {
     813             :     // list of attributes that have to be set
     814    23158784 :     std::vector<as2js::Node::attribute_t> attrs;
     815    23158784 :     as2js::as_char_t const *a(attributes_set.c_str());
     816    23158784 :     as2js::as_char_t const *s(a);
     817             :     for(;;)
     818             :     {
     819    23347200 :         if(*a == ',' || *a == '\0')
     820             :         {
     821    23158784 :             if(s == a)
     822             :             {
     823    46301184 :                 break;
     824             :             }
     825       16384 :             as2js::String name(s, a - s);
     826       16384 :             attrs.push_back(str_to_attribute_code(name));
     827       16384 :             if(*a == '\0')
     828             :             {
     829       16384 :                 break;
     830             :             }
     831           0 :             do // skip commas
     832             :             {
     833           0 :                 ++a;
     834             :             }
     835           0 :             while(*a == ',');
     836           0 :             s = a;
     837             :         }
     838             :         else
     839             :         {
     840      188416 :             ++a;
     841             :         }
     842      188416 :     }
     843             : 
     844             :     // list of attributes that must be checked
     845    46317568 :     std::vector<as2js::Node::attribute_t> attrs_to_check;
     846             : 
     847    23158784 :     if(node->get_type() != as2js::Node::node_t::NODE_PROGRAM)
     848             :     {
     849             :         // except for PROGRAM, all attributes always apply
     850    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_PUBLIC);
     851    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_PRIVATE);
     852    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_PROTECTED);
     853    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_INTERNAL);
     854    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_TRANSIENT);
     855    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_VOLATILE);
     856    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_STATIC);
     857    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_ABSTRACT);
     858    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_VIRTUAL);
     859    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_ARRAY);
     860    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_REQUIRE_ELSE);
     861    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_ENSURE_THEN);
     862    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_NATIVE);
     863    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_DEPRECATED);
     864    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_UNSAFE);
     865    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_CONSTRUCTOR);
     866    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_FINAL);
     867    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_ENUMERABLE);
     868    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_TRUE);
     869    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_FALSE);
     870    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_UNUSED);
     871    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_DYNAMIC);
     872    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_FOREACH);
     873    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_NOBREAK);
     874    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_AUTOBREAK);
     875    21921792 :         attrs_to_check.push_back(as2js::Node::attribute_t::NODE_ATTR_DEFINED);
     876             :     }
     877             : 
     878    23158784 :     CPPUNIT_ASSERT(attrs.size() <= attrs_to_check.size());
     879             : 
     880   593125376 :     for(size_t idx(0); idx < attrs_to_check.size(); ++idx)
     881             :     {
     882   569966592 :         as2js::Node::attribute_t attr(attrs_to_check[idx]);
     883   569966592 :         std::vector<as2js::Node::attribute_t>::iterator it(std::find(attrs.begin(), attrs.end(), attr));
     884   569966592 :         if(it == attrs.end())
     885             :         {
     886             :             // expected to be unset
     887   569950208 :             if(verbose && node->get_attribute(attr))
     888             :             {
     889           0 :                 std::cerr << "*** Comparing attributes " << attribute_to_str(attr) << " (should not be set)\n";
     890             :             }
     891   569950208 :             CPPUNIT_ASSERT(!node->get_attribute(attr));
     892             :         }
     893             :         else
     894             :         {
     895             :             // expected to be set
     896       16384 :             attrs.erase(it);
     897       16384 :             if(verbose && !node->get_attribute(attr))
     898             :             {
     899           0 :                 std::cerr << "*** Comparing attributes " << attribute_to_str(attr) << " (it should be set in this case)\n";
     900             :             }
     901       16384 :             CPPUNIT_ASSERT(node->get_attribute(attr));
     902             :         }
     903             :     }
     904             : 
     905    46317568 :     CPPUNIT_ASSERT(attrs.empty());
     906    23158784 : }
     907             : 
     908             : 
     909             : 
     910             : 
     911    23158784 : void verify_result(as2js::JSON::JSONValue::pointer_t expected, as2js::Node::pointer_t node, bool verbose)
     912             : {
     913    23158784 :     as2js::String node_type_string;
     914    23158784 :     node_type_string.from_utf8("node type");
     915    46317568 :     as2js::String children_string;
     916    23158784 :     children_string.from_utf8("children");
     917    46317568 :     as2js::String link_strings[static_cast<int>(as2js::Node::link_t::LINK_max)];
     918    23158784 :     link_strings[0].from_utf8("link instance");
     919    23158784 :     link_strings[1].from_utf8("link type");
     920    23158784 :     link_strings[2].from_utf8("link attributes");
     921    23158784 :     link_strings[3].from_utf8("link goto exit");
     922    23158784 :     link_strings[4].from_utf8("link goto enter");
     923    46317568 :     as2js::String label_string;
     924    23158784 :     label_string.from_utf8("label");
     925    46317568 :     as2js::String flags_string;
     926    23158784 :     flags_string.from_utf8("flags");
     927    46317568 :     as2js::String attributes_string;
     928    23158784 :     attributes_string.from_utf8("attributes");
     929    46317568 :     as2js::String integer_string;
     930    23158784 :     integer_string.from_utf8("integer");
     931    46317568 :     as2js::String float_string;
     932    23158784 :     float_string.from_utf8("float");
     933             : 
     934    23158784 :     CPPUNIT_ASSERT(expected->get_type() == as2js::JSON::JSONValue::type_t::JSON_TYPE_OBJECT);
     935    23158784 :     as2js::JSON::JSONValue::object_t const& child_object(expected->get_object());
     936             : 
     937    23158784 :     as2js::JSON::JSONValue::object_t::const_iterator it_node_type(child_object.find(node_type_string));
     938    23158784 :     if(it_node_type == child_object.end())
     939             :     {
     940           0 :         std::cerr << "\nerror: \"node type\" is mandatory in your JSON.\n";
     941           0 :         exit(1);
     942             :     }
     943    46317568 :     as2js::JSON::JSONValue::pointer_t node_type_value(it_node_type->second);
     944    23158784 :     if(verbose)
     945             :     {
     946           0 :         std::cerr << "*** Comparing " << node->get_type_name() << " (node) vs " << node_type_value->get_string() << " (JSON)\n";
     947             :     }
     948    23158784 :     CPPUNIT_ASSERT(node->get_type_name() == node_type_value->get_string());
     949             : 
     950    23158784 :     as2js::JSON::JSONValue::object_t::const_iterator it_label(child_object.find(label_string));
     951    23158784 :     if(it_label != child_object.end())
     952             :     {
     953             :         // we expect a string in this object
     954     8888320 :         if(verbose && node->get_string() != it_label->second->get_string())
     955             :         {
     956           0 :             std::cerr << "   Expecting string \"" << it_label->second->get_string() << "\", node has \"" << node->get_string() << "\"\n";
     957             :         }
     958     8888320 :         CPPUNIT_ASSERT(node->get_string() == it_label->second->get_string());
     959             :     }
     960             :     else
     961             :     {
     962             :         // the node cannot have a string otherwise, so we expect a throw
     963    14270464 :         CPPUNIT_ASSERT_THROW(node->get_string(), as2js::exception_internal_error);
     964             :     }
     965             : 
     966    23158784 :     as2js::JSON::JSONValue::object_t::const_iterator it_flags(child_object.find(flags_string));
     967    23158784 :     if(it_flags != child_object.end())
     968             :     {
     969             :         // the tester declared as set of flags that are expected to be set
     970     1417216 :         verify_flags(node, it_flags->second->get_string(), verbose);
     971             :     }
     972             :     else
     973             :     {
     974             :         // all flags must be unset
     975    21741568 :         verify_flags(node, "", verbose);
     976             :     }
     977             : 
     978             :     // WARNING: these attributes are what we call IMMEDIATE ATTRIBUTES in case
     979             :     //          of the parser because the parser also makes use of a
     980             :     //          LINK_ATTRIBUTES which represents a list of attributes
     981    23158784 :     as2js::JSON::JSONValue::object_t::const_iterator it_attributes(child_object.find(attributes_string));
     982    23158784 :     if(it_attributes != child_object.end())
     983             :     {
     984             :         // the tester declared as set of attributes that are expected to be set
     985       16384 :         verify_attributes(node, it_attributes->second->get_string(), verbose);
     986             :     }
     987             :     else
     988             :     {
     989             :         // all attributes must be unset
     990    23142400 :         verify_attributes(node, "", verbose);
     991             :     }
     992             : 
     993    23158784 :     as2js::JSON::JSONValue::object_t::const_iterator it_integer(child_object.find(integer_string));
     994    23158784 :     if(it_integer != child_object.end())
     995             :     {
     996             :         // we expect an integer in this object
     997     1286144 :         if(node->get_int64().get() != it_integer->second->get_int64().get())
     998             :         {
     999           0 :             std::cerr << "   Expecting " << it_integer->second->get_int64().get() << ", got " << node->get_int64().get() << " in the node\n";
    1000             :         }
    1001     1286144 :         CPPUNIT_ASSERT(node->get_int64().get() == it_integer->second->get_int64().get());
    1002             :     }
    1003             :     else
    1004             :     {
    1005             :         // the node cannot have an integer otherwise, so we expect a throw
    1006    21872640 :         CPPUNIT_ASSERT_THROW(node->get_int64(), as2js::exception_internal_error);
    1007             :     }
    1008             : 
    1009    23158784 :     as2js::JSON::JSONValue::object_t::const_iterator it_float(child_object.find(float_string));
    1010    23158784 :     if(it_float != child_object.end())
    1011             :     {
    1012             :         // if we expect a NaN we have to compare specifically
    1013             :         // because (NaN == NaN) always returns false
    1014      131072 :         if(it_float->second->get_float64().is_NaN())
    1015             :         {
    1016           0 :             CPPUNIT_ASSERT(node->get_float64().is_NaN());
    1017             :         }
    1018             :         else
    1019             :         {
    1020             :             // we expect a floating point number in this object
    1021             : #pragma GCC diagnostic push
    1022             : #pragma GCC diagnostic ignored "-Wfloat-equal"
    1023      131072 :             if(node->get_float64().get() != it_float->second->get_float64().get())
    1024             :             {
    1025           0 :                 std::cerr << "   Expecting " << it_float->second->get_float64().get() << ", got " << node->get_float64().get() << " in the node\n";
    1026             :             }
    1027      131072 :             CPPUNIT_ASSERT(node->get_float64().get() == it_float->second->get_float64().get());
    1028             : 
    1029             :             // further, if the float is zero, it may be +0.0 or -0.0
    1030      131072 :             if(it_float->second->get_float64().get() == 0.0)
    1031             :             {
    1032           0 :                 CPPUNIT_ASSERT(std::signbit(node->get_float64().get()) == std::signbit(it_float->second->get_float64().get()));
    1033             :             }
    1034             : #pragma GCC diagnostic pop
    1035             :         }
    1036             :     }
    1037             :     else
    1038             :     {
    1039             :         // the node cannot have a float otherwise, so we expect a throw
    1040    23027712 :         CPPUNIT_ASSERT_THROW(node->get_float64(), as2js::exception_internal_error);
    1041             :     }
    1042             : 
    1043             :     // List of links are tested just like children, only the list starts somewhere else
    1044   138952704 :     for(int link_idx(0); link_idx < static_cast<int>(as2js::Node::link_t::LINK_max); ++link_idx)
    1045             :     {
    1046   115793920 :         as2js::String link_name;
    1047   115793920 :         switch(static_cast<as2js::Node::link_t>(link_idx))
    1048             :         {
    1049             :         case as2js::Node::link_t::LINK_INSTANCE:
    1050    23158784 :             link_name = "instance";
    1051    23158784 :             break;
    1052             : 
    1053             :         case as2js::Node::link_t::LINK_TYPE:
    1054    23158784 :             link_name = "type";
    1055    23158784 :             break;
    1056             : 
    1057             :         case as2js::Node::link_t::LINK_ATTRIBUTES:
    1058    23158784 :             link_name = "attributes";
    1059    23158784 :             break;
    1060             : 
    1061             :         case as2js::Node::link_t::LINK_GOTO_EXIT:
    1062    23158784 :             link_name = "goto-exit";
    1063    23158784 :             break;
    1064             : 
    1065             :         case as2js::Node::link_t::LINK_GOTO_ENTER:
    1066    23158784 :             link_name = "goto-enter";
    1067    23158784 :             break;
    1068             : 
    1069             :         case as2js::Node::link_t::LINK_max:
    1070           0 :             CPPUNIT_ASSERT(!"LINK_max reached when getting the link type");
    1071           0 :             break;
    1072             : 
    1073             :         }
    1074   115793920 :         as2js::JSON::JSONValue::object_t::const_iterator it_link(child_object.find(link_strings[link_idx]));
    1075   115793920 :         as2js::Node::pointer_t link_node(node->get_link(static_cast<as2js::Node::link_t>(link_idx)));
    1076   115793920 :         if(link_node)
    1077             :         {
    1078             :             // make sure root node is of the right type
    1079      876544 :             switch(static_cast<as2js::Node::link_t>(link_idx))
    1080             :             {
    1081             :             case as2js::Node::link_t::LINK_INSTANCE:
    1082           0 :                 CPPUNIT_ASSERT(!"parser does not use LINK_INSTANCE");
    1083           0 :                 break;
    1084             : 
    1085             :             case as2js::Node::link_t::LINK_TYPE:
    1086           0 :                 CPPUNIT_ASSERT(!"parser does not use LINK_TYPE");
    1087           0 :                 break;
    1088             : 
    1089             :             case as2js::Node::link_t::LINK_ATTRIBUTES:
    1090      876544 :                 CPPUNIT_ASSERT(link_node->get_type() == as2js::Node::node_t::NODE_ATTRIBUTES);
    1091      876544 :                 break;
    1092             : 
    1093             :             case as2js::Node::link_t::LINK_GOTO_EXIT:
    1094           0 :                 CPPUNIT_ASSERT(!"parser does not use LINK_GOTO_EXIT");
    1095           0 :                 break;
    1096             : 
    1097             :             case as2js::Node::link_t::LINK_GOTO_ENTER:
    1098           0 :                 CPPUNIT_ASSERT(!"parser does not use LINK_GOTO_ENTER");
    1099           0 :                 break;
    1100             : 
    1101             :             case as2js::Node::link_t::LINK_max:
    1102           0 :                 CPPUNIT_ASSERT(!"LINK_max reached when testing the link_node type");
    1103           0 :                 break;
    1104             : 
    1105             :             }
    1106             :         }
    1107   115793920 :         if(it_link != child_object.end())
    1108             :         {
    1109             :             // the children value must be an array
    1110      876544 :             as2js::JSON::JSONValue::array_t const& array(it_link->second->get_array());
    1111      876544 :             size_t const max_links(array.size());
    1112      876544 :             if(link_node)
    1113             :             {
    1114      876544 :                 if(verbose && max_links != link_node->get_children_size())
    1115             :                 {
    1116           0 :                     std::cerr << "   Expecting " << max_links << " " << link_name << ", we have " << link_node->get_children_size() << " in the node\n";
    1117             :                 }
    1118      876544 :                 CPPUNIT_ASSERT(max_links == link_node->get_children_size());
    1119     1908736 :                 for(size_t idx(0); idx < max_links; ++idx)
    1120             :                 {
    1121     1032192 :                     as2js::JSON::JSONValue::pointer_t link_value(array[idx]);
    1122     1032192 :                     verify_result(link_value, link_node->get_child(idx), verbose); // recursive
    1123     1032192 :                 }
    1124             :             }
    1125             :             else
    1126             :             {
    1127           0 :                 if(verbose && max_links != 0)
    1128             :                 {
    1129           0 :                     std::cerr << "   Expecting " << max_links << " " << link_name << ", we have no " << link_name << " at all in the node\n";
    1130             :                 }
    1131           0 :                 CPPUNIT_ASSERT(max_links == 0);
    1132             :             }
    1133             :         }
    1134             :         else
    1135             :         {
    1136             :             // no children defined in the JSON, no children expected in the node
    1137   114917376 :             if(verbose && link_node && link_node->get_children_size() != 0)
    1138             :             {
    1139           0 :                 std::cerr << "   Expecting no " << link_name << " list, we have " << link_node->get_children_size() << " " << link_name << " in the node\n";
    1140             :             }
    1141   114917376 :             CPPUNIT_ASSERT(!link_node || link_node->get_children_size() == 0);
    1142             :         }
    1143   115793920 :     }
    1144             : 
    1145    23158784 :     as2js::JSON::JSONValue::object_t::const_iterator it_children(child_object.find(children_string));
    1146    23158784 :     if(it_children != child_object.end())
    1147             :     {
    1148             :         // the children value must be an array
    1149    13492224 :         as2js::JSON::JSONValue::array_t const& array(it_children->second->get_array());
    1150    13492224 :         size_t const max_children(array.size());
    1151    13492224 :         if(verbose && max_children != node->get_children_size())
    1152             :         {
    1153           0 :             std::cerr << "   Expecting " << max_children << " children, we have " << node->get_children_size() << " in the node\n";
    1154             :         }
    1155    13492224 :         CPPUNIT_ASSERT(max_children == node->get_children_size());
    1156    34381824 :         for(size_t idx(0); idx < max_children; ++idx)
    1157             :         {
    1158    20889600 :             as2js::JSON::JSONValue::pointer_t children_value(array[idx]);
    1159    20889600 :             verify_result(children_value, node->get_child(idx), verbose); // recursive
    1160    20889600 :         }
    1161             :     }
    1162             :     else
    1163             :     {
    1164             :         // no children defined in the JSON, no children expected in the node
    1165     9666560 :         if(verbose && node->get_children_size() != 0)
    1166             :         {
    1167           0 :             std::cerr << "   Expecting no children, we have " << node->get_children_size() << " in the node\n";
    1168             :         }
    1169     9666560 :         CPPUNIT_ASSERT(node->get_children_size() == 0);
    1170    23158784 :     }
    1171    23158784 : }
    1172             : 
    1173             : 
    1174             : //
    1175             : // JSON data used to test the parser, most of the work is in this table
    1176             : // these are long JSON strings! It is actually generated using the
    1177             : // json_to_string tool and the test_as2js_parser_*.json source files.
    1178             : //
    1179             : // Note: the top entries are arrays so we can execute programs in the
    1180             : //       order we define them...
    1181             : //
    1182             : char const g_basics[] =
    1183             : #include "test_as2js_parser_basics.ci"
    1184             : ;
    1185             : char const g_class[] =
    1186             : #include "test_as2js_parser_class.ci"
    1187             : ;
    1188             : char const g_function[] =
    1189             : #include "test_as2js_parser_function.ci"
    1190             : ;
    1191             : char const g_variable[] =
    1192             : #include "test_as2js_parser_variable.ci"
    1193             : ;
    1194             : char const g_data[] =
    1195             : #include "test_as2js_parser.ci"
    1196             : ;
    1197             : 
    1198             : 
    1199             : 
    1200             : 
    1201             : 
    1202             : 
    1203             : 
    1204             : 
    1205             : // This function runs all the tests defined in the
    1206             : // string 'data'
    1207           5 : void run_tests(char const *data, char const *filename)
    1208             : {
    1209           5 :     as2js::String input_data;
    1210           5 :     input_data.from_utf8(data);
    1211             : 
    1212           5 :     if(as2js_test::g_save_parser_tests)
    1213             :     {
    1214           0 :         std::ofstream json_file;
    1215           0 :         json_file.open(filename);
    1216           0 :         CPPUNIT_ASSERT(json_file.is_open());
    1217           0 :         json_file << "// To properly indent this JSON you may use http://json-indent.appspot.com/"
    1218           0 :                 << std::endl << data << std::endl;
    1219             :     }
    1220             : 
    1221          10 :     as2js::StringInput::pointer_t in(new as2js::StringInput(input_data));
    1222          10 :     as2js::JSON::pointer_t json_data(new as2js::JSON);
    1223          10 :     as2js::JSON::JSONValue::pointer_t json(json_data->parse(in));
    1224             : 
    1225             :     // verify that the parser() did not fail
    1226           5 :     CPPUNIT_ASSERT(!!json);
    1227           5 :     CPPUNIT_ASSERT(json->get_type() == as2js::JSON::JSONValue::type_t::JSON_TYPE_ARRAY);
    1228             : 
    1229          10 :     as2js::String name_string;
    1230           5 :     name_string.from_utf8("name");
    1231          10 :     as2js::String program_string;
    1232           5 :     program_string.from_utf8("program");
    1233          10 :     as2js::String verbose_string;
    1234           5 :     verbose_string.from_utf8("verbose");
    1235          10 :     as2js::String slow_string;
    1236           5 :     slow_string.from_utf8("slow");
    1237          10 :     as2js::String result_string;
    1238           5 :     result_string.from_utf8("result");
    1239          10 :     as2js::String expected_messages_string;
    1240           5 :     expected_messages_string.from_utf8("expected messages");
    1241             : 
    1242           5 :     std::cout << "\n";
    1243             : 
    1244           5 :     as2js::JSON::JSONValue::array_t const& array(json->get_array());
    1245           5 :     size_t const max_programs(array.size());
    1246         156 :     for(size_t idx(0); idx < max_programs; ++idx)
    1247             :     {
    1248         151 :         as2js::JSON::JSONValue::pointer_t prog_obj(array[idx]);
    1249         151 :         CPPUNIT_ASSERT(prog_obj->get_type() == as2js::JSON::JSONValue::type_t::JSON_TYPE_OBJECT);
    1250         151 :         as2js::JSON::JSONValue::object_t const& prog(prog_obj->get_object());
    1251             : 
    1252         151 :         bool verbose(false);
    1253         151 :         as2js::JSON::JSONValue::object_t::const_iterator verbose_it(prog.find(verbose_string));
    1254         151 :         if(verbose_it != prog.end())
    1255             :         {
    1256           0 :             verbose = verbose_it->second->get_type() == as2js::JSON::JSONValue::type_t::JSON_TYPE_TRUE;
    1257             :         }
    1258             : 
    1259         151 :         bool slow(false);
    1260         151 :         as2js::JSON::JSONValue::object_t::const_iterator slow_it(prog.find(slow_string));
    1261         151 :         if(slow_it != prog.end())
    1262             :         {
    1263          24 :             slow = slow_it->second->get_type() == as2js::JSON::JSONValue::type_t::JSON_TYPE_TRUE;
    1264             :         }
    1265             : 
    1266             :         // got a program, try to compile it with all the possible options
    1267         302 :         as2js::JSON::JSONValue::pointer_t name(prog.find(name_string)->second);
    1268         151 :         std::cout << "  -- working on \"" << name->get_string() << "\" " << (slow ? "" : "...") << std::flush;
    1269             : 
    1270     1237143 :         for(size_t opt(0); opt < (1 << g_options_size); ++opt)
    1271             :         {
    1272     1236992 :             if(slow && ((opt + 1) % 250) == 0)
    1273             :             {
    1274         768 :                 std::cout << "." << std::flush;
    1275             :             }
    1276             : //std::cerr << "\n***\n*** OPTIONS:";
    1277     1236992 :             as2js::Options::pointer_t options(new as2js::Options);
    1278    17317888 :             for(size_t o(0); o < g_options_size; ++o)
    1279             :             {
    1280    16080896 :                 if((opt & (1 << o)) != 0)
    1281             :                 {
    1282             :                     options->set_option(g_options[o].f_option,
    1283     8040448 :                             options->get_option(g_options[o].f_option) | g_options[o].f_value);
    1284             : //std::cerr << " " << g_options[o].f_name << "=" << g_options[o].f_value;
    1285             :                 }
    1286             :             }
    1287             : //std::cerr << "\n***\n";
    1288             : 
    1289     2473984 :             as2js::JSON::JSONValue::pointer_t program_value(prog.find(program_string)->second);
    1290     2473984 :             as2js::String program_source(program_value->get_string());
    1291             : //std::cerr << "prog = [" << program_source << "]\n";
    1292     2473984 :             as2js::StringInput::pointer_t prog_text(new as2js::StringInput(program_source));
    1293     2473984 :             as2js::Parser::pointer_t parser(new as2js::Parser(prog_text, options));
    1294             : 
    1295     2473984 :             test_callback tc(verbose);
    1296             : 
    1297     1236992 :             as2js::JSON::JSONValue::object_t::const_iterator expected_msg_it(prog.find(expected_messages_string));
    1298     1236992 :             if(expected_msg_it != prog.end())
    1299             :             {
    1300             : 
    1301             :                 // the expected messages value must be an array
    1302     1130496 :                 as2js::JSON::JSONValue::array_t const& msg_array(expected_msg_it->second->get_array());
    1303     1130496 :                 size_t const max_msgs(msg_array.size());
    1304     5218304 :                 for(size_t j(0); j < max_msgs; ++j)
    1305             :                 {
    1306     4087808 :                     as2js::JSON::JSONValue::pointer_t message_value(msg_array[j]);
    1307     4087808 :                     as2js::JSON::JSONValue::object_t const& message(message_value->get_object());
    1308             : 
    1309     4087808 :                     bool ignore_message(false);
    1310             : 
    1311     4087808 :                     as2js::JSON::JSONValue::object_t::const_iterator const message_options_iterator(message.find("options"));
    1312     4087808 :                     if(message_options_iterator != message.end())
    1313             :                     {
    1314             : //{
    1315             : //as2js::JSON::JSONValue::object_t::const_iterator line_it(message.find("line #"));
    1316             : //if(line_it != message.end())
    1317             : //{
    1318             : //    int64_t lines(line_it->second->get_int64().get());
    1319             : //std::cerr << "_________\nLine #" << lines << "\n";
    1320             : //}
    1321             : //else
    1322             : //std::cerr << "_________\nLine #<undefined>\n";
    1323             : //}
    1324     2179072 :                         as2js::String const message_options(message_options_iterator->second->get_string());
    1325    53125120 :                         for(as2js::as_char_t const *s(message_options.c_str()), *start(s);; ++s)
    1326             :                         {
    1327    53125120 :                             if(*s == ',' || *s == '|' || *s == '\0')
    1328             :                             {
    1329     2543616 :                                 as2js::String opt_name(start, s - start);
    1330    17461248 :                                 for(size_t o(0); o < g_options_size; ++o)
    1331             :                                 {
    1332    17461248 :                                     if(g_options[o].f_name == opt_name)
    1333             :                                     {
    1334     1249280 :                                         ignore_message = (opt & (1 << o)) != 0;
    1335             : //std::cerr << "+++ pos option [" << opt_name << "] " << ignore_message << "\n";
    1336     1249280 :                                         goto found_option;
    1337             :                                     }
    1338    16211968 :                                     else if(g_options[o].f_neg_name == opt_name)
    1339             :                                     {
    1340     1294336 :                                         ignore_message = (opt & (1 << o)) == 0;
    1341             : //std::cerr << "+++ neg option [" << opt_name << "] " << ignore_message << "\n";
    1342     1294336 :                                         goto found_option;
    1343             :                                     }
    1344             :                                 }
    1345           0 :                                 std::cerr << "Option \"" << opt_name << "\" not found in our list of valid options\n";
    1346           0 :                                 CPPUNIT_ASSERT(!"option name from JSON not found in g_options");
    1347             : 
    1348             : found_option:
    1349     2543616 :                                 if(*s == '\0')
    1350             :                                 {
    1351     1814528 :                                     break;
    1352             :                                 }
    1353      729088 :                                 if(*s == '|')
    1354             :                                 {
    1355      581632 :                                     if(ignore_message)
    1356             :                                     {
    1357      290816 :                                         break;
    1358             :                                     }
    1359             :                                 }
    1360             :                                 else
    1361             :                                 {
    1362      147456 :                                     if(!ignore_message)
    1363             :                                     {
    1364       73728 :                                         break;
    1365             :                                     }
    1366             :                                 }
    1367             : 
    1368             :                                 // skip commas
    1369      364544 :                                 do
    1370             :                                 {
    1371      364544 :                                     ++s;
    1372             :                                 }
    1373      729088 :                                 while(*s == ',' || *s == '|');
    1374      364544 :                                 start = s;
    1375             :                             }
    1376    53125120 :                         }
    1377             :                     }
    1378             : 
    1379     4087808 :                     if(!ignore_message)
    1380             :                     {
    1381     2889728 :                         test_callback::expected_t expected;
    1382     2889728 :                         expected.f_message_level = static_cast<as2js::message_level_t>(message.find("message level")->second->get_int64().get());
    1383     2889728 :                         expected.f_error_code = str_to_error_code(message.find("error code")->second->get_string());
    1384     2889728 :                         expected.f_pos.set_filename("unknown-file");
    1385     2889728 :                         as2js::JSON::JSONValue::object_t::const_iterator func_it(message.find("function name"));
    1386     2889728 :                         if(func_it == message.end())
    1387             :                         {
    1388     2889728 :                             expected.f_pos.set_function("unknown-func");
    1389             :                         }
    1390             :                         else
    1391             :                         {
    1392           0 :                             expected.f_pos.set_function(func_it->second->get_string());
    1393             :                         }
    1394     2889728 :                         as2js::JSON::JSONValue::object_t::const_iterator line_it(message.find("line #"));
    1395     2889728 :                         if(line_it != message.end())
    1396             :                         {
    1397     2889728 :                             int64_t lines(line_it->second->get_int64().get());
    1398    24582144 :                             for(int64_t l(1); l < lines; ++l)
    1399             :                             {
    1400    21692416 :                                 expected.f_pos.new_line();
    1401             :                             }
    1402             :                         }
    1403     2889728 :                         expected.f_message = message.find("message")->second->get_string();
    1404             : //std::cerr << "    --- message [" << expected.f_message << "]\n";
    1405     2889728 :                         tc.f_expected.push_back(expected);
    1406             :                     }
    1407     4087808 :                 }
    1408             :             }
    1409             : 
    1410     1236992 :             as2js::Node::pointer_t root(parser->parse());
    1411             : 
    1412     1236992 :             tc.got_called();
    1413             : 
    1414             :             // the result is object which can have children
    1415             :             // which are represented by an array of objects
    1416     1236992 :             verify_result(prog.find(result_string)->second, root, verbose);
    1417     2473984 :         }
    1418             : 
    1419         151 :         std::cout << " OK\n";
    1420         156 :     }
    1421           5 : }
    1422             : 
    1423             : 
    1424             : }
    1425             : // no name namespace
    1426             : 
    1427             : 
    1428             : 
    1429             : 
    1430             : 
    1431           1 : void As2JsParserUnitTests::test_parser_basics()
    1432             : {
    1433           1 :     run_tests(g_basics, "test_parser_basics.json");
    1434           1 : }
    1435             : 
    1436             : 
    1437           1 : void As2JsParserUnitTests::test_parser_class()
    1438             : {
    1439           1 :     run_tests(g_class, "test_parser_class.json");
    1440           1 : }
    1441             : 
    1442             : 
    1443           1 : void As2JsParserUnitTests::test_parser_function()
    1444             : {
    1445           1 :     run_tests(g_function, "test_parser_function.json");
    1446           1 : }
    1447             : 
    1448             : 
    1449           1 : void As2JsParserUnitTests::test_parser_variable()
    1450             : {
    1451           1 :     run_tests(g_variable, "test_parser_variable.json");
    1452           1 : }
    1453             : 
    1454             : 
    1455           1 : void As2JsParserUnitTests::test_parser()
    1456             : {
    1457           1 :     run_tests(g_data, "test_parser.json");
    1458          13 : }
    1459             : 
    1460             : 
    1461             : 
    1462             : 
    1463             : 
    1464             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.10