Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.9k stars 540 forks source link

refactor t/op/append.t to use test.pl #12386

Closed p5pRT closed 11 years ago

p5pRT commented 12 years ago

Migrated from rt.perl.org#114796 (status was 'resolved')

Searchable as RT114796$

p5pRT commented 12 years ago

From @perlDreamer

Another hand TAP to test.pl conversion

p5pRT commented 12 years ago

From @perlDreamer

0004-Refactor-t-op-append.t-to-use-test.pl-instead-of-mak.patch ```diff From 96288f11e75672e60cd78ac510834da475c7cb0c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 8 Sep 2012 15:32:23 -0700 Subject: [PATCH 4/4] Refactor t/op/append.t to use test.pl instead of making TAP by hand. --- t/op/append.t | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/t/op/append.t b/t/op/append.t index 21af62c..99dc545 100644 --- a/t/op/append.t +++ b/t/op/append.t @@ -1,22 +1,23 @@ #!./perl -print "1..13\n"; +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; +} $a = 'ab' . 'c'; # compile time $b = 'def'; $c = $a . $b; -print "#1\t:$c: eq :abcdef:\n"; -if ($c eq 'abcdef') {print "ok 1\n";} else {print "not ok 1\n";} +is( $c, 'abcdef', 'compile time concatenation' ); $c .= 'xyz'; -print "#2\t:$c: eq :abcdefxyz:\n"; -if ($c eq 'abcdefxyz') {print "ok 2\n";} else {print "not ok 2\n";} +is( $c, 'abcdefxyz', 'concat to self'); $_ = $a; $_ .= $b; -print "#3\t:$_: eq :abcdef:\n"; -if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} +is( $_, 'abcdef', 'concat using $_'); # test that when right argument of concat is UTF8, and is the same # variable as the target, and the left argument is not UTF8, it no @@ -40,7 +41,7 @@ if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} my $t1 = $a; $t1 .= $ab; - print $t1 =~ /b/ ? "ok 6\n" : "not ok 6\t# $t1\n"; + like( $t1, qr/b/, 'null bytes get copied'); my $t2 = $a; $t2 .= $uab; @@ -48,7 +49,7 @@ if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} my $t3 = $ua; $t3 .= $ab; - print $t3 =~ /$ub/ ? "ok 8\n" : "not ok 8\t# $t3\n"; + like( $t3, qr/$ub/ ); my $t4 = $ua; $t4 .= $uab; @@ -56,7 +57,7 @@ if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} my $t5 = $a; $t5 = $ab . $t5; - print $t5 =~ /$ub/ ? "ok 10\n" : "not ok 10\t# $t5\n"; + like( $t5, qr/$ub/ ); my $t6 = $a; $t6 = $uab . $t6; @@ -64,9 +65,11 @@ if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} my $t7 = $ua; $t7 = $ab . $t7; - print $t7 =~ /$ub/ ? "ok 12\n" : "not ok 12\t# $t7\n"; + like( $t7, qr/$ub/ ); my $t8 = $ua; $t8 = $uab . $t8; print eval '$t8 =~ /$ub/' ? "ok 13\n" : "not ok 13\t# $t8\n"; } + +done_testing; -- 1.7.5.4 ```
p5pRT commented 12 years ago

From @jkeenan

On Sat Sep 08 15​:34​:37 2012\, colink@​perldreamer.com wrote​:

Another hand TAP to test.pl conversion

This is the output I got after applying the patch​:

######## $ ./perl t/op/append.t ok 1 - compile time concatenation ok 2 - concat to self ok 3 - concat using $_ ok 4 ok 5 ok 4 - null bytes get copied ok 7 ok 5 ok 9 ok 6 ok 11 ok 7 ok 13 1..7 #########

It appears we still have some manually constructed test output. Can you fix?

Also\, I like the fact that you have added labels for 3 of the tests. Could you do so for the remaining 10?

Thank you very much. Jim Keenan

P.S.​: You don't have to prepend the subject with 'TODO task​: '. AFAICT\, that doesn't set the "Todo" type\, which someone has to set manually.

p5pRT commented 12 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 12 years ago

From @perlDreamer

All patched up.

Also\, in subsequent patches I'll try to add as many labels/names as possible.

p5pRT commented 12 years ago

