Bigtop
view release on metacpan or search on metacpan
t/04_parse_errors.t view on Meta::CPAN
}
field category {
is int;
label `Expense Category`;
}
}
}
EO_Bigtop
@correct_error_output = split /\n/, <<'EO_error_output';
Error: missing semi-colon (possible run-away string beginning on line 11.)
on line 15 near:
Expense Category`;
}
}
}
EO_error_output
Bigtop::Parser->add_valid_keywords(
'field',
{ keyword => 'is' },
{ keyword => 'update_with' },
{ keyword => 'label' },
);
eval {
my $conf = Bigtop::Parser->parse_string($bigtop_string);
};
@error_output = split /\n/, $@;
is_deeply(
\@error_output,
\@correct_error_output,
'runaway string/missing semicolon'
);
#---------------------------------------------------------------------------
# invalid field keyword
#---------------------------------------------------------------------------
$bigtop_string = <<"EO_Bigtop_label_error";
config {
base_dir `.`;
SQL Postgres {}
HttpdConf Gantry {}
}
app Apps::Checkbook {
table payeepayor {
field id { is int, primary_key, auto; }
field name {
is varchar;
lable `Payee or Payor`;
}
}
}
EO_Bigtop_label_error
@correct_error_output = split /\n/, <<'EO_keyword_error';
Error: invalid keyword 'lable' (line 11) near:
`Payee or Payor`;
I was expecting one of these: is, label, not_for, on_delete, on_update, refers_to, update_with.
EO_keyword_error
Bigtop::Parser->add_valid_keywords(
'field',
{ keyword => 'is' },
{ keyword => 'update_with' },
{ keyword => 'label' },
);
eval {
my $conf = Bigtop::Parser->parse_string($bigtop_string);
};
@error_output = split /\n/, $@;
is_deeply(
\@error_output,
\@correct_error_output,
'invalid keyword'
);
#---------------------------------------------------------------------------
# => instead of space
#---------------------------------------------------------------------------
$bigtop_string = <<"EO_Bigtop";
config {
base_dir `.`;
SQL Postgres {}
HttpdConf Gantry {}
}
app Apps::Checkbook {
table payeepayor {
field id { is int, primary_key, auto; }
field name {
is varchar;
label => `Payee or Payor`;
}
field category {
is int;
label `Expense Category`;
}
}
}
EO_Bigtop
my $filler = ' ' x 8;
@correct_error_output = split /\n/, <<"EO_fat_comma";
Error: I was expecting an argument or argument list
on line 11 near:
=> `Payee or Payor`;
}
field category {
$filler
EO_fat_comma
#Bigtop::Parser->add_valid_keywords( 'field', qw( is update_with label ) );
eval {
my $conf = Bigtop::Parser->parse_string($bigtop_string);
};
( run in 0.472 second using v1.01-cache-2.11-cpan-39bf76dae61 )