11 use utf8; # Tell EBCDIC translator to make this UTF-8,
20 like($@, qr/^Horribly/, 'die with no args propagates $@');
21 like($@, qr/\.{3}propagated at/, '... and appends a phrase');
24 local $SIG{__DIE__} = sub { is( $_[0], "[\000]\n", 'Embedded null passed to signal handler' )};
30 is( $@, $err, 'Embedded null passed back into $@' );
34 local $SIG{__DIE__} = sub {
35 isa_ok( $_[0], 'ARRAY', 'pass an array ref as an argument' );
41 is( $x->[0], 4, 'actual array, not a copy, passed to signal handler' );
50 is($@->[0], 7, 'die with no arguments propagates $@, but leaves references alone');
54 die bless [ 7 ], "Error";
56 isa_ok( $@, 'Error', '$@ is an Error object' );
60 isa_ok( $@, 'Out', 'returning a different object than what was passed in, via PROPAGATE' );
61 is($@->[0], 9, 'reference returned correctly');
68 bless [$_[0]->[0]], "Out";
77 my $msg = "ce ºtii tu, bã ?\n";
79 is( $@, $msg, "Literal passed to die" );
81 local $SIG{__WARN__} = $SIG{__DIE__} = sub { $err = shift };
83 is( $err, $msg, 'die handler with utf8' );
85 is( $err, $msg, 'warn handler with utf8' );
86 eval qq/ use strict; \$\x{3b1} /;
87 like( $@, qr/Global symbol "\$\x{3b1}"/, 'utf8 symbol names show up in $@' );
90 # [perl #36470] got uninit warning if $@ was undef
93 use warnings "uninitialized";
96 local $SIG{__WARN__} = sub { $ok = 0 };
97 eval { undef $@; die };
98 is( $ok, 1, 'no warnings if $@ is undef' );
100 eval { $@ = 100; die };
101 like($@."", qr/100\t\.{3}propagated at/,
102 'check non-PVs in $@ are propagated');
106 local $SIG{__DIE__}= sub { push @error, @_ };
108 my $ok= eval '$intentionally_missing+1';
110 is($ok,undef,"eval should return undef");
111 is(0+@error,1,"we should have captured 1 error via __DIE__");
113 qr/Global symbol \"\$intentionally_missing\"/,
114 "The __DIE__ handler should have seen this message");
116 qr/Global symbol \"\$intentionally_missing\"/,
117 "The eval error in '\$@' should contain this message");
118 is( $error[0], $eval_error,
119 "__DIE__ handler and \$@ should be the same");
123 local $TODO = 'RT #4821: die qr{x} does not check termination';
124 my $out = runperl(prog => 'die qr{x}', stderr => 1);
125 like($out, qr/at -e line 1./, 'RT #4821: output from die qr{x}');