Skip to content

Commit

Permalink
fix wpt testrunner
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jan 7, 2025
1 parent d5f2203 commit 3f5b3e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
3 changes: 2 additions & 1 deletion include/ada/url_pattern-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ url_pattern_component::create_component_match_result(
// Let name be component’s group name list[index].
// Let value be Get(execResult, ToString(index)).
// Set groups[name] to value.
if (auto str = exec_result[index].str(); !str.empty()) {
auto match = exec_result[index];
if (auto str = match.str(); !str.empty()) {
result.groups.insert({
group_name_list[index],
str,
Expand Down
7 changes: 5 additions & 2 deletions include/ada/url_pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ struct url_pattern_component_result {
#if ADA_TESTING
friend void PrintTo(const url_pattern_component_result& result,
std::ostream* os) {
*os << "input: " << result.input
<< ", groups_size: " << result.groups.size();
*os << "input: '" << result.input
<< "', group: ";
for (const auto& group : result.groups) {
*os << "(" << group.first << ", " << group.second << ") ";
}
}
#endif // ADA_TESTING
};
Expand Down
30 changes: 10 additions & 20 deletions tests/wpt/urlpatterntestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,8 @@
{
"pattern": [{ "pathname": "/foo/:bar?" }],
"inputs": [{ "pathname": "/foo" }],
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"pathname": { "input": "/foo", "groups": { "bar": null } }
"pathname": { "input": "/foo", "groups": {} }
}
},
{
Expand Down Expand Up @@ -445,9 +444,8 @@
{
"pattern": [{ "pathname": "/foo/:bar*" }],
"inputs": [{ "pathname": "/foo" }],
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"pathname": { "input": "/foo", "groups": { "bar": null } }
"pathname": { "input": "/foo", "groups": {} }
}
},
{
Expand Down Expand Up @@ -500,17 +498,15 @@
"expected_obj": {
"pathname": "/foo/*?"
},
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"pathname": { "input": "/foo", "groups": { "0": null } }
"pathname": { "input": "/foo", "groups": {} }
}
},
{
"pattern": [{ "pathname": "/foo/*?" }],
"inputs": [{ "pathname": "/foo" }],
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"pathname": { "input": "/foo", "groups": { "0": null } }
"pathname": { "input": "/foo", "groups": {} }
}
},
{
Expand Down Expand Up @@ -686,17 +682,15 @@
"expected_obj": {
"pathname": "/foo/**"
},
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"pathname": { "input": "/foo", "groups": { "0": null } }
"pathname": { "input": "/foo", "groups": {} }
}
},
{
"pattern": [{ "pathname": "/foo/**" }],
"inputs": [{ "pathname": "/foo" }],
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"pathname": { "input": "/foo", "groups": { "0": null } }
"pathname": { "input": "/foo", "groups": {} }
}
},
{
Expand Down Expand Up @@ -1823,10 +1817,9 @@
"hostname": "(sub.)?example.com",
"pathname": "/foo"
},
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"hostname": { "input": "example.com", "groups": { "0": null } },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/foo", "groups": {} }
}
},
Expand Down Expand Up @@ -1860,10 +1853,9 @@
"hostname": "(sub(?:.))?example.com",
"pathname": "/foo"
},
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"hostname": { "input": "example.com", "groups": { "0": null } },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/foo", "groups": {} }
}
},
Expand Down Expand Up @@ -2295,10 +2287,9 @@
"protocol": "data",
"pathname": "text/javascript,let x = 100/:tens?5;"
},
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"protocol": { "input": "data", "groups": {} },
"pathname": { "input": "text/javascript,let x = 100/5;", "groups": { "tens": null } }
"pathname": { "input": "text/javascript,let x = 100/5;", "groups": {} }
}
},
{
Expand Down Expand Up @@ -2608,9 +2599,8 @@
"expected_obj": {
"pathname": "*(.*)?"
},
"//": "The `null` below is translated to undefined in the test harness.",
"expected_match": {
"pathname": { "input": "foobar", "groups": { "0": "foobar", "1": null }}
"pathname": { "input": "foobar", "groups": { "0": "foobar" }}
}
},
{
Expand Down
5 changes: 2 additions & 3 deletions tests/wpt_urlpattern_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,10 @@ ada::url_pattern_component_result parse_component_result(
ondemand::object groups;
EXPECT_FALSE(element.value().get_object().get(groups));
for (auto group : groups) {
auto group_key = group.escaped_key().value();
auto group_key = group.unescaped_key().value();
std::string_view group_value;
EXPECT_FALSE(group.value().get_string(group_value));
result.groups.insert_or_assign(std::string(group_key),
group_value);
result.groups.insert_or_assign(std::string(group_key), std::string(group_value));
}
}
}
Expand Down

0 comments on commit 3f5b3e6

Please sign in to comment.