This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate above \xFF in bitwise string ops
[perl5.git] / t / op / context.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     require "./test.pl";
6     set_up_inc( qw(. ../lib) );
7 }
8
9 require "./test.pl";
10 plan( tests => 8 );
11
12 sub foo {
13     $a='abcd';
14     $a=~/(.)/g;
15     cmp_ok($1,'eq','a','context ' . curr_test());
16 }
17
18 $a=foo;
19 @a=foo;
20 foo;
21 foo(foo);
22
23 my $before = curr_test();
24 $h{foo} = foo;
25 my $after = curr_test();
26
27 cmp_ok($after-$before,'==',1,'foo called once')
28         or diag("nr tests: before=$before, after=$after");
29
30 sub context {
31     $cx = qw[void scalar list][wantarray + defined wantarray];
32 }
33 $_ = sub { context(); BEGIN { } }->();
34 is($cx, 'scalar', 'context of { foo(); BEGIN {} }');