[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Add test for regressions specific of parse_texi_l
From: |
Patrice Dumas |
Subject: |
branch master updated: Add test for regressions specific of parse_texi_line |
Date: |
Sun, 09 Jan 2022 05:07:37 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new b934582fe4 Add test for regressions specific of parse_texi_line
b934582fe4 is described below
commit b934582fe41b0ece588322f967cb053391c28860
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 9 11:07:10 2022 +0100
Add test for regressions specific of parse_texi_line
---
tp/t/test_parse_texi_line.t | 59 ++++++++++++++++++++++++++++++++++++++++++++
tp/t/test_parser_registrar.t | 1 -
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/tp/t/test_parse_texi_line.t b/tp/t/test_parse_texi_line.t
new file mode 100644
index 0000000000..1d1cdaed07
--- /dev/null
+++ b/tp/t/test_parse_texi_line.t
@@ -0,0 +1,59 @@
+use strict;
+
+use lib '.';
+use Texinfo::ModulePath (undef, undef, 'updirs' => 2);
+
+use Test::More;
+
+BEGIN { plan tests => 7; }
+
+use Texinfo::Convert::Texinfo;
+use Texinfo::Parser;
+
+# test regressions specific of parse_texi_line
+
+sub test_line($$$$)
+{
+ my $parser = shift;
+ my $texinfo_line = shift;
+ my $test_explanation = shift;
+ my $errors_references = shift;
+
+ if (not defined($parser)) {
+ $parser = Texinfo::Parser::parser();
+ }
+
+ my $tree = $parser->parse_texi_line($texinfo_line);
+ my $check_texinfo = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
+ is ($texinfo_line, $check_texinfo, $test_explanation);
+
+ my $parser_registrar = $parser->registered_errors();
+ my ($error_warnings_list, $error_count) = $parser_registrar->errors();
+ if (defined($errors_references)) {
+ is (scalar(@$errors_references), scalar(@$error_warnings_list),
+ "warning/errors nr $test_explanation");
+ }
+ my $error_idx = 0;
+ foreach my $error_message (@$error_warnings_list) {
+ if (defined($errors_references) and $error_idx <
scalar(@$errors_references)) {
+ is($error_message->{'error_line'}, $errors_references->[$error_idx]."\n",
+ "$test_explanation error message $error_idx");
+ } else {
+ warn "not caught: $error_message->{'error_line'}";
+ }
+ $error_idx++;
+ }
+}
+
+my @tests = (
+["\@node a node\n", 'node line'],
+["aa \@exdent in exdent", 'exdent error no end line',
+ [':0: warning: @exdent should only appear at the beginning of a line']],
+["aa \@exdent in exdent\n", 'exdent error with end line',
+ [':0: warning: @exdent should only appear at the beginning of a line']],
+);
+
+foreach my $test_string_explanation (@tests) {
+ my ($texi_string, $explanation, $error_messages) = @$test_string_explanation;
+ test_line(undef, $texi_string, $explanation, $error_messages);
+}
diff --git a/tp/t/test_parser_registrar.t b/tp/t/test_parser_registrar.t
index 21127fb7c4..e5a239df2a 100644
--- a/tp/t/test_parser_registrar.t
+++ b/tp/t/test_parser_registrar.t
@@ -24,7 +24,6 @@ my $parser = Texinfo::Parser::parser({'registrar' =>
$registrar});
# this also tests errors with line_errors not defined
my $tree = $parser->parse_texi_text("\@end format\n");
-use Data::Dumper;
my $parser_registrar = $parser->registered_errors();
ok ($parser_registrar eq $registrar, 'reused registrar');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Add test for regressions specific of parse_texi_line,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_texi), tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command): check if the element type is root_line when closing a root command, and die if there is no parent only if not in root_line. A root command in parse_texi_line could be considered incorrect, in that case an error message should be output.
- Next by Date:
branch master updated: * tp/Texinfo/ParserNonXS.pm (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_text) (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_string, parse_text), tp/Texinfo/XS/parsetexi/api.c (parse_string, parse_text): add a line number argument to the XS parser parse_string() and parse_text() functions and update accordingly the callers. Set line number to 1 in the default case for parse_texi_line().
- Previous by thread:
branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_texi), tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command): check if the element type is root_line when closing a root command, and die if there is no parent only if not in root_line. A root command in parse_texi_line could be considered incorrect, in that case an error message should be output.
- Next by thread:
branch master updated: * tp/Texinfo/ParserNonXS.pm (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_text) (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_string, parse_text), tp/Texinfo/XS/parsetexi/api.c (parse_string, parse_text): add a line number argument to the XS parser parse_string() and parse_text() functions and update accordingly the callers. Set line number to 1 in the default case for parse_texi_line().
- Index(es):