diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-04-01 18:39:43 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-04-01 18:39:43 +0000 |
commit | a89be09a10c36299e755a956d356eb7f1f643437 (patch) | |
tree | fad7397078cfab938793727614ea388a35f3d402 /t/comp | |
parent | b78f6729f182484e2ef54fb7af30d24d99373338 (diff) | |
download | perl-a89be09a10c36299e755a956d356eb7f1f643437.tar.gz |
Fix bug #21742. require should be always invoked in
scalar context. This wasn't the case when called from
an eval(""), because the void context doesn't propagate
through the leaveeval op. Instead of making scalarvoid()
handle OP_LEAVEEVAL -- this breaks AutoLoader -- implement
a workaround in doeval().
p4raw-id: //depot/perl@19126
Diffstat (limited to 't/comp')
-rwxr-xr-x | t/comp/require.t | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/t/comp/require.t b/t/comp/require.t index 44b46cd72c..78ac436337 100755 --- a/t/comp/require.t +++ b/t/comp/require.t @@ -11,8 +11,8 @@ $i = 1; my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0; my $Is_UTF8 = (${^OPEN} || "") =~ /:utf8/; -my $total_tests = 23; -if ($Is_EBCDIC || $Is_UTF8) { $total_tests = 20; } +my $total_tests = 29; +if ($Is_EBCDIC || $Is_UTF8) { $total_tests = 26; } print "1..$total_tests\n"; sub do_require { @@ -130,6 +130,22 @@ dofile(); sub dofile { do "bleah.do"; }; print $x; +# Test that scalar context is forced for require + +write_file('bleah.pm', <<'**BLEAH**' +print "not " if !defined wantarray || wantarray ne ''; +print "ok $i - require() context\n"; +1; +**BLEAH** +); + delete $INC{"bleah.pm"}; ++$::i; +$foo = eval q{require bleah}; delete $INC{"bleah.pm"}; ++$::i; +@foo = eval q{require bleah}; delete $INC{"bleah.pm"}; ++$::i; + eval q{require bleah}; delete $INC{"bleah.pm"}; ++$::i; +$foo = eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i; +@foo = eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i; + eval {require bleah}; + # UTF-encoded things - skipped on EBCDIC machines and on UTF-8 input if ($Is_EBCDIC || $Is_UTF8) { exit; } |