Re: mocking Proc

2017-02-27 Thread Lloyd Fournier
Ah nice. Wrapping makes more sense than augmenting Proc anyway. LL On Tue, Feb 28, 2017 at 4:22 AM Brian Duggan wrote: > On Monday, February 27, Brian Duggan wrote: > > I tried numerous variants with multis and signatures that match the > > existing signatures, but

Re: mocking Proc

2017-02-27 Thread Brian Duggan
On Monday, February 27, Brian Duggan wrote: > I tried numerous variants with multis and signatures that match the > existing signatures, but didn't have any success. Okay, looks like wrap does what I want: use module; ( sub (|args) { say 'bye' } ); hello; Brian

Re: mocking Proc

2017-02-27 Thread Brian Duggan
On Monday, February 27, Lloyd Fournier wrote: > You will have to use augment in this case I think: > https://docs.perl6.org/syntax/augment > > Augment Proc with your own shell method and should call it. No luck.. use MONKEY-TYPING; augment class Proc { method shell() {

Re: mocking Proc

2017-02-27 Thread Lloyd Fournier
Hmm, You will have to use augment in this case I think: https://docs.perl6.org/syntax/augment Augment Proc with your own shell method and should call it. On Tue, 28 Feb 2017 at 1:59 am, Brian Duggan wrote: > On Monday, February 27, Lloyd Fournier wrote: > > Do you mean

Re: mocking Proc

2017-02-27 Thread Lloyd Fournier
I was thinking just do: 'sub shell(...) is export { }'. And then 'use MyCrazyShell;' in module.pm. Do you mean without modifying module.pm? LL On Tue, Feb 28, 2017 at 1:46 AM Brian Duggan wrote: > On Monday, February 27, Lloyd Fournier wrote: > > I'd do the follwiing: > >

Re: mocking Proc

2017-02-27 Thread Brian Duggan
On Monday, February 27, Lloyd Fournier wrote: > Do you mean without modifying module.pm? Yes, ideally without modifying module.pm. Brian

Re: mocking Proc

2017-02-27 Thread Brian Duggan
On Monday, February 27, Lloyd Fournier wrote: > I'd do the follwiing: > > 1. make a sub named shell to overwrite the existing one that calls .shell > on Proc. Once I make a 'shell', is it possible for the test file to inject my 'shell' into module.pm's namespace? e.g. I was hoping for

Re: mocking Proc

2017-02-27 Thread Lloyd Fournier
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

mocking Proc

2017-02-27 Thread Brian Duggan
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