Skip to content

Commit

Permalink
add failing bareword tests
Browse files Browse the repository at this point in the history
Foo->bar is detected as a bareword and exempted, but
Foo->$bar isn't
  • Loading branch information
chocolateboy committed Apr 20, 2018
1 parent 26af50b commit 66167a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ perl:
- "5.22"
- "5.24"
- "5.26"
- "dev"
13 changes: 12 additions & 1 deletion t/all.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use warnings;
use FindBin qw($Bin);
use lib "$Bin/lib";

use Test::More tests => 292;
use Test::More tests => 302;

$| = 1;

Expand All @@ -76,6 +76,7 @@ my $string = 'Hello, world!';
my $array = [ 0 .. 9 ];
my $hash = { 0 .. 9 };
my $code = \&add;
my $test = 'test';
my $error = qr{Can't (call|locate object) method "test" (without a|via) package\b};
my $string_error = qr{Can't locate object method "test" via package "Hello, world!"};
my $unblessed_error = qr{Can't call method "test" on unblessed reference};
Expand All @@ -87,6 +88,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'no args: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'no args: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'no args: $object->test() - object not autoboxed');
Expand Down Expand Up @@ -122,6 +124,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'override package: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'override package: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'override package: $object->test() - object not autoboxed');
Expand All @@ -147,6 +150,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'override namespace: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'override namespace: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'override namespace: $object->test() - object not autoboxed');
Expand All @@ -172,6 +176,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'default package: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'default package: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'default package: $object->test() - object not autoboxed');
Expand Down Expand Up @@ -207,6 +212,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'default namespace: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'default namespace: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'default namespace: $object->test() - object not autoboxed');
Expand Down Expand Up @@ -268,6 +274,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'test all 1: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'test all 1: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'test all 1: $object->test() - object not autoboxed');
Expand Down Expand Up @@ -303,6 +310,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'test all 2: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'test all 2: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'test all 2: $object->test() - object not autoboxed');
Expand Down Expand Up @@ -338,6 +346,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'test all 3: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'test all 3: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'test all 3: $object->test() - object not autoboxed');
Expand Down Expand Up @@ -372,6 +381,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'test all 4: Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'test all 4: Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'test all 4: $object->test() - object not autoboxed');
Expand Down Expand Up @@ -455,6 +465,7 @@ my $undef_error = qr{Can't call method "[^"]+" on an undefined value};

my $object = Test->new();
is(ref $object, 'Test', 'nested (outer): Test->new() - bareword not autoboxed');
is(Test->$test, 'rubicund', 'nested (outer): Test->$test() - bareword not autoboxed');

my $result = $object->test();
is($result, 'rubicund', 'nested (outer): $object->test() - object not autoboxed');
Expand Down

0 comments on commit 66167a5

Please sign in to comment.