texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp Texinfo/Convert/Paragraph.pm t/parag...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/Paragraph.pm t/parag...
Date: Sun, 06 Nov 2011 21:09:30 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/11/06 21:09:30

Modified files:
        tp/Texinfo/Convert: Paragraph.pm 
        tp/t           : paragraph.t plaintext_tests.t test_count.t 
Added files:
        tp/t/results/plaintext_tests: expanded_tex.pl 
        tp/t/results/test_count: expanded_tex.pl 

Log message:
        Handle correctly end of lines passed in add_next.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Paragraph.pm?cvsroot=texinfo&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/paragraph.t?cvsroot=texinfo&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/plaintext_tests.t?cvsroot=texinfo&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/test_count.t?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/plaintext_tests/expanded_tex.pl?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/test_count/expanded_tex.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Convert/Paragraph.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Paragraph.pm,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- Texinfo/Convert/Paragraph.pm        5 Nov 2011 16:36:49 -0000       1.26
+++ Texinfo/Convert/Paragraph.pm        6 Nov 2011 21:09:29 -0000       1.27
@@ -211,7 +211,17 @@
     
     $paragraph->{'word'} .= $word;
     $paragraph->{'underlying_word'} .= $underlying_word unless($transparent);
+    if ($word =~ /\n/) {
+      $paragraph->{'lines_counter'}++;
+      $paragraph->{'end_line_count'}++;
+      $paragraph->{'counter'} = 0;
+      $paragraph->{'word_counter'} = 0;
+      $result .= $paragraph->{'word'};
+      $paragraph->{'word'} = undef;
+      $paragraph->{'underlying_word'} = undef;
+    } else {
     $paragraph->{'word_counter'} += length($word);
+    }
     if ($paragraph->{'DEBUG'}) {
       print STDERR "WORD+ $word -> $paragraph->{'word'}\n";
       print STDERR "UNDERLYING_WORD+ $underlying_word -> 
$paragraph->{'underlying_word'}\n";

Index: t/paragraph.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/paragraph.t,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- t/paragraph.t       18 Oct 2011 20:13:29 -0000      1.22
+++ t/paragraph.t       6 Nov 2011 21:09:29 -0000       1.23
@@ -1,7 +1,7 @@
 use strict;
 
 use Test::More;
-BEGIN { plan tests => 127 };
+BEGIN { plan tests => 129 };
 use lib 'maintain/lib/Unicode-EastAsianWidth/lib/';
 use Texinfo::Convert::Paragraph;
 use Texinfo::Convert::Line;
@@ -364,6 +364,20 @@
 is ($result, "aa.)    bb  eee    .)_  aa  . gg.  a  c\n", "protected spaces 
many inputs");
 $para->end();
 
+$para = Texinfo::Convert::Paragraph->new({'max' => 10});
+$result = '';
+$result .= $para->add_next("AAAAAAA");
+$result .= $para->add_text("GGG GGG");
+$result .= $para->end();
+is ($result, "AAAAAAAGGG\nGGG\n", 'line split check');
+
+$para = Texinfo::Convert::Paragraph->new({'max' => 10});
+$result = '';
+$result .= $para->add_next("AAAAAAA\n");
+$result .= $para->add_text("GGG GGG");
+$result .= $para->end();
+is ($result, "AAAAAAA\nGGG GGG\n", 'end line reset counter');
+
 $para = Texinfo::Convert::Paragraph->new({'indent_length' => 3});
 $result = '';
 $result .= $para->set_space_protection(1,1);

Index: t/plaintext_tests.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/plaintext_tests.t,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- t/plaintext_tests.t 18 Oct 2011 23:16:15 -0000      1.26
+++ t/plaintext_tests.t 6 Nov 2011 21:09:29 -0000       1.27
@@ -447,6 +447,16 @@
 text
 @end example
 '],
+['expanded_tex',
+'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
address@hidden
+TTT
+GGG
+HHH
address@hidden tex
+bbbbbbbbb1 bbbbbbbbbbb2 bbbbbbbbbb3 bbbbbbbbbbbbbb4.
+', {'expanded_formats' => ['tex']}
+],
 );
 
 my $insert_copying_and_paragraph = 

Index: t/test_count.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/test_count.t,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- t/test_count.t      6 Mar 2011 23:20:36 -0000       1.7
+++ t/test_count.t      6 Nov 2011 21:09:30 -0000       1.8
@@ -57,7 +57,22 @@
 @printindex cp
 
 @anchor{a counting anchor}
-']);
+'],
+['expanded_tex',
+'AAA
address@hidden
+TTT
+GGG
address@hidden tex
+After
+
+second
address@hidden FFF
+GGG @end tex
+After2.
+', {'expanded_formats' => ['tex']}
+],
+);
 
 my %info_tests = ('printindex' => 1);
 foreach my $test (@test_cases) {

Index: t/results/plaintext_tests/expanded_tex.pl
===================================================================
RCS file: t/results/plaintext_tests/expanded_tex.pl
diff -N t/results/plaintext_tests/expanded_tex.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/plaintext_tests/expanded_tex.pl   6 Nov 2011 21:09:30 -0000       
1.1
@@ -0,0 +1,118 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text);
+
+use utf8;
+
+$result_trees{'expanded_tex'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+'
+        },
+        {
+          'cmdname' => 'tex',
+          'contents' => [
+            {
+              'extra' => {
+                'command' => {}
+              },
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'empty_line_after_command'
+            },
+            {
+              'parent' => {},
+              'text' => 'TTT
+',
+              'type' => 'raw'
+            },
+            {
+              'parent' => {},
+              'text' => 'GGG
+',
+              'type' => 'raw'
+            },
+            {
+              'parent' => {},
+              'text' => 'HHH',
+              'type' => 'raw'
+            },
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'last_raw_newline'
+            }
+          ],
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 2,
+            'macro' => ''
+          },
+          'parent' => {}
+        },
+        {
+          'extra' => {
+            'command' => {}
+          },
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        },
+        {
+          'parent' => {},
+          'text' => 'bbbbbbbbb1 bbbbbbbbbbb2 bbbbbbbbbb3 bbbbbbbbbbbbbb4.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[0]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'extra'}{'command'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[3]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[4]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[2]{'extra'}{'command'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[2]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[3]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'parent'} = 
$result_trees{'expanded_tex'};
+
+$result_texis{'expanded_tex'} = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
address@hidden
+TTT
+GGG
+HHH
address@hidden tex
+bbbbbbbbb1 bbbbbbbbbbb2 bbbbbbbbbb3 bbbbbbbbbbbbbb4.
+';
+
+
+$result_texts{'expanded_tex'} = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+bbbbbbbbb1 bbbbbbbbbbb2 bbbbbbbbbb3 bbbbbbbbbbbbbb4.
+';
+
+$result_errors{'expanded_tex'} = [];
+
+
+
+$result_converted{'plaintext'}->{'expanded_tex'} = 
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TTT
+GGG
+HHH
+bbbbbbbbb1 bbbbbbbbbbb2 bbbbbbbbbb3 bbbbbbbbbbbbbb4.
+';
+
+1;

Index: t/results/test_count/expanded_tex.pl
===================================================================
RCS file: t/results/test_count/expanded_tex.pl
diff -N t/results/test_count/expanded_tex.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/test_count/expanded_tex.pl        6 Nov 2011 21:09:30 -0000       
1.1
@@ -0,0 +1,240 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text);
+
+use utf8;
+
+$result_trees{'expanded_tex'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'AAA
+'
+        },
+        {
+          'cmdname' => 'tex',
+          'contents' => [
+            {
+              'extra' => {
+                'command' => {}
+              },
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'empty_line_after_command'
+            },
+            {
+              'parent' => {},
+              'text' => 'TTT
+',
+              'type' => 'raw'
+            },
+            {
+              'parent' => {},
+              'text' => 'GGG',
+              'type' => 'raw'
+            },
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'last_raw_newline'
+            }
+          ],
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 2,
+            'macro' => ''
+          },
+          'parent' => {}
+        },
+        {
+          'extra' => {
+            'command' => {}
+          },
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        },
+        {
+          'parent' => {},
+          'text' => 'After
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'second
+'
+        },
+        {
+          'cmdname' => 'tex',
+          'contents' => [
+            {
+              'extra' => {
+                'command' => {}
+              },
+              'parent' => {},
+              'text' => ' ',
+              'type' => 'empty_line_after_command'
+            },
+            {
+              'parent' => {},
+              'text' => 'FFF
+',
+              'type' => 'raw'
+            },
+            {
+              'parent' => {},
+              'text' => 'GGG ',
+              'type' => 'raw'
+            }
+          ],
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 9,
+            'macro' => ''
+          },
+          'parent' => {}
+        },
+        {
+          'extra' => {
+            'command' => {}
+          },
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        },
+        {
+          'parent' => {},
+          'text' => 'After2.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[0]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'extra'}{'command'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[1]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[2]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'contents'}[3]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[2]{'extra'}{'command'}
 = $result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[2]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'contents'}[3]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[0];
