From: Graham Knop Date: Fri, 21 Jun 2013 04:32:52 +0000 (-0400) Subject: refactor test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=66b17c0bc4229dbcc9b47e2499403dca05ff3619;p=p5sagit%2FFilter-Keyword.git refactor test --- diff --git a/t/simple.t b/t/simple.t index 47b744a..d60cafc 100644 --- a/t/simple.t +++ b/t/simple.t @@ -43,32 +43,66 @@ BEGIN { ))->install; } +my ($line1, $line2); #line 1 -method yay { is(__LINE__, 1, 'line number correct inside keyword' ); "YAY $self" } is(__LINE__, 1, 'line number correct on same line after keyword'); +method yay { $line1 = __LINE__; "YAY $self" } $line2 = __LINE__; is(__LINE__, 2, 'line number correct after first keyword'); +is(__PACKAGE__->yay, 'YAY ' . __PACKAGE__, 'result of keyword correct'); +is($line1, 1, 'line number correct in keyword'); +is($line2, 1, 'line number correct on same line as keyword'); + #line 1 -my $x = __LINE__ . " @{[ __LINE__ ]} method foo @{[ __LINE__ ]} bar baz " . __LINE__; +my $x = __LINE__ . " @{[ __LINE__ ]} method foo @{[ __LINE__ ]} " . __LINE__; is(__LINE__, 2, 'line number correct after string with keyword'); is($x, '1 1 method foo 1 bar baz 1', 'line numbers in constructed string are correct'); -is(__PACKAGE__->yay, 'YAY ' . __PACKAGE__, 'result of keyword correct'); - +undef $line1; +undef $line2; #line 1 method spoon { - is(__LINE__, 2, 'line number correct in multiline keyword'); + $line1 = __LINE__; 'I HAZ A SPOON' } -is(__PACKAGE__->spoon, 'I HAZ A SPOON', 'result of second method correct'); +is(__PACKAGE__->spoon, 'I HAZ A SPOON', 'result of multiline keyword'); +is($line1, 2, 'line number correct in multiline keyword'); #line 1 -shadowed fun { is(__LINE__, 1, 'line number correct inside second keyword'); 'OH WHAT FUN' }; +method spoon2 { + $line2 = __LINE__; + 'I HAZ A SPOON' +} + +is(__PACKAGE__->spoon2, 'I HAZ A SPOON', 'result of second multiline keyword correct'); +is($line2, 2, 'line number correct in second multiline keyword'); + +undef $line1; +undef $line2; +#line 1 +shadowed fun { $line1 = __LINE__; 'OH WHAT FUN' } +is($line1, 1, 'line number correct inside second keyword'); + +shadowed fun { $line2 = __LINE__; 'OH WHAT FUN' } +is($line1, 4, 'line number correct inside second keyword repeat'); + +undef $line1; +undef $line2; +#line 1 +shadowed fun { + $line1 = __LINE__; + 'OH WHAT FUN'; +} +is($line1, 2, 'line number correct inside second keyword multiline'); -shadowed fun { is(__LINE__, 1, 'line number correct inside second keyword'); 'OH WHAT FUN' }; +shadowed fun { + $line2 = __LINE__; + 'OH WHAT FUN'; +}; +is($line2, 8, 'line number correct inside second keyword multiline'); -is($shadowed_called, 2, 'shadowed sub called only by filter output'); +is($shadowed_called, 4, 'shadowed sub called only by filter output'); -is(__LINE__, 5, 'line number after shadowed correct'); +is(__LINE__, 15, 'line number after shadowed correct'); done_testing;