Skip to content

Mocked subs invoked as plain functions are not being unloaded #19

@slightlytwisted

Description

@slightlytwisted

I'm running into an issue that is probably best illustrated with code, below. I'm not sure if I'm just using the class wrong, or if this is a bug in the Mock::Quick package:

#!/usr/bin/env perl

use Mock::Quick;

test1();
test2();

sub test1 {
  my $control = qimplement 'Foo' => (
      bar => sub { say STDOUT 'I am in test1' },
    );

  Foo::bar();

  $control->undefine();
  $control = undef;
}

sub test2 {
  my $control = qimplement 'Foo' => (
      bar => sub { say STDOUT 'I am in test2' },
    );

  Foo::bar();

  $control->undefine();
  $control = undef;
}

Expected output:

test1
test2

Actual output:

test1
test1

Mock::Quick version: 1.111
Perl Version: 5.22.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions