Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunshine40 committed Jun 7, 2024
1 parent 5a23111 commit ceaa42b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,10 @@ function initSearch(rawSearchIndex) {
) {
break;
} else if (parserState.pos > 0) {
throw ["Unexpected ", c, " after ", parserState.userQuery[parserState.pos - 1]];
throw ["Unexpected ", c, " after ", parserState.userQuery[parserState.pos - 1],
" (not a valid identifier)"];
} else {
throw ["Unexpected ", c];
throw ["Unexpected ", c, " (not a valid identifier)"];
}
parserState.pos += 1;
afterIdent = consumeIdent(parserState);
Expand Down
23 changes: 16 additions & 7 deletions tests/rustdoc-js-std/parser-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const PARSED = [
original: "-> *",
returned: [],
userQuery: "-> *",
error: "Unexpected `*` after ` `",
error: "Unexpected `*` after ` ` (not a valid identifier)",
},
{
query: 'a<"P">',
Expand Down Expand Up @@ -204,16 +204,25 @@ const PARSED = [
original: "_:",
returned: [],
userQuery: "_:",
error: "Unexpected `:` (expected path after type filter `_:`)",
error: "Unexpected `_` (not a valid identifier)",
},
{
query: "_:a",
query: "ab:",
elems: [],
foundElems: 0,
original: "_:a",
original: "ab:",
returned: [],
userQuery: "_:a",
error: "Unknown type filter `_`",
userQuery: "ab:",
error: "Unexpected `:` (expected path after type filter `ab:`)",
},
{
query: "a:b",
elems: [],
foundElems: 0,
original: "a:b",
returned: [],
userQuery: "a:b",
error: "Unknown type filter `a`",
},
{
query: "a-bb",
Expand All @@ -240,7 +249,7 @@ const PARSED = [
original: "ab'",
returned: [],
userQuery: "ab'",
error: "Unexpected `'` after `b`",
error: "Unexpected `'` after `b` (not a valid identifier)",
},
{
query: "a->",
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-js/non-english-identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const PARSED = [
original: "非法符号——",
returned: [],
userQuery: "非法符号——",
error: "Unexpected `—` after `号`",
error: "Unexpected `—` after `号` (not a valid identifier)",
}
]
const EXPECTED = [
Expand Down

0 comments on commit ceaa42b

Please sign in to comment.