This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
skip trying to constant fold an incomplete op tree
[perl5.git] / t / op / my_stash.t
1 #!./perl
2
3 package Foo;
4
5 BEGIN {
6     chdir 't' if -d 't';
7     require './test.pl';
8     set_up_inc('../lib');
9 }
10
11 plan 9;
12
13 use constant MyClass => 'Foo::Bar::Biz::Baz';
14
15 {
16     package Foo::Bar::Biz::Baz;
17     1;
18 }
19
20 for (qw(Foo Foo:: MyClass __PACKAGE__)) {
21     eval "sub { my $_ \$obj = shift; }";
22     ok ! $@;
23 #    print $@ if $@;
24 }
25
26 use constant NoClass => 'Nope::Foo::Bar::Biz::Baz';
27
28 for (qw(Nope Nope:: NoClass)) {
29     eval "sub { my $_ \$obj = shift; }";
30     ok $@;
31 #    print $@ if $@;
32 }
33
34 is runperl(prog => 'my main $r; sub FIELDS; $$r{foo}; print qq-ok\n-'),
35   "ok\n",
36   'no crash with hash element when FIELDS sub stub exists';
37 is runperl(prog => 'my main $r; sub FIELDS; @$r{f,b}; print qq-ok\n-'),
38   "ok\n",
39   'no crash with hash slice when FIELDS sub stub exists';