Skip to content
Snippets Groups Projects
Commit 6564cc41 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Clarified error messages for missing semicolon.

parent 11f12b4d
No related branches found
No related tags found
No related merge requests found
......@@ -182,6 +182,15 @@ Currently undocumented (will be merged with sieve-test).
Various example scripts are bundled in the directory 'examples'.
Known issues
------------
Most open issues are outlined in the TODO file. The more generic ones are (re-)
listed here:
- Compile errors are sometimes a bit obscure and long. This needs work.
Suggestions for improvement are welcome.
Authors
-------
......
......@@ -857,24 +857,44 @@ static bool sieve_validate_arguments_context
*/
static bool sieve_validate_command_subtests
(struct sieve_validator *validator, struct sieve_command_context *cmd,
(struct sieve_validator *valdtr, struct sieve_command_context *cmd,
const unsigned int count)
{
switch ( count ) {
case 0:
if ( sieve_ast_test_count(cmd->ast_node) > 0 ) {
sieve_command_validate_error(validator, cmd,
"the %s %s accepts no sub-tests, but tests are specified anyway "
"(forgot semicolon?)",
cmd->command->identifier, sieve_command_type_name(cmd->command));
/* Unexpected command specified */
enum sieve_command_type ctype = SCT_NONE;
struct sieve_command_registration *cmd_reg;
struct sieve_ast_node *test = sieve_ast_test_first(cmd->ast_node);
cmd_reg = sieve_validator_find_command_registration
(valdtr, test->identifier);
/* First check what we are dealing with */
if ( cmd_reg != NULL && cmd_reg->command != NULL )
ctype = cmd_reg->command->type;
switch ( ctype ) {
case SCT_TEST:
sieve_command_validate_error(valdtr, cmd,
"the %s %s accepts no sub-tests, but one is specified anyway",
cmd->command->identifier, sieve_command_type_name(cmd->command));
break;
case SCT_NONE:
case SCT_COMMAND:
sieve_command_validate_error(valdtr, cmd,
"missing semicolon ';' after %s %s",
cmd->command->identifier, sieve_command_type_name(cmd->command));
break;
}
return FALSE;
}
break;
case 1:
if ( sieve_ast_test_count(cmd->ast_node) == 0 ) {
sieve_command_validate_error(validator, cmd,
sieve_command_validate_error(valdtr, cmd,
"the %s %s requires one sub-test, but none is specified",
cmd->command->identifier, sieve_command_type_name(cmd->command));
......@@ -883,7 +903,7 @@ static bool sieve_validate_command_subtests
} else if ( sieve_ast_test_count(cmd->ast_node) > 1 ||
cmd->ast_node->test_list ) {
sieve_command_validate_error(validator, cmd,
sieve_command_validate_error(valdtr, cmd,
"the %s %s requires one sub-test, but a list of tests is specified",
cmd->command->identifier, sieve_command_type_name(cmd->command));
......@@ -893,7 +913,7 @@ static bool sieve_validate_command_subtests
default:
if ( sieve_ast_test_count(cmd->ast_node) == 0 ) {
sieve_command_validate_error(validator, cmd,
sieve_command_validate_error(valdtr, cmd,
"the %s %s requires a list of sub-tests, but none is specified",
cmd->command->identifier, sieve_command_type_name(cmd->command));
......@@ -902,7 +922,7 @@ static bool sieve_validate_command_subtests
} else if ( sieve_ast_test_count(cmd->ast_node) == 1 &&
!cmd->ast_node->test_list ) {
sieve_command_validate_error(validator, cmd,
sieve_command_validate_error(valdtr, cmd,
"the %s %s requires a list of sub-tests, "
"but a single test is specified",
cmd->command->identifier, sieve_command_type_name(cmd->command) );
......
......@@ -80,7 +80,7 @@ test "Header errors" {
}
if not test_error :index 7 :matches
"*header test accepts no sub-tests* are specified*" {
"*header test accepts no sub-tests* is specified*" {
test_fail "error 7 is invalid";
}
......@@ -313,6 +313,36 @@ test "Tagged argument errors (FIXME: count only)" {
}
}
/*
* Typos
*/
test "Typos" {
if test_compile "errors/typos.sieve" {
test_fail "compile should have failed.";
}
if not test_error :count "eq" :comparator "i;ascii-numeric" "4" {
test_fail "wrong number of errors reported";
}
if not test_error :index 1 :matches
"missing semicolon * fileinto *" {
test_fail "error 1 is invalid";
}
if not test_error :index 2 :matches
"*fileinto command * no *tests* one is specified*" {
test_fail "error 2 is invalid";
}
if not test_error :index 3 :matches
"missing semicolon * fileinto *" {
test_fail "error 3 is invalid";
}
}
/*
* Unsupported language features
*/
......@@ -326,4 +356,3 @@ test "Unsupported language features (FIXME: count only)" {
test_fail "wrong number of errors reported";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.