From @perlDreamer

0008-Refactor-t-uni-case.pl-to-use-test.pl-instead-of-mak.patch ```diff From d4ca4994fdec670fc510ac9905d6ee3bf3a4d8fa Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 18 Jul 2012 18:35:19 -0700 Subject: [PATCH 08/11] Refactor t/uni/case.pl to use test.pl instead of making TAP by hand. --- t/uni/case.pl | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-) diff --git a/t/uni/case.pl b/t/uni/case.pl index aa6467c..08df670 100644 --- a/t/uni/case.pl +++ b/t/uni/case.pl @@ -88,9 +88,7 @@ sub casetest { foreach my $func (@funcs) { my $d = $func->($c); my $e = unidump($d); - print $d eq pack("U0U", $simple{$i}) ? - "ok $test # $i -> $w\n" : "not ok $test # $i -> $e ($w)\n"; - $test++; + is( $d, pack("U0U", $simple{$i}), "$i -> $e ($w)" ); } } @@ -101,9 +99,7 @@ sub casetest { foreach my $func (@funcs) { my $d = $func->($c); my $e = unidump($d); - print $w eq $e ? - "ok $test # $i -> $w\n" : "not ok $test # $h -> $e ($w)\n"; - $test++; + is( $w, $e, "$h -> $e ($w)" ); } } @@ -113,13 +109,11 @@ sub casetest { foreach my $func (@funcs) { my $d = $func->($c); my $e = unidump($d); - print $d eq $c ? - "ok $test # $i -> $w\n" : "not ok $test # $i -> $e ($w)\n"; - $test++; + is( $d, $c, "$i -> $e ($w)" ); } } - print "1..$tests\n"; + done_testing(); } 1; -- 1.7.5.4 ```
p5pRT commented 12 years ago

From @jkeenan

On Sun Sep 09 14​:42​:03 2012\, colink@​perldreamer.com wrote​:

All patched up.

Also\, in subsequent patches I'll try to add as many labels/names as possible.

Colin\, your most recent patch pertains to t/uni/case.pl -- and has already been applied :-) (be250cb1944\, July 18 2012)

Do you have a second patch for t/op/append.t?

Thank you very much. Jim Keenan

p5pRT commented 12 years ago

From @perlDreamer

There has to be an easier way to manage all these patches. What I've done is to clone a git branch off of blead\, make a series of commits\, and then use format-patch to get patches that I can send. When the patches clear\, then I delete and recreate the branch. Suggestions or clue-bats welcome.

p5pRT commented 12 years ago

From @perlDreamer

