t/test18-goto2.p

filter: Statementstmt 100% 7 / 7 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 10 / 10 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
longmess
1.0
longmess_jmp
1.0
CRAP 1.0
« t/test14.p ↑ Summary t/test18-goto2.pm »
1 # Test Carp::Heavy's "swap subs out from under you with goto &sub"
2  
3 16 ▶use lib 't';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Test18;
6  
7 16 ▶sub longmess { goto &longmess_jmp }
Subroutine longmess: called CC=1 SCAR=0.0
8  
9 16 ▶sub longmess_jmp {
Subroutine longmess_jmp: called CC=1 SCAR=0.0
10 # the required file deletes this longmess_jmp sub, while it's executing,
11 # and replaces it with longmess_real, which we then goto into!
12 16 require 'test18-goto2.pm'; # has to be require, not eval '...'
13 16 goto &longmess_real;
14 }
15  
16 16 longmess("Oops");
« t/test14.p ↑ Summary t/test18-goto2.pm »