Re: Can a user "cheat" and call a class's private method?

2015-05-14 Thread R. Ransbottom
On Tue, May 12, 2015 at 11:03:01PM +0200, Moritz Lenz wrote: > I'm curious, what's a case where private state of a class needs to be > tested, and tests agains the public interface are not enough? > In my experience, testing against private parts only makes the tests > more brittle (that is, ever

Re: Can a user "cheat" and call a class's private method?

2015-05-12 Thread Moritz Lenz
Hi, On 05/12/2015 09:40 PM, R. Ransbottom wrote: > On Mon, May 11, 2015 at 03:22:46PM -0700, Darren Duncan wrote: > >> you can use "trusts". Also having to do this may indicate bad code >> design. -- Darren Duncan > > I saw Moritz' and Carl's responses and I agree with the smell > issue. > >

Re: Can a user "cheat" and call a class's private method?

2015-05-12 Thread Darren Duncan
On 2015-05-12 12:40 PM, R. Ransbottom wrote: On Mon, May 11, 2015 at 03:22:46PM -0700, Darren Duncan wrote: you can use "trusts". Also having to do this may indicate bad code design. -- Darren Duncan I saw Moritz' and Carl's responses and I agree with the smell issue. Given that the code ex

Re: Can a user "cheat" and call a class's private method?

2015-05-12 Thread R. Ransbottom
On Mon, May 11, 2015 at 03:22:46PM -0700, Darren Duncan wrote: > you can use "trusts". Also having to do this may indicate bad code > design. -- Darren Duncan I saw Moritz' and Carl's responses and I agree with the smell issue. Given that the code exists and needs testing, 'augment' seems pre

Re: Can a user "cheat" and call a class's private method?

2015-05-11 Thread Darren Duncan
See Moritz Lenz' response to this thread on March 26. To summarize, you can use "trusts". Also having to do this may indicate bad code design. -- Darren Duncan On 2015-05-11 2:13 PM, R. Ransbottom wrote: I need to test some private routines, so is there a way to do that? Is there a downsi

Re: Can a user "cheat" and call a class's private method?

2015-05-11 Thread R. Ransbottom
> I need to test some private routines, so is there a way to do that? Is there a downsize to augment for this? # source class Dog { method bark { say( "#bark"); return "bark" } method !pee { say( "#pee" ); return "pee"} } # test #use MONKEY_TYPING; use Test; use v6; plan 4; my Dog

Re: Can a user "cheat" and call a class's private method?

2015-03-27 Thread yary
On Fri, Mar 27, 2015 at 8:35 AM, Tom Browder wrote: > Use a separate module (but included with the code for the whole > package) for the non-class-specific, formerly-private methods to be > "public", because some of the private > methods are really general math subroutines. That way I can te

Re: Can a user "cheat" and call a class's private method?

2015-03-27 Thread Tom Browder
On Fri, Mar 27, 2015 at 6:36 AM, Carl Mäsak wrote: > This feels like the same conversation we had earlier this week about > accessing private methods. :) But maybe there are still a few new > points that can be made. ... Okay, Carl, I think I understand. But what about this for my particular sit

Re: Can a user "cheat" and call a class's private method?

2015-03-27 Thread Carl Mäsak
This feels like the same conversation we had earlier this week about accessing private methods. :) But maybe there are still a few new points that can be made. Tom (>>), Moritz (>): >> I need to test some private routines, so is there a way to do that? > > The easiest way to do that is when the cl

Re: Can a user "cheat" and call a class's private method?

2015-03-26 Thread Tom Browder
On Mar 26, 2015 11:04 AM, "Moritz Lenz" wrote: > On 26.03.2015 16:55, Tom Browder wrote: > > I need to test some private routines, so is there a way to do that ... > And then you can also do something like: > > my $private_method = $obj.^private_method_table{$methodname}; > $obj.$private_metnod(ar

Re: Can a user "cheat" and call a class's private method?

2015-03-26 Thread Moritz Lenz
Hi, On 26.03.2015 16:55, Tom Browder wrote: > I need to test some private routines, so is there a way to do that? The easiest way to do that is when the class with the private methods trusts the class that calls them. See for example http://doc.perl6.org/type/Metamodel::Trusting http://design.per

Can a user "cheat" and call a class's private method?

2015-03-26 Thread Tom Browder
I need to test some private routines, so is there a way to do that? Or will I have to copy code to a test script or? BTW, the tests are for input/output checks during development--not for the public user. Thanks. Best, -Tom