Re: mocking $*OUT

2017-01-25 Thread Brian Duggan
Thanks, Timo and Moritz. > Because say() is a high-level function that uses the lower-level > $*OUT.print under the hood. Ah, so an alternative would be to just redefine the sub: my $str = ''; sub say($arg) { $str ~= $arg } say 'hi'; use Test; is $str, 'hi', 'works'; Works

Re: mocking $*OUT

2017-01-24 Thread Moritz Lenz
Hi Brian, On 24.01.2017 23:28, Brian Duggan wrote: > Hi All, > > This code: > > my $str = ''; > class Mock { > method say($arg) { $str ~= $arg } > } > $*OUT = Mock.new; > say 'hi'; > > produces: > > Too many positionals passed; expected 1 argument but got 2 > in block at

Re: mocking $*OUT

2017-01-24 Thread Timo Paulssen
You're getting a stack trace that's missing the helpful bits, because they go through the core setting, and our default backtrace printer skips those. You can get the vital information you need by supplying --ll-exception directly after perl6. It'll show you that calling the sub "say" will grab