From 26af50b810cdd146cfad4ba3a4fd848aabaf0523 Mon Sep 17 00:00:00 2001 From: chocolateboy Date: Fri, 20 Apr 2018 14:58:36 +0100 Subject: [PATCH] add failing test for debugger bug in perl >= 5.22: https://github.com/scrottie/autobox-Core/issues/34 --- .gitignore | 1 + .travis.yml | 1 + MANIFEST | 2 ++ Makefile.PL | 46 ++++++++++++++++++++++++++-------------------- t/debugger.pl | 30 ++++++++++++++++++++++++++++++ t/debugger.t | 15 +++++++++++++++ 6 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 t/debugger.pl create mode 100644 t/debugger.t diff --git a/.gitignore b/.gitignore index 686e81f..f1d2985 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ MYMETA.yml *.o *.bs autobox.c +dev/ diff --git a/.travis.yml b/.travis.yml index 59bdc19..acc80f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: perl perl: - "5.8" - "5.10" + - "5.20" - "5.22" - "5.24" - "5.26" diff --git a/MANIFEST b/MANIFEST index 5d29326..706b8ae 100644 --- a/MANIFEST +++ b/MANIFEST @@ -13,6 +13,8 @@ README t/all.t t/autoref.t t/coderef.t +t/debugger.pl +t/debugger.t t/default.t t/export.t t/hints.t diff --git a/Makefile.PL b/Makefile.PL index 496ddee..02e2806 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -18,27 +18,33 @@ if ($Config{gccversion}) { $OPTIMIZE = $Config{optimize}; } +my $META_MERGE = { + resources => { + repository => 'https://github.com/chocolateboy/autobox', + bugtracker => 'https://github.com/chocolateboy/autobox/issues', + }, +}; + +my $TEST_REQUIRES = { + 'IPC::System::Simple' => '1.25', +}; + WriteMakefile( - NAME => 'autobox', - VERSION_FROM => 'lib/autobox.pm', + NAME => 'autobox', + VERSION_FROM => 'lib/autobox.pm', + # compatibility in case module was previously installed to lib - INSTALLDIRS => ($] >= 5.011 ? 'site' : 'perl'), - PREREQ_PM => { - 'Scope::Guard' => '0.21', + INSTALLDIRS => ($] >= 5.011 ? 'site' : 'perl'), + + PREREQ_PM => { + 'Scope::Guard' => '0.21', }, - ABSTRACT_FROM => 'lib/autobox.pod', - AUTHOR => 'chocolateboy ', - INC => '-I.', - OPTIMIZE => $OPTIMIZE, - ($EUMM_VERSION >= 6.48 ? (MIN_PERL_VERSION => '5.8.0') : ()), - ($EUMM_VERSION >= 6.31 ? (LICENSE => 'perl') : ()), - ($EUMM_VERSION >= 6.46 ? - (META_MERGE => { - resources => { - repository => 'https://github.com/chocolateboy/autobox', - bugtracker => 'https://github.com/chocolateboy/autobox/issues', - }, - }) - : () - ), + ABSTRACT_FROM => 'lib/autobox.pod', + AUTHOR => 'chocolateboy ', + INC => '-I.', + OPTIMIZE => $OPTIMIZE, + ($EUMM_VERSION >= 6.5503 ? (BUILD_REQUIRES => $TEST_REQUIRES) : ()), + ($EUMM_VERSION >= 6.31 ? (LICENSE => 'artistic_2') : ()), + ($EUMM_VERSION >= 6.46 ? (META_MERGE => $META_MERGE) : ()), + ($EUMM_VERSION >= 6.48 ? (MIN_PERL_VERSION => '5.8.0') : ()), ); diff --git a/t/debugger.pl b/t/debugger.pl new file mode 100644 index 0000000..0e371ea --- /dev/null +++ b/t/debugger.pl @@ -0,0 +1,30 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use blib; + +use autobox { DEFAULT => __PACKAGE__ }; + +# helper for t/debugger.t +# +# this prints "foo -> bar -> baz -> quux" +# on perl < 5.22 and fails with the following error on newer perls: +# +# Can't locate object method "baz" via package "foo -> bar" +# +# https://github.com/scrottie/autobox-Core/issues/34 + +sub bar { + return "$_[0] -> bar"; +} + +sub baz { + return "$_[0] -> baz"; +} + +sub quux { + print "$_[0] -> quux", $/; +} + +'foo'->bar->baz->quux; diff --git a/t/debugger.t b/t/debugger.t new file mode 100644 index 0000000..3544193 --- /dev/null +++ b/t/debugger.t @@ -0,0 +1,15 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use FindBin qw($Bin); +use IPC::System::Simple qw(capturex); +use Test::More tests => 1; + +# https://github.com/scrottie/autobox-Core/issues/34 + +$ENV{PERLDB_OPTS} = 'NonStop=1'; + +chomp(my $got = capturex($^X, '-d', "$Bin/debugger.pl")); +is $got, 'foo -> bar -> baz -> quux', 'runs under perl -d';