14 use vars qw{ @warnings };
17 $SIG{'__WARN__'} = sub { push @warnings, @_ };
21 my $fail_odd = 'Odd number of elements in hash assignment at ';
22 my $fail_odd_anon = 'Odd number of elements in anonymous hash at ';
23 my $fail_ref = 'Reference found where even-sized list expected at ';
24 my $fail_not_hr = 'Not a HASH reference at ';
29 cmp_ok(scalar(@warnings),'==',1,'odd count');
30 cmp_ok(substr($warnings[0],0,length($fail_odd)),'eq',$fail_odd,'odd msg');
34 cmp_ok(scalar(@warnings),'==',1,'scalar count');
35 cmp_ok(substr($warnings[0],0,length($fail_odd)),'eq',$fail_odd,'scalar msg');
39 cmp_ok(scalar(@warnings),'==',2,'odd hashref count');
40 cmp_ok(substr($warnings[0],0,length($fail_odd_anon)),'eq',$fail_odd_anon,'odd hashref msg 1');
41 cmp_ok(substr($warnings[1],0,length($fail_ref)),'eq',$fail_ref,'odd hashref msg 2');
45 cmp_ok(scalar(@warnings),'==',1,'arrayref count');
46 cmp_ok(substr($warnings[0],0,length($fail_ref)),'eq',$fail_ref,'arrayref msg');
49 %hash = sub { print "fenice" };
50 cmp_ok(scalar(@warnings),'==',1,'coderef count');
51 cmp_ok(substr($warnings[0],0,length($fail_odd)),'eq',$fail_odd,'coderef msg');
55 cmp_ok(scalar(@warnings),'==',0,'hashref assign');
57 # Old pseudo-hash syntax, now removed.
60 my $avhv = [{x=>1,y=>2}];
64 cmp_ok(scalar(@warnings),'==',0,'pseudo-hash 1 count');
65 cmp_ok(substr($@,0,length($fail_not_hr)),'eq',$fail_not_hr,'pseudo-hash 1 msg');
71 cmp_ok(scalar(@warnings),'==',0,'pseudo-hash 2 count');
72 cmp_ok(substr($@,0,length($fail_not_hr)),'eq',$fail_not_hr,'pseudo-hash 2 msg');