File: predictable_destroy.pl

package info (click to toggle)
libtest-spec-perl 0.54-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 308 kB
  • sloc: perl: 2,502; makefile: 2
file content (27 lines) | stat: -rwxr-xr-x 626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env perl
#
# predictable_destroy.pl
#
# Objects should be destroyed in a predictable order during the RUN phase
# Expected to print out "DESTROYED IN RUN PHASE"
#
########################################################################
#

package Testcase::Spec::PredictableDestroy;
use Test::Spec;
use Devel::GlobalPhase qw( global_phase );
{
    package Foo;
    sub new { bless {}, $_[0] }
    sub DESTROY { warn("$_[0] DESTROYED IN ". global_phase) }
};

describe "Test::Spec::Mocks" => sub {
  my $x = Foo->new;
  it "destroys objects in the run phase" => sub {
      ok $x;
  };
};

runtests() unless caller;