File: debugger.t

package info (click to toggle)
libtest-mockobject-perl 1.20200122-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: perl: 1,260; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (8)
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
37
38
39
40
41
#!perl

use strict;
use warnings;

use Test::More tests => 4;

# ask for generated anonymous sub names with this debugger variable
BEGIN { $^P |= 0x200 }

use_ok( 'Test::MockObject' );
my $mock = Test::MockObject->new();

package Some::Parent;

BEGIN
{
	for my $name (qw( isa can ))
	{
		my $sub = sub
		{
			my $caller = ( caller( 1 ) )[ 3 ];
			::is( $caller, "Test::MockObject::$name",
				"generated $name() should have correct name under debugger" );
		};

		no strict 'refs';
		*{ $name } = $sub;
	}
}

package main;

local @Test::MockObject::ISA;
@Test::MockObject::ISA = 'Some::Parent';

my $tmo = Test::MockObject->new();
$tmo->isa( 'foo' );
$tmo->can( 'bar' );

ok( $^P & 0x200, 'T::MO should not permanently reset $^P' );