+$result_trees{'expanded_tex'}{'contents'}[0]{'parent'} = 
$result_trees{'expanded_tex'};
+$result_trees{'expanded_tex'}{'contents'}[1]{'parent'} = 
$result_trees{'expanded_tex'};
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[0]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[2];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1]{'contents'}[0]{'extra'}{'command'}
 = $result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1]{'contents'}[0]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1]{'contents'}[1]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1]{'contents'}[2]{'parent'}
 = $result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[2];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[2]{'extra'}{'command'}
 = $result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[1];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[2]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[2];
+$result_trees{'expanded_tex'}{'contents'}[2]{'contents'}[3]{'parent'} = 
$result_trees{'expanded_tex'}{'contents'}[2];
+$result_trees{'expanded_tex'}{'contents'}[2]{'parent'} = 
$result_trees{'expanded_tex'};
+
+$result_texis{'expanded_tex'} = 'AAA
address@hidden
+TTT
+GGG
address@hidden tex
+After
+
+second
address@hidden FFF
+GGG @end tex
+After2.
+';
+
+
+$result_texts{'expanded_tex'} = 'AAA
+After
+
+second
+After2.
+';
+
+$result_errors{'expanded_tex'} = [
+  {
+    'error_line' => ':10: warning: @end tex should only appear at a line 
beginning
+',
+    'file_name' => '',
+    'line_nr' => 10,
+    'macro' => '',
+    'text' => '@end tex should only appear at a line beginning',
+    'type' => 'warning'
+  }
+];
+
+
+
+$result_converted{'debugcount'}->{'expanded_tex'} = ' [1] (0,0) :text_root
+  [2] (0,0) :paragraph
+   [3] (0,0) :text|AAA\\n|
+   [3] (3,0)
+   [4] (3,0) @tex
+    [5] (4,0) :empty_line_after_command:text|\\n|
+    [5] (4,0)
+    [6] (4,0) :raw:text|TTT\\n|
+    [6] (8,1)
+    [7] (8,1) :raw:text|GGG|
+    [7] (8,1)
+    [8] (8,1) :last_raw_newline:text|\\n|
+    [8] (12,2)
+   [4] (12,2)
+   [9] (12,2) :empty_line_after_command:text|\\n|
+   [9] (12,2)
+   [10] (12,2) :text|After\\n|
+   [10] (17,2)
+  [2] (18,3)
+  [11] (18,3) :empty_line:text|\\n|
+  [11] (19,4)
+  [12] (19,4) :paragraph
+   [13] (19,4) :text|second\\n|
+   [13] (28,4)
+   [14] (28,4) @tex
+    [15] (29,4) :empty_line_after_command:text| |
+    [15] (29,4)
+    [16] (29,4) :raw:text|FFF\\n|
+    [16] (33,5)
+    [17] (33,5) :raw:text|GGG |
+    [17] (33,5)
+   [14] (33,5)
+   [18] (33,5) :empty_line_after_command:text|\\n|
+   [18] (33,5)
+   [19] (33,5) :text|After2.\\n|
+   [19] (47,5)
+  [12] (48,6)
+ [1] (48,6)
+AAA TTT
+GGG
+After
+
+   second FFF
+   GGG After2.
+';
+
+1;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]