xref: /openbsd/gnu/usr.bin/perl/t/op/context.t (revision 9f11ffb7)
1#!./perl
2
3BEGIN {
4    chdir 't' if -d 't';
5    require "./test.pl";
6    set_up_inc( qw(. ../lib) );
7}
8
9require "./test.pl";
10plan( tests => 8 );
11
12sub foo {
13    $a='abcd';
14    $a=~/(.)/g;
15    cmp_ok($1,'eq','a','context ' . curr_test());
16}
17
18$a=foo;
19@a=foo;
20foo;
21foo(foo);
22
23my $before = curr_test();
24$h{foo} = foo;
25my $after = curr_test();
26
27cmp_ok($after-$before,'==',1,'foo called once')
28	or diag("nr tests: before=$before, after=$after");
29
30sub context {
31    $cx = qw[void scalar list][wantarray + defined wantarray];
32}
33$_ = sub { context(); BEGIN { } }->();
34is($cx, 'scalar', 'context of { foo(); BEGIN {} }');
35