[Bps-public-commit] r10447 - Text-Quoted/t
ruz at bestpractical.com
ruz at bestpractical.com
Wed Jan 23 09:40:06 EST 2008
Author: ruz
Date: Wed Jan 23 09:40:06 2008
New Revision: 10447
Added:
Text-Quoted/t/
Text-Quoted/t/2.t
Text-Quoted/t/3.t
Text-Quoted/t/4.t
Text-Quoted/t/5.t
Text-Quoted/t/6.t
Text-Quoted/t/7.t
Log:
* add tests back and add a new test that segfaults
Added: Text-Quoted/t/2.t
==============================================================================
--- (empty file)
+++ Text-Quoted/t/2.t Wed Jan 23 09:40:06 2008
@@ -0,0 +1,154 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl 1.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 1;
+use Text::Quoted;
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+$a = <<'EOF';
+>>>>> "dc" == darren chamberlain writes:
+
+>> If I don't do "use Template;" in my startup script, each child will
+>> get the pleasure of loading and compiling it all when the first script
+>> that uses Template gets executed.
+
+dc> Unless one of the other modules that you use in your startup script
+dc> happens to use Template, in which case you'll be OK.
+
+Well, that's still "use Template;" as far as I'm concerned.
+
+I was really just being pedantic... but think of a hosting situation
+where the startup is pretty bare, and some Registry program uses the
+template.
+
+I personally don't think the preload should be called automagically,
+even if it does the right thing most of the time.
+
+_______________________________________________
+templates mailing list
+templates at template-toolkit.org
+http://www.template-toolkit.org/mailman/listinfo/templates
+EOF
+
+$expected = [
+ [
+ [
+ {
+ 'quoter' => '>>>>>',
+ 'text' => '"dc" == darren chamberlain writes:',
+ 'raw' => '>>>>> "dc" == darren chamberlain writes:',
+ 'empty' => ''
+ }
+ ]
+ ],
+ {
+ 'quoter' => '',
+ 'text' => '',
+ 'raw' => '',
+ 'empty' => '1'
+ },
+ [
+ {
+ 'quoter' => '>>',
+ 'text' => 'If I don\'t do "use Template;" in my startup script, each child will
+get the pleasure of loading and compiling it all when the first script
+that uses Template gets executed.',
+ 'raw' => '>> If I don\'t do "use Template;" in my startup script, each child will
+>> get the pleasure of loading and compiling it all when the first script
+>> that uses Template gets executed.',
+ 'empty' => ''
+ }
+ ],
+ {
+ 'quoter' => '',
+ 'text' => '',
+ 'raw' => '',
+ 'empty' => '1'
+ },
+ [
+ {
+ 'quoter' => 'dc>',
+ 'text' => 'Unless one of the other modules that you use in your startup script
+happens to use Template, in which case you\'ll be OK.',
+ 'raw' => 'dc> Unless one of the other modules that you use in your startup script
+dc> happens to use Template, in which case you\'ll be OK.',
+ 'empty' => ''
+ }
+ ],
+ {
+ 'quoter' => '',
+ 'text' => '',
+ 'raw' => '',
+ 'empty' => '1'
+ },
+ {
+ 'quoter' => '',
+ 'text' => 'Well, that\'s still "use Template;" as far as I\'m concerned.',
+ 'raw' => 'Well, that\'s still "use Template;" as far as I\'m concerned.',
+ 'empty' => ''
+ },
+ {
+ 'quoter' => '',
+ 'text' => '',
+ 'raw' => '',
+ 'empty' => '1'
+ },
+ {
+ 'quoter' => '',
+ 'text' => 'I was really just being pedantic... but think of a hosting situation
+where the startup is pretty bare, and some Registry program uses the
+template.',
+ 'raw' => 'I was really just being pedantic... but think of a hosting situation
+where the startup is pretty bare, and some Registry program uses the
+template.',
+ 'empty' => ''
+ },
+ {
+ 'quoter' => '',
+ 'text' => '',
+ 'raw' => '',
+ 'empty' => '1'
+ },
+ {
+ 'quoter' => '',
+ 'text' => 'I personally don\'t think the preload should be called automagically,
+even if it does the right thing most of the time.',
+ 'raw' => 'I personally don\'t think the preload should be called automagically,
+even if it does the right thing most of the time.',
+ 'empty' => ''
+ },
+ {
+ 'quoter' => '',
+ 'text' => '',
+ 'raw' => '',
+ 'empty' => '1'
+ },
+ {
+ 'quoter' => '',
+ 'text' => '_______________________________________________',
+ 'raw' => '_______________________________________________',
+ 'empty' => ''
+ },
+ {
+ 'quoter' => '',
+ 'text' => 'templates mailing list
+templates at template-toolkit.org
+http://www.template-toolkit.org/mailman/listinfo/templates',
+ 'raw' => 'templates mailing list
+templates at template-toolkit.org
+http://www.template-toolkit.org/mailman/listinfo/templates',
+ 'empty' => ''
+ }
+ ];
+
+
+is_deeply(extract($a), $expected,
+ "Supercite doesn't screw me up as badly as before");
Added: Text-Quoted/t/3.t
==============================================================================
--- (empty file)
+++ Text-Quoted/t/3.t Wed Jan 23 09:40:06 2008
@@ -0,0 +1,98 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl 1.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 1;
+use Text::Quoted;
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+$a = <<'EOF';
+From: "Brian Christopher Robinson" <brian.c.robinson at trw.com>
+zxc
+> > An
+> > alternative solution is to not have those phone calls at work,
+> > faciliitated by worked very hard for a reasonably workday, then
+> > leaving... thus having time to deal with personal issues when not at
+> > work.
+iabc
+> Unfortunately, personal issues can't be conveniently shoved aside
+eight
+> hours a day. People with kids especially have to deal with issues
+> realted to picking them up and dropping them off at various times, as
+x
+EOF
+
+$expected = [
+ {
+ 'quoter' => '',
+ 'text' => 'From: "Brian Christopher Robinson" <brian.c.robinson at trw.com>
+zxc',
+ 'raw' => 'From: "Brian Christopher Robinson" <brian.c.robinson at trw.com>
+zxc',
+ 'empty' => ''
+ },
+ [
+ [
+ {
+ 'quoter' => '> >',
+ 'text' => 'An
+alternative solution is to not have those phone calls at work,
+faciliitated by worked very hard for a reasonably workday, then
+leaving... thus having time to deal with personal issues when not at
+work.',
+ 'raw' => '> > An
+> > alternative solution is to not have those phone calls at work,
+> > faciliitated by worked very hard for a reasonably workday, then
+> > leaving... thus having time to deal with personal issues when not at
+> > work.',
+ 'empty' => ''
+ }
+ ]
+ ],
+ {
+ 'quoter' => '',
+ 'text' => 'iabc',
+ 'raw' => 'iabc',
+ 'empty' => ''
+ },
+ [
+ {
+ 'quoter' => '>',
+ 'text' => 'Unfortunately, personal issues can\'t be conveniently shoved aside',
+ 'raw' => '> Unfortunately, personal issues can\'t be conveniently shoved aside',
+ 'empty' => ''
+ }
+ ],
+ {
+ 'quoter' => '',
+ 'text' => 'eight',
+ 'raw' => 'eight',
+ 'empty' => ''
+ },
+ [
+ {
+ 'quoter' => '>',
+ 'text' => 'hours a day. People with kids especially have to deal with issues
+realted to picking them up and dropping them off at various times, as',
+ 'raw' => '> hours a day. People with kids especially have to deal with issues
+> realted to picking them up and dropping them off at various times, as',
+ 'empty' => ''
+ }
+ ],
+ {
+ 'quoter' => '',
+ 'text' => 'x',
+ 'raw' => 'x',
+ 'empty' => ''
+ }
+ ];
+
+is_deeply(extract($a), $expected,
+ "Supercite doesn't screw me up as badly as before");
Added: Text-Quoted/t/4.t
==============================================================================
--- (empty file)
+++ Text-Quoted/t/4.t Wed Jan 23 09:40:06 2008
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 1;
+use Text::Quoted;
+
+# I don't really care what the results are, so long as we don't
+# segfault.
+
+my $ntk = <<'NTK';
+ _ _ _____ _ __ <*the* weekly high-tech sarcastic update for the uk>
+| \ | |_ _| |/ / _ __ __2002-07-26_ o join! mail an empty message to
+| \| | | | | ' / | '_ \ / _ \ \ /\ / / o ntknow-subscribe at lists.ntk.net
+| |\ | | | | . \ | | | | (_) \ v v / o website (+ archive) lives at:
+|_| \_| |_| |_|\_\|_| |_|\___/ \_/\_/ o http://www.ntk.net/
+NTK
+
+ok(extract($ntk), "It's not pretty, but at least it works");
Added: Text-Quoted/t/5.t
==============================================================================
--- (empty file)
+++ Text-Quoted/t/5.t Wed Jan 23 09:40:06 2008
@@ -0,0 +1,31 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl 1.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 3;
+BEGIN { use_ok('Text::Quoted') };
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+$a = '';
+use Data::Dumper;
+
+$empty_deeply = [
+ {
+ 'text' => undef,
+ 'empty' => undef,
+ 'quoter' => undef,
+ 'raw' => undef
+ }
+ ];
+
+is_deeply(extract($a),$empty_deeply);
+$b = undef;
+is_deeply(extract($b),$empty_deeply);
+
Added: Text-Quoted/t/6.t
==============================================================================
--- (empty file)
+++ Text-Quoted/t/6.t Wed Jan 23 09:40:06 2008
@@ -0,0 +1,101 @@
+use strict;
+use warnings;
+use Text::Quoted;
+use Test::More tests => 5;
+
+#########################
+# handle nested comments with common >
+my $a = <<EOF;
+> a
+>> b
+> c
+EOF
+
+my $a_data =
+ [
+ [
+ { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' },
+ [ { 'text' => 'b', 'empty' => '', 'quoter' => '>>', 'raw' => '>> b' } ],
+ { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' }
+ ]
+ ];
+
+is_deeply(extract($a),$a_data,"correctly parse >> delimiter");
+
+#############
+# when the quoter changes in the middle of things, don't get confused
+
+$a = <<EOF;
+> a
+=> b
+> c
+EOF
+
+$a_data =
+ [
+ [ { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' } ],
+ [ { 'text' => 'b', 'empty' => '', 'quoter' => '=>', 'raw' => '=> b' } ],
+ [ { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' } ]
+ ];
+
+is_deeply(extract($a),$a_data,"correctly parse => delimiter");
+
+#############
+# when the quoter changes in the middle of things, don't get confused
+# blank lines shouldn't affect it
+
+$a = <<EOF;
+> a
+
+=> b
+
+> c
+EOF
+
+$a_data =
+ [
+ [ { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' } ],
+ { 'text' => '', 'empty' => 1, 'quoter' => '', 'raw' => '' },
+ [ { 'text' => 'b', 'empty' => '', 'quoter' => '=>', 'raw' => '=> b' } ],
+ { 'text' => '', 'empty' => 1, 'quoter' => '', 'raw' => '' },
+ [ { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' } ]
+ ];
+
+is_deeply(extract($a),$a_data,"correctly parse => delimiter with blank lines");
+
+#############
+# one of the real world quoter breakage examples was cpan>
+# also, no text is required for the quoter to break things
+
+$a = <<EOF;
+>
+cpan>
+>
+EOF
+
+$a_data =
+ [
+ [ { 'text' => '', 'empty' => 1, 'quoter' => '>', 'raw' => '>' } ],
+ [ { 'text' => '', 'empty' => 1, 'quoter' => 'cpan>', 'raw' => 'cpan>' } ],
+ [ { 'text' => '', 'empty' => 1, 'quoter' => '>', 'raw' => '>' } ]
+ ];
+
+is_deeply(extract($a),$a_data,"correctly parse cpan> delimiter with no text");
+
+############
+# just checking that when the cpan> quoter gets a space, we handle it properly
+
+$a = <<EOF;
+> a
+cpan > b
+> c
+EOF
+
+$a_data =
+ [
+ [ { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' } ],
+ { 'text' => 'cpan > b', 'empty' => '', 'quoter' => '', 'raw' => 'cpan > b' },
+ [ { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' } ],
+ ];
+
+is_deeply(extract($a),$a_data,"correctly handles a non-delimiter");
Added: Text-Quoted/t/7.t
==============================================================================
--- (empty file)
+++ Text-Quoted/t/7.t Wed Jan 23 09:40:06 2008
@@ -0,0 +1,13 @@
+use strict;
+use Test::More tests => 2;
+BEGIN { use_ok('Text::Quoted') };
+
+eval { require Encode } or skip_all("No Encode module");
+$a = Encode::decode_utf8("x\303\203 \tz");
+
+is_deeply( extract($a), [ {
+ text => Encode::decode_utf8("x\303\203 z"),
+ empty => '',
+ quoter => '',
+ raw => Encode::decode_utf8("x\303\203 z"),
+} ], "No segfault");
More information about the Bps-public-commit
mailing list