I'd do the follwiing:

1. make a sub named shell to overwrite the existing one that calls .shell
on Proc.
2. make a class that inherits from Proc: class MyProc is Proc { }
3. Look at https://github.com/rakudo/rakudo/blob/nom/src/core/Proc.pm and
decide what methods you need to override to get the behaviour you want.
4. return a MyProc from your custom shell()

LL

On Tue, Feb 28, 2017 at 12:45 AM Brian Duggan <bdugg...@gmail.com> wrote:

> Hi perl6-users,
>
> Suppose I have a file like this:
>
>     # module.pm
>     sub hello is export {
>         shell "echo hello world"
>     }
>
> and another like this:
>
>     # test.t
>     use module;
>     hello;
>
> I want to have 'hello' invoke a 'shell' that I write,
> rather than the real one, so that I can mock the
> behavior of a command.  What would be the best way
> to do this?
>
> thanks
> Brian
>

Reply via email to