mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 19:22:45 +08:00
Fix tests for new )
token error
This commit is contained in:
parent
df89d71237
commit
7447432471
|
@ -578,6 +578,15 @@ static void test_tokenizer() {
|
|||
do_test(token.error_offset == 3);
|
||||
}
|
||||
|
||||
{
|
||||
tokenizer_t t(L"abc )defg(hij", 0);
|
||||
do_test(t.next(&token));
|
||||
do_test(t.next(&token));
|
||||
do_test(token.type == TOK_ERROR);
|
||||
do_test(token.error == TOK_CLOSING_UNOPENED_SUBSHELL);
|
||||
do_test(token.error_offset == 4);
|
||||
}
|
||||
|
||||
{
|
||||
tokenizer_t t(L"abc defg(hij (klm)", 0);
|
||||
do_test(t.next(&token));
|
||||
|
@ -4420,10 +4429,11 @@ static void test_illegal_command_exit_code() {
|
|||
|
||||
const command_result_tuple_t tests[] = {
|
||||
{L"echo -n", STATUS_CMD_OK}, {L"pwd", STATUS_CMD_OK},
|
||||
{L")", STATUS_ILLEGAL_CMD}, {L") ", STATUS_ILLEGAL_CMD},
|
||||
// a `)` without a matching `(` is now a tokenizer error, and cannot be executed even as an illegal command
|
||||
// {L")", STATUS_ILLEGAL_CMD}, {L") ", STATUS_ILLEGAL_CMD}, {L") ", STATUS_ILLEGAL_CMD}
|
||||
{L"*", STATUS_ILLEGAL_CMD}, {L"**", STATUS_ILLEGAL_CMD},
|
||||
{L"?", STATUS_ILLEGAL_CMD}, {L"abc?def", STATUS_ILLEGAL_CMD},
|
||||
{L") ", STATUS_ILLEGAL_CMD}};
|
||||
};
|
||||
|
||||
int res = 0;
|
||||
const io_chain_t empty_ios;
|
||||
|
|
|
@ -180,7 +180,7 @@ tok_t tokenizer_t::read_string() {
|
|||
else if (c == L')') {
|
||||
switch (paran_offsets.size()) {
|
||||
case 0:
|
||||
return this->call_error(TOK_CLOSING_UNOPENED_SUBSHELL, buff_start, this->buff);
|
||||
return this->call_error(TOK_CLOSING_UNOPENED_SUBSHELL, this->start, this->buff);
|
||||
case 1:
|
||||
mode &= ~(tok_mode::subshell);
|
||||
default:
|
||||
|
@ -195,7 +195,7 @@ tok_t tokenizer_t::read_string() {
|
|||
//prints an error message with the caret pointing at token_start,
|
||||
//not err_loc, making the TOK_ILLEGAL_SLICE message misleading.
|
||||
// return call_error(TOK_ILLEGAL_SLICE, buff_start, this->buff);
|
||||
return call_error(TOK_UNTERMINATED_SLICE, buff_start, this->buff);
|
||||
return this->call_error(TOK_UNTERMINATED_SLICE, this->start, this->buff);
|
||||
}
|
||||
slice_offset = this->buff - this->start;
|
||||
mode |= tok_mode::array_brackets;
|
||||
|
|
Loading…
Reference in New Issue
Block a user