diff -Nru as2js-0.1.39.3~mantic/as2js/node/node_operator.cpp as2js-0.1.40.0~mantic/as2js/node/node_operator.cpp --- as2js-0.1.39.3~mantic/as2js/node/node_operator.cpp 2023-09-17 16:29:06.000000000 +0000 +++ as2js-0.1.40.0~mantic/as2js/node/node_operator.cpp 2023-12-10 16:15:39.000000000 +0000 @@ -130,7 +130,8 @@ { node_t::NODE_BITWISE_NOT, "~", __LINE__ }, // two or more characters transformed to an enum only - { node_t::NODE_ALMOST_EQUAL, "\u2248", __LINE__ }, // this is just one character too, but UTF-8 + { node_t::NODE_ALMOST_EQUAL, "\u2248", __LINE__ }, // this is just one character too, but UTF-8, so 3 bytes + { node_t::NODE_ARROW, "=>", __LINE__ }, { node_t::NODE_ASSIGNMENT_ADD, "+=", __LINE__ }, { node_t::NODE_ASSIGNMENT_BITWISE_AND, "&=", __LINE__ }, { node_t::NODE_ASSIGNMENT_BITWISE_OR, "|=", __LINE__ }, @@ -236,7 +237,7 @@ // check only once // checked = true; - for(size_t idx = 1; idx < g_operator_to_string_size; ++idx) + for(std::size_t idx(1); idx < g_operator_to_string_size; ++idx) { if(g_operator_to_string[idx].f_node <= g_operator_to_string[idx - 1].f_node) [[unlikely]] { @@ -315,6 +316,7 @@ for(size_t idx(0); idx < g_operator_to_string_size; ++idx) { // not sorted by name so we use a slow poke search... + // if(str == g_operator_to_string[idx].f_name) { return g_operator_to_string[idx].f_node; @@ -330,44 +332,40 @@ return node_t::NODE_NOT_EQUAL; } if(str == ":=" - || str == "\xE2\x89\x94") + || str == "\u2254") { return node_t::NODE_ASSIGNMENT; } - if(str == "\xC3\x97") + if(str == "\u00D7") { return node_t::NODE_MULTIPLY; } - if(str == "\xC3\xB7") + if(str == "\u00F7") { return node_t::NODE_DIVIDE; } - if(str == "\xE2\x87\x92") + if(str == "\u21D2") { return node_t::NODE_ARROW; } - if(str == "\xE2\x88\x88" - || str == "\xE2\x88\x8A") + if(str == "\u2208" + || str == "\u220A") { return node_t::NODE_IN; } - if(str == "\xE2\x88\xA7") + if(str == "\u2227") { return node_t::NODE_LOGICAL_AND; } - if(str == "\xE2\x88\xA8") + if(str == "\u2228") { return node_t::NODE_LOGICAL_OR; } - if(str == "\xE2\x89\x88") - { - return node_t::NODE_ALMOST_EQUAL; - } - if(str == "\xE2\x89\xA4") + if(str == "\u2264") { return node_t::NODE_LESS_EQUAL; } - if(str == "\xE2\x89\xA5") + if(str == "\u2265") { return node_t::NODE_GREATER_EQUAL; } diff -Nru as2js-0.1.39.3~mantic/as2js/node/node_tree.cpp as2js-0.1.40.0~mantic/as2js/node/node_tree.cpp --- as2js-0.1.39.3~mantic/as2js/node/node_tree.cpp 2023-09-17 16:30:33.000000000 +0000 +++ as2js-0.1.40.0~mantic/as2js/node/node_tree.cpp 2023-12-10 16:15:39.000000000 +0000 @@ -837,7 +837,7 @@ pointer_t me(const_cast(this)->shared_from_this()); if(me != child->get_parent()) { - throw parent_child("find_next_child() called with a child which is not a child of this node."); + throw parent_child("find_next_child() called with a child which is not a child of this node."); // LCOV_EXCL_LINE } } #endif diff -Nru as2js-0.1.39.3~mantic/as2js/node.h as2js-0.1.40.0~mantic/as2js/node.h --- as2js-0.1.39.3~mantic/as2js/node.h 2023-09-04 19:01:51.000000000 +0000 +++ as2js-0.1.40.0~mantic/as2js/node.h 2023-12-10 16:15:39.000000000 +0000 @@ -626,7 +626,7 @@ void set_child(int index, pointer_t child); pointer_t get_child(int index) const; pointer_t find_first_child(node_t type) const; - pointer_t find_next_child(pointer_t start, node_t type) const; + pointer_t find_next_child(pointer_t child, node_t type) const; pointer_t find_descendent(node_t type, node_filter_t filter) const; void clean_tree(); diff -Nru as2js-0.1.39.3~mantic/debian/changelog as2js-0.1.40.0~mantic/debian/changelog --- as2js-0.1.39.3~mantic/debian/changelog 2023-11-11 02:08:12.000000000 +0000 +++ as2js-0.1.40.0~mantic/debian/changelog 2023-12-10 16:15:39.000000000 +0000 @@ -1,4 +1,11 @@ -as2js (0.1.39.3~mantic) mantic; urgency=high +as2js (0.1.40.0~mantic) mantic; urgency=high + + * Properly test all special operators (Unicode and things such as := and <>). + * Added a test for the check of the parent/child in next_child(). + + -- Alexis Wilke Sun, 10 Dec 2023 08:15:39 -0800 + +as2js (0.1.39.3~bionic) bionic; urgency=high * Bumped build version to rebuild on Launchpad. diff -Nru as2js-0.1.39.3~mantic/seed.txt as2js-0.1.40.0~mantic/seed.txt --- as2js-0.1.39.3~mantic/seed.txt 2023-09-04 19:50:03.000000000 +0000 +++ as2js-0.1.40.0~mantic/seed.txt 2023-12-10 16:15:39.000000000 +0000 @@ -1 +1 @@ -1693857003 +1702248626 diff -Nru as2js-0.1.39.3~mantic/tests/catch_node.cpp as2js-0.1.40.0~mantic/tests/catch_node.cpp --- as2js-0.1.39.3~mantic/tests/catch_node.cpp 2023-08-29 16:52:49.000000000 +0000 +++ as2js-0.1.40.0~mantic/tests/catch_node.cpp 2023-12-10 16:15:39.000000000 +0000 @@ -254,16 +254,60 @@ //std::cerr << " testing " << node->get_type_name() << " from " << op << std::endl; CATCH_REQUIRE(as2js::node::string_to_operator(op) == g_node_types[i].f_type); - // check the special case for not equal - if(strcmp(g_node_types[i].f_operator, "!=") == 0) + // check the special cases + // + switch(g_node_types[i].f_type) { + case as2js::node_t::NODE_NOT_EQUAL: CATCH_REQUIRE(as2js::node::string_to_operator("<>") == g_node_types[i].f_type); - } + break; - // check the special case for assignment - if(strcmp(g_node_types[i].f_operator, "=") == 0) - { + case as2js::node_t::NODE_ASSIGNMENT: CATCH_REQUIRE(as2js::node::string_to_operator(":=") == g_node_types[i].f_type); + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x89\x94") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_MULTIPLY: + CATCH_REQUIRE(as2js::node::string_to_operator("\xC3\x97") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_DIVIDE: + CATCH_REQUIRE(as2js::node::string_to_operator("\xC3\xB7") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_ARROW: + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x87\x92") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_IN: + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x88\x88") == g_node_types[i].f_type); + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x88\x8A") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_LOGICAL_AND: + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x88\xA7") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_LOGICAL_OR: + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x88\xA8") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_ALMOST_EQUAL: + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x89\x88") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_LESS_EQUAL: + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x89\xA4") == g_node_types[i].f_type); + break; + + case as2js::node_t::NODE_GREATER_EQUAL: + CATCH_REQUIRE(as2js::node::string_to_operator("\xE2\x89\xA5") == g_node_types[i].f_type); + break; + + default: + // no special case + break; + } } else @@ -2274,6 +2318,8 @@ // int counter(0); + as2js::node::pointer_t other_node(std::make_shared(as2js::node_t::NODE_VOID)); + // first test: try with all types as the parent and children for(size_t i(0); i < g_node_types_size; ++i) { @@ -2435,7 +2481,15 @@ CATCH_REQUIRE(child->get_offset() == valid_children); CATCH_REQUIRE(parent->get_child(valid_children) == child); CATCH_REQUIRE(parent->find_first_child(child_type) == child); - CATCH_REQUIRE(!parent->find_next_child(child, child_type)); + CATCH_REQUIRE(parent->find_next_child(child, child_type) == nullptr); + + // test with a node which is not a child of "parent" + // + CATCH_REQUIRE_THROWS_MATCHES( + parent->find_next_child(other_node, child_type) + , as2js::parent_child + , Catch::Matchers::ExceptionMessage( + "as2js_exception: find_next_child() called with a child which is not a child of this node.")); ++valid_children; break; diff -Nru as2js-0.1.39.3~mantic/tests/catch_node_data.ci as2js-0.1.40.0~mantic/tests/catch_node_data.ci --- as2js-0.1.39.3~mantic/tests/catch_node_data.ci 2023-09-04 19:03:20.000000000 +0000 +++ as2js-0.1.40.0~mantic/tests/catch_node_data.ci 2023-12-10 16:15:39.000000000 +0000 @@ -648,7 +648,7 @@ { .f_type = as2js::node_t::NODE_ARROW, .f_name = "ARROW", - .f_operator = nullptr, + .f_operator = "=>", .f_flags = TEST_NODE_IS_NAN, .f_node_flags = g_flags_none }, Binary files /tmp/tmp_ekmai7c/hzaUtfEOlz/as2js-0.1.39.3~mantic/tests/gmon.out and /tmp/tmp_ekmai7c/K8YO4L7DhA/as2js-0.1.40.0~mantic/tests/gmon.out differ Binary files /tmp/tmp_ekmai7c/hzaUtfEOlz/as2js-0.1.39.3~mantic/tools/gmon.out and /tmp/tmp_ekmai7c/K8YO4L7DhA/as2js-0.1.40.0~mantic/tools/gmon.out differ