summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-03-09 10:59:55 +0000
committerPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-03-19 00:01:21 +0000
commitb4d822d9e307900f7723b6280d07edc04776c9e8 (patch)
tree74c79551df134e99bed4753d15ee6f0507c67201
parent6e2744e09b30f776a1184d2ae6a769be072088a5 (diff)
downloadperl-b4d822d9e307900f7723b6280d07edc04776c9e8.tar.gz
Unit-test that try{} blocks are invisible to caller()
-rw-r--r--t/op/try.t16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/op/try.t b/t/op/try.t
index 5539a3b83e..32095662f1 100644
--- a/t/op/try.t
+++ b/t/op/try.t
@@ -249,4 +249,20 @@ no warnings 'experimental::try';
ok(eq_array(\@list, [4, 5, 6]), 'do { try/catch } in list context');
}
+# try{} blocks should be invisible to caller()
+{
+ my $caller;
+ sub A { $caller = sprintf "%s (%s line %d)", (caller 1)[3,1,2]; }
+
+ sub B {
+ try { A(); }
+ catch ($e) {}
+ }
+
+ my $LINE = __LINE__+1;
+ B();
+
+ is($caller, "main::B ($0 line $LINE)", 'try {} block is invisible to caller()');
+}
+
done_testing;