[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp/t nodenormalization.t
From: |
Patrice Dumas |
Subject: |
texinfo/tp/t nodenormalization.t |
Date: |
Thu, 19 Jan 2012 00:58:09 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 12/01/19 00:58:09
Modified files:
tp/t : nodenormalization.t
Log message:
Test directly node normalization and transliteration.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/nodenormalization.t?cvsroot=texinfo&r1=1.2&r2=1.3
Patches:
Index: nodenormalization.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/nodenormalization.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- nodenormalization.t 12 Oct 2011 23:52:21 -0000 1.2
+++ nodenormalization.t 19 Jan 2012 00:58:09 -0000 1.3
@@ -1,9 +1,9 @@
use Test::More;
-BEGIN { plan tests => 3 };
+BEGIN { plan tests => 8 };
use lib 'maintain/lib/Unicode-EastAsianWidth/lib/';
use lib 'maintain/lib/libintl-perl/lib/';
use lib 'maintain/lib/Text-Unidecode/lib/';
-use Texinfo::Convert::NodeNameNormalization qw(normalize_node);
+use Texinfo::Convert::NodeNameNormalization qw(normalize_node
transliterate_texinfo);
use Texinfo::Parser;
use Data::Dumper;
@@ -143,3 +143,31 @@
#print STDERR "Manual: $normalized_manual\n";
ok($normalized_manual =~ /^[\w\-]+$/, 'normalized tree is a valid id');
+
+# Now test some node normalizations
+
+my $texi_line = 'A @sc{sc} accents @"i @"address@hidden @address@hidden @l{}
@,address@hidden'C} @={@,address@hidden @address@hidden'{r}}
@address@hidden@dotless{i}}} @"y @dotless{i} @dotless{j} @,{C} @ogonek{E}
@udotaccent{a} @tieaccent{a} @dotaccent{a} characters @l{} @exclamdown{} @aa{}
@oe{} @comma{} @error{} @today{} @dots{} @enddots{} no brace commands @@ @: @.
@ @* @} signs -- --- `` \'\' !_"#$%&\'()*+-. /;<=>?[\\]^_`|~';
+
+my $line_tree = $parser->parse_texi_text($texi_line);
+my $normalized_line = normalize_node($line_tree);
+is ($normalized_line,
+'A-SC-accents-_00ef-_00ef-_1e14-_0142-_1e08-_0146_0303_0304-_0155_030c-_0129_0304-_00ff-_0131-j-_00c7-_0118-_1ea1-a_0361-_0227-characters-_0142-_00a1-_00e5-_0153-_002c-error_002d_002d_003e--_2026-_002e_002e_002e-no-brace-commands-_0040--_002e-----_007d-signs-_002d_002d-_002d_002d_002d-_0060_0060-_0027_0027-_0021_005f_0022_0023_0024_0025_0026_0027_0028_0029_002a_002b_002d_002e-_002f_003b_003c_003d_003e_003f_005b_005c_005d_005e_005f_0060_007c_007e',
+ 'normalized complex line');
+my $transliterated_line = transliterate_texinfo($line_tree);
+is ($transliterated_line,
+'A-SC-accents-i-i-E-l-C-n-r-i-y-i-j-C-E-a-a-a-characters-l-_00a1-aa-oe-_002c-error_002d_002d_003e--_2026-_002e_002e_002e-no-brace-commands-_0040--_002e-----_007d-signs-_002d_002d-_002d_002d_002d-_0060_0060-_0027_0027-_0021_005f_0022_0023_0024_0025_0026_0027_0028_0029_002a_002b_002d_002e-_002f_003b_003c_003d_003e_003f_005b_005c_005d_005e_005f_0060_007c_007e',
+ 'transliterated complex line');
+my $transliterated_line_no_unidecode = transliterate_texinfo($line_tree, 1);
+is ($transliterated_line_no_unidecode,
+'A-SC-accents-i-i-_1e14-l-_1e08-n-r-i-y-_0131-j-C-E-a-a-a-characters-l-_00a1-aa-oe-_002c-error_002d_002d_003e--_2026-_002e_002e_002e-no-brace-commands-_0040--_002e-----_007d-signs-_002d_002d-_002d_002d_002d-_0060_0060-_0027_0027-_0021_005f_0022_0023_0024_0025_0026_0027_0028_0029_002a_002b_002d_002e-_002f_003b_003c_003d_003e_003f_005b_005c_005d_005e_005f_0060_007c_007e',
+ 'transliterated complex line no unidecode');
+
+my $top_text = ' tOp';
+my $top_tree = $parser->parse_texi_text($top_text);
+my $top_normalized = normalize_node($top_tree);
+is ($top_normalized, 'Top', 'normalize Top node');
+
+my $top_and_spaces_text = 'TOP ';
+my $top_and_spaces_tree = $parser->parse_texi_text($top_and_spaces_text);
+my $top_and_spaces_normalized = normalize_node($top_and_spaces_tree);
+is ($top_and_spaces_normalized, 'TOP-', 'normalize Top node followed by
spaces');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp/t nodenormalization.t,
Patrice Dumas <=