0001-Refactor-to-use-test.pl-instead-of-making-TAP-by-han.patch ```diff From 97aae026b76cfbce11dd4ae46193dd27e8e3e17c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 9 Sep 2012 13:26:49 -0700 Subject: [PATCH 1/4] Refactor to use test.pl instead of making TAP by hand. Add test names. --- t/op/append.t | 60 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 30 insertions(+), 30 deletions(-) diff --git a/t/op/append.t b/t/op/append.t index 21af62c..42ee071 100644 --- a/t/op/append.t +++ b/t/op/append.t @@ -1,22 +1,26 @@ #!./perl -print "1..13\n"; +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; +} + +##Literal test count since evals below can fail +plan tests => 13; $a = 'ab' . 'c'; # compile time $b = 'def'; $c = $a . $b; -print "#1\t:$c: eq :abcdef:\n"; -if ($c eq 'abcdef') {print "ok 1\n";} else {print "not ok 1\n";} +is( $c, 'abcdef', 'compile time concatenation' ); $c .= 'xyz'; -print "#2\t:$c: eq :abcdefxyz:\n"; -if ($c eq 'abcdefxyz') {print "ok 2\n";} else {print "not ok 2\n";} +is( $c, 'abcdefxyz', 'concat to self'); $_ = $a; $_ .= $b; -print "#3\t:$_: eq :abcdef:\n"; -if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} +is( $_, 'abcdef', 'concat using $_'); # test that when right argument of concat is UTF8, and is the same # variable as the target, and the left argument is not UTF8, it no @@ -28,7 +32,8 @@ if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} $string = "abcdefghijkl$string"; } - r2() and print "ok $_\n" for qw/ 4 5 /; + isnt(r2(), '', 'UTF8 concat does not free the wrong string'); + isnt(r2(), '', 'second check'); } # test that nul bytes get copied @@ -38,35 +43,30 @@ if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";} my $ub = pack("U0a*", 'b'); + #aa\0b my $t1 = $a; $t1 .= $ab; + like( $t1, qr/b/, 'null bytes do not stop string copy, aa\0b'); - print $t1 =~ /b/ ? "ok 6\n" : "not ok 6\t# $t1\n"; - + #a\0a\0b my $t2 = $a; $t2 .= $uab; - - print eval '$t2 =~ /$ub/' ? "ok 7\n" : "not ok 7\t# $t2\n"; - + eval { like( $t2, qr/$ub/, '... a\0a\0b' ); }; + + #\0aa\0b my $t3 = $ua; $t3 .= $ab; - - print $t3 =~ /$ub/ ? "ok 8\n" : "not ok 8\t# $t3\n"; - + like( $t3, qr/$ub/, '... \0aa\0b' ); + my $t4 = $ua; $t4 .= $uab; - - print eval '$t4 =~ /$ub/' ? "ok 9\n" : "not ok 9\t# $t4\n"; - + eval { like( $t4, qr/$ub/, '... \0a\0a\0b' ); }; + my $t5 = $a; $t5 = $ab . $t5; - - print $t5 =~ /$ub/ ? "ok 10\n" : "not ok 10\t# $t5\n"; - + like( $t5, qr/$ub/, '... a\0ba' ); + my $t6 = $a; $t6 = $uab . $t6; - - print eval '$t6 =~ /$ub/' ? "ok 11\n" : "not ok 11\t# $t6\n"; - + eval { like( $t6, qr/$ub/, '... \0a\0ba' ); }; + my $t7 = $ua; $t7 = $ab . $t7; - - print $t7 =~ /$ub/ ? "ok 12\n" : "not ok 12\t# $t7\n"; - + like( $t7, qr/$ub/, '... a\0b\0a' ); + my $t8 = $ua; $t8 = $uab . $t8; - - print eval '$t8 =~ /$ub/' ? "ok 13\n" : "not ok 13\t# $t8\n"; + eval { like( $t8, qr/$ub/, '... \0a\0b\0a' ); }; } -- 1.7.5.4 ```
p5pRT commented 12 years ago

From @doy

On Tue\, Sep 11\, 2012 at 06​:41​:26PM -0700\, Colin Kuskie via RT wrote​:

There has to be an easier way to manage all these patches. What I've done is to clone a git branch off of blead\, make a series of commits\, and then use format-patch to get patches that I can send. When the patches clear\, then I delete and recreate the branch. Suggestions or clue-bats welcome.

You can just keep the commits directly on blead\, and use 'git pull --rebase' when updating. It will be smart enough to notice when commits are applied\, and not duplicate them. If you want to keep things on a separate branch\, just use 'git rebase blead' whenever you want to update it\, it will have the same effect.

-doy

p5pRT commented 12 years ago

From @tsee

On 09/12/2012 03​:41 AM\, Colin Kuskie via RT wrote​:

There has to be an easier way to manage all these patches. What I've done is to clone a git branch off of blead\, make a series of commits\, and then use format-patch to get patches that I can send. When the patches clear\, then I delete and recreate the branch. Suggestions or clue-bats welcome.

Thanks\, applied as 18b94ad2978e118214353bdd240628c63557c0c8 unless I have to rebase/retest again after tests finish.

--Steffen

p5pRT commented 12 years ago

From @b2gills

On Wed\, Sep 12\, 2012 at 12​:54 AM\, Steffen Mueller \smueller@​cpan\.org wrote​:

On 09/12/2012 03​:41 AM\, Colin Kuskie via RT wrote​:

There has to be an easier way to manage all these patches. What I've done is to clone a git branch off of blead\, make a series of commits\, and then use format-patch to get patches that I can send. When the patches clear\, then I delete and recreate the branch. Suggestions or clue-bats welcome.

Thanks\, applied as 18b94ad2978e118214353bdd240628c63557c0c8 unless I have to rebase/retest again after tests finish.

--Steffen

What's up with the eval{} lines?

- print eval '$t4 =~ /$ub/' ? "ok 9\n" : "not ok 9\t# $t4\n"; + eval { like( $t4\, qr/$ub/\, '... \0a\0a\0b' ); };

p5pRT commented 12 years ago

From @perlDreamer

Good question. From the digging I did in git\, they were part of the original set of tests that were added to this file. I'm assuming that those tests died in the regex engine\, and he didn't want the test to die either.

p5pRT commented 11 years ago

From @jkeenan

On Tue Sep 11 22​:56​:02 2012\, smueller@​cpan.org wrote​:

On 09/12/2012 03​:41 AM\, Colin Kuskie via RT wrote​:

There has to be an easier way to manage all these patches. What I've done is to clone a git branch off of blead\, make a series of commits\, and then use format-patch to get patches that I can send. When the patches clear\, then I delete and recreate the branch. Suggestions or clue-bats welcome.

Thanks\, applied as 18b94ad2978e118214353bdd240628c63557c0c8 unless I have to rebase/retest again after tests finish.

--Steffen

Steffen\,

If you feel this ticket is closable\, please feel free to do so.

Thank you very much. Jim Keenan

p5pRT commented 11 years ago

From @tsee

I restored some logic related to those evals (need to be string evals) based on some archaeology. This change applied as a5d38fd9a576445bb00ac5ac3b195e659b56c470daff0d3c7d.

The relevant commit goes back a bit and refers to EBCDIC compatibility​:

  commit 933bc096593f55b9633fb193815ddd81d5b5ec1b   Author​: Jarkko Hietaniemi \jhi@​iki\.fi   Date​: Tue Nov 27 01​:22​:22 2001 +0000  
  \141 is malformed "unexpected continuation byte" in UTF-EBCDIC.   Delay the match until runtime.

p5pRT commented 11 years ago

From [Unknown Contact. See original ticket]

I restored some logic related to those evals (need to be string evals) based on some archaeology. This change applied as a5d38fd9a576445bb00ac5ac3b195e659b56c470daff0d3c7d.

The relevant commit goes back a bit and refers to EBCDIC compatibility​:

  commit 933bc096593f55b9633fb193815ddd81d5b5ec1b   Author​: Jarkko Hietaniemi \jhi@​iki\.fi   Date​: Tue Nov 27 01​:22​:22 2001 +0000  
  \141 is malformed "unexpected continuation byte" in UTF-EBCDIC.   Delay the match until runtime.

p5pRT commented 11 years ago

@tsee - Status changed from 'open' to 'resolved'

p5pRT commented 11 years ago

From @jkeenan

On Thu Oct 04 23​:29​:32 2012\, smueller@​cpan.org wrote​:

I restored some logic related to those evals (need to be string evals) based on some archaeology. This change applied as a5d38fd9a576445bb00ac5ac3b195e659b56c470daff0d3c7d.

I went looking for that commit with 'git show' and couldn't find it.

However\, I found it here​: 76445bb00ac5ac3b195e659b56c470daff0d3c7d

Am I misunderstanding something about commit numbers?

Thank you very much. Jim Keenan

p5pRT commented 11 years ago

From @ap

* James E Keenan via RT \perlbug\-followup@​perl\.org [2012-10-05 16​:50]​:

Am I misunderstanding something about commit numbers?

No. That object simply doesn’t exist in perl5.git.

p5pRT commented 11 years ago

From @tsee

On 10/05/2012 02​:00 PM\, James E Keenan via RT wrote​:

On Thu Oct 04 23​:29​:32 2012\, smueller@​cpan.org wrote​:

I restored some logic related to those evals (need to be string evals) based on some archaeology. This change applied as a5d38fd9a576445bb00ac5ac3b195e659b56c470daff0d3c7d.

I went looking for that commit with 'git show' and couldn't find it.

However\, I found it here​: 76445bb00ac5ac3b195e659b56c470daff0d3c7d

Am I misunderstanding something about commit numbers?

No\, you simply overestimated me. When I do open source stuff\, I'm usually on a bad connection on a train. So I prepare the RT replies and all for when I have a usable link. In the mornings\, shortly after 7am in Europe\, it's really rather rare for others to be committing. Usually\, I still check whether I had to rebase-before-push before hitting "Update ticket". Sometimes\, that doesn't work so well before my first coffee. :(

In other words​: Sorry about that!

--Steffen