Skip to content

Commit

Permalink
Improve some tests. Add test for qw<>
Browse files Browse the repository at this point in the history
  • Loading branch information
ikegami committed Sep 19, 2011
1 parent 268d60b commit e7a9fa8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
25 changes: 17 additions & 8 deletions t/01_basic.t
Expand Up @@ -3,7 +3,7 @@
use strict;
use warnings;

use Test::More tests => 21;
use Test::More tests => 24;

use feature::qw_comments;

Expand Down Expand Up @@ -43,6 +43,9 @@ is(join('|', @a), "a[s]|b|c", "Nesting []");
@a = qw{ a{s} b c };
is(join('|', @a), "a{s}|b|c", "Nesting {}");

@a = qw< a<s> b c >;
is(join('|', @a), "a<s>|b|c", "Nesting <>");

@a = qw!
a # Foo!
b
Expand All @@ -60,13 +63,19 @@ is(join('|', @a), "a|b|c", "Nesting delimiter in comments");
@a = qw( a ) x 3;
is(join('|', @a), "a|a|a", "qw() still counts as parens for 'x'");

@a = qw( a\b ); is(join('|', @a), "a\\b", "qw( a\\b )");
@a = qw( a\\b ); is(join('|', @a), "a\\b", "qw( a\\\\b )");
@a = qw( a\(b ); is(join('|', @a), "a(b", "qw( a\\(b )");
@a = qw( a\)b ); is(join('|', @a), "a)b", "qw( a\\)b )");
@a = qw! a\!b !; is(join('|', @a), "a!b", "qw! a\\!b !");
@a = qw( a\#b ); is(join('|', @a), "a#b", "qw( a\\#b )");
@a = qw( a\ b ); is(join('|', @a), "a\\|b", "qw( a\\ b )");
@a = qw( a\\b ); is(join('|', @a), "a\\b", "Escape of \"\\\"");
@a = qw! a\!b !; is(join('|', @a), "a!b", "Escape of delimiter");
@a = qw( a\(b ); is(join('|', @a), "a(b", "Escape of start delimiter");
@a = qw( a\)b ); is(join('|', @a), "a)b", "Escape of end delimiter");
@a = qw( a\#b ); is(join('|', @a), "a#b", "Escape of \"#\"");
@a = qw( a\b ); is(join('|', @a), "a\\b", "Non-escape of non-meta");
@a = qw( a\ b ); is(join('|', @a), "a\\|b", "Non-escape of space");
@a = qw(a b c);
is(join('|', @a), "a|b|c", "Lack of whitespace");
@a = qw();
is(join('|', @a), "", "Lack of whitespace with empty qw");
@a = qw ( a b c );
is(join('|', @a), "a|b|c", "Space before start delimiter");
Expand Down
20 changes: 10 additions & 10 deletions t/04_errors.t
Expand Up @@ -98,14 +98,14 @@ my @ea;

{
no feature::qw_comments;
eval '@a = qw( a, b ); 1' or die $@;
eval '@a = qw( a, b ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
@ewarnings = @warnings;
@ea = @a;
@warnings = ();
} {
use feature::qw_comments;
eval '@a = qw( a, b ); 1' or die $@;
eval '@a = qw( a, b ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
ok(0+@warnings, "One comma warning test verification");
is_deeply(\@warnings, \@ewarnings, "One comma warnings");
Expand All @@ -115,14 +115,14 @@ my @ea;

{
no feature::qw_comments;
eval '@a = qw( a, b, ); 1' or die $@;
eval '@a = qw( a, b, ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
@ewarnings = @warnings;
@ea = @a;
@warnings = ();
} {
use feature::qw_comments;
eval '@a = qw( a, b, ); 1' or die $@;
eval '@a = qw( a, b, ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
ok(0+@warnings, "Two commas warning test verification");
is_deeply(\@warnings, \@ewarnings, "Two commas warnings");
Expand All @@ -132,27 +132,27 @@ my @ea;

{
no feature::qw_comments;
eval 'qw( ); 1' or die $@;
eval 'qw( ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
@ewarnings = @warnings;
@warnings = ();
} {
use feature::qw_comments;
eval 'qw( ); 1' or die $@;
eval 'qw( ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
is_deeply(\@warnings, \@ewarnings, "Zero elements in void context");
@warnings = ();
}

{
no feature::qw_comments;
eval 'qw( a ); 1' or die $@;
eval 'qw( a ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
@ewarnings = @warnings;
@warnings = ();
} {
use feature::qw_comments;
eval 'qw( a ); 1' or die $@;
eval 'qw( a ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
ok(0+@warnings, "One element in void context test verification");
is_deeply(\@warnings, \@ewarnings, "One element in void context");
Expand All @@ -161,13 +161,13 @@ my @ea;

{
no feature::qw_comments;
eval 'qw( a b ); 1' or die $@;
eval 'qw( a b ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
@ewarnings = @warnings;
@warnings = ();
} {
use feature::qw_comments;
eval 'qw( a b ); 1' or die $@;
eval 'qw( a b ); 1' or do { my $e = $@; chomp($e); die $e; };
s/ at (?:(?!\bat\b).)+ line \S+\.\n\z//s for @warnings;
ok(0+@warnings, "Two elements in void context test verification");
is_deeply(\@warnings, \@ewarnings, "Two elements in void context");
Expand Down

0 comments on commit e7a9fa8

Please sign in to comment.