| 1 | # | ||
| 2 | # Copyright (c) 2015 Christian Jaeger, copying@christianjaeger.ch | ||
| 3 | # | ||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||
| 7 | # bundled with this file. | ||
| 8 | # | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | FP::Weak::t - tests for FP::Weak | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | # just let it sit there and be tested by `t/require_and_run_tests` | ||
| 17 | |||
| 18 | =head1 DESCRIPTION | ||
| 19 | |||
| 20 | |||
| 21 | =head1 NOTE | ||
| 22 | |||
| 23 | This is alpha software! Read the status section in the package README | ||
| 24 | or on the L<website|http://functional-perl.org/>. | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | package FP::Weak::t; | ||
| 29 | |||
| 30 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 31 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | 1 | ▶ | use warnings FATAL => 'uninitialized'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | |||
| 34 | 1 | ▶ | use FP::Weak ":all"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 35 | 1 | ▶ | use Chj::TEST; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 36 | |||
| 37 | 5 | ▶ | sub t { |
|
Subroutine
t: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 38 | 5 | my $foo = []; | |
| 39 | 5 | weaken $foo; | |
| 40 | 5 | $foo | |
| 41 | } | ||
| 42 | |||
| 43 | 1 | ▶ | TEST { my $foo = []; noweaken $foo; $foo } |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 44 | 1 | []; | |
| 45 | 1 | ▶ | TEST {t} |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 46 | 1 | undef; | |
| 47 | 1 | ▶ | TEST { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 48 | 1 | ▶ | with_noweaken {t} |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 49 | 1 | } | |
| 50 | 1 | []; | |
| 51 | 1 | ▶ | TEST { &with_noweaken(\&t) } |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 52 | 1 | []; | |
| 53 | 1 | ▶ | TEST {t} |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 54 | 1 | undef; | |
| 55 | 1 | ▶ | TEST { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 56 | 1 | my @w; | |
| 57 | 1 | ▶ | local $SIG{__WARN__} = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 58 | 1 | my ($msg) = @_; | |
| 59 | 1 | $msg =~ s/0x[0-9a-f]*/0x.../s; | |
| 60 | 1 | $msg =~ s/ at .*/ .../s; | |
| 61 | 1 | push @w, $msg | |
| 62 | 1 | }; | |
| 63 | 1 | [&with_warnweaken(\&t), @w] | |
| 64 | } | ||
| 65 | 1 | [undef, "weaken (ARRAY(0x...)) ..."]; | |
| 66 | |||
| 67 | 1 | 1 | |