File: 01_singleton.t

package info (click to toggle)
libapache-singleton-perl 0.07-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze
  • size: 84 kB
  • ctags: 15
  • sloc: perl: 80; makefile: 42
file content (36 lines) | stat: -rw-r--r-- 645 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
28
29
30
31
32
33
34
35
36
use strict;
use Test::More tests => 2;

package Apache;
sub request {
    bless {}, 'Mock::Apache';
}

package Mock::Apache;
my %pnotes;
sub pnotes {
    my($self, $key, $val) = @_;
    $pnotes{$key} = $val if $val;
    return $pnotes{$key};
}

package Printer;
use base qw(Apache::Singleton);

package main;
{
    local $ENV{MOD_PERL} = 1;
    $INC{'Apache.pm'} = 1;		# dummy

    my $printer_a = Printer->instance;
    my $printer_b = Printer->instance;

    is "$printer_a", "$printer_b", 'same printer';
}

{
    my $printer_a = Printer->instance;
    my $printer_b = Printer->instance;

    is "$printer_a", "$printer_b", 'same printer';
}