t/lib/indirect/Test0/Oooooo/Pppppppp.pm
t/lib/indirect/Test1/il1.pm
t/lib/indirect/Test1/il2.pm
+t/lib/indirect/Test2.pm
+t/lib/indirect/Test3.pm
+t/lib/indirect/Test4.pm
+t/lib/indirect/Test5.pm
t/lib/indirect/TestRequired1.pm
t/lib/indirect/TestRequired2.pm
t/lib/indirect/TestRequired3X.pm
# ifndef PL_oldbufptr
# define PL_oldbufptr PL_parser->oldbufptr
# endif
+# ifndef PL_lex_inwhat
+# define PL_lex_inwhat PL_parser->lex_inwhat
+# endif
#else
# ifndef PL_linestr
# define PL_linestr PL_Ilinestr
# ifndef PL_oldbufptr
# define PL_oldbufptr PL_Ioldbufptr
# endif
+# ifndef PL_lex_inwhat
+# define PL_lex_inwhat PL_Ilex_inwhat
+# endif
#endif
#ifndef I_WORKAROUND_REQUIRE_PROPAGATION
t = line;
u = t;
- while (t <= p) {
- STRLEN i = indirect_nextline(t, line_len);
- if (i >= line_len)
- break;
- u = t;
- t += i;
- line_len -= i;
+
+ /* If we're inside a string-like environment, we don't need to be smart for
+ * finding the positions of the tokens : as the line number will always be
+ * the line where the string began (or at least I hope so), and the line
+ * buffer points to the beginning of the string (likewise), we can just take
+ * the offset in this string as the position. */
+ if (!PL_lex_inwhat) {
+ while (t <= p) {
+ STRLEN i = indirect_nextline(t, line_len);
+ if (i >= line_len)
+ break;
+ u = t;
+ t += i;
+ line_len -= i;
+ }
}
+
*name_pos = p - u;
return 1;
my $tests;
BEGIN { $tests = 18 }
-use Test::More tests => (1 + $tests + 1) + 2 + 3 + 3 + 3 + 5 + 4 + 5;
+use Test::More tests => (1 + $tests + 1) + 2 + 3 + 3 + 3 + 5 + 4 + 5 + 4;
BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
my %wrong = map { $_ => 1 } 2, 3, 5, 7, 9, 10, 14, 15, 17, 18;
sub expect {
- my ($pkg, $file) = @_;
- $file = $file ? quotemeta $file : '\(eval \d+\)';
- qr/^warn:Indirect call of method "new" on object "$pkg" at $file line \d+/;
+ my ($obj, $file, $prefix) = @_;
+ $obj = quotemeta $obj;
+ $file = $file ? quotemeta $file : '\(eval \d+\)';
+ $prefix = defined $prefix ? quotemeta $prefix : 'warn:';
+ qr/^${prefix}Indirect call of method "new" on object "$obj" at $file line \d+/;
}
{
is_deeply \@w, [ ], 'indirect syntax in eval in sub';
}
+{
+ local $@;
+ eval { require indirect::Test2 };
+ is $@, '', 'direct call in string is not fooled by newlines';
+}
+
+{
+ local $@;
+ eval { require indirect::Test3 };
+ like $@, expect('$x', 't/lib/indirect/Test3.pm', ''),
+ 'indirect call in string is not fooled by newlines';
+}
+
+{
+ local $@;
+ eval { require indirect::Test4 };
+ is $@, '', 'direct call in string is not fooled by more newlines';
+}
+
+{
+ local $@;
+ eval { require indirect::Test5 };
+ is $@, '', 'direct call in sort in string is not fooled by newlines';
+}
+
__DATA__
my $a = new P1;