Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Tom Browder
On Mon, Mar 23, 2015 at 5:25 PM, Henk van Oers wrote: >>> From 2005, but still a fantastic primer on testing in Perl. > Sorry Tom. > I think you must read a book about OO. I will go back and review OO, Henk. Thanks. Best, -Tom

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Henk van Oers
[...] From 2005, but still a fantastic primer on testing in Perl. Sorry Tom. I think you must read a book about OO. Unsubscribing from this list now, Regards, Henk

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Carl Mäsak
(resending to p6u) Tom (>>), Henk (>): > > That doesn't seem to work with private methods. Any trick to accomplish > > that? > > What part of 'private' did you mis? Henk, that's an unnecessarily harsh way to say "Private methods are private and not visible or testable outside of the class." In

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Tom Browder
On Mon, Mar 23, 2015 at 9:35 AM, Bruce Gray wrote: >> Any recommendations for books on the subject? > http://shop.oreilly.com/product/9780596100926.do > Perl Testing: A Developer's Notebook > by Ian Langworth and Chromatic > > From 2005, but still a fantastic primer on testing in P

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Tom Browder
On Mon, Mar 23, 2015 at 11:28 AM, B. Estrade wrote: > As good as this book is, it's still Perl 5 specific. So watch out if you're > coming from Perl 5 land and Heaven forbid you're looking to do traditional > things, you might get scolded for asking a reasonable question. o_O. Roger! Thanks, Bre

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread B. Estrade
As good as this book is, it's still Perl 5 specific. So watch out if you're coming from Perl 5 land and Heaven forbid you're looking to do traditional things, you might get scolded for asking a reasonable question. o_O. Brett On Mon, Mar 23, 2015 at 10:41 AM, Elizabeth Mattijsen wrote: > > On 2

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Bruce Gray
On Mar 23, 2015, at 8:11 AM, Tom Browder wrote: > On Mon, Mar 23, 2015 at 7:04 AM, Tom Browder wrote: >> From your and Henk's comments, I think I need to learn a lot more about >> testing in general. > > Any recommendations for books on the subject? > > -Tom http://shop.oreilly.com/product/9

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Tom Browder
On Mon, Mar 23, 2015 at 10:41 AM, Elizabeth Mattijsen wrote: >> On 23 Mar 2015, at 14:11, Tom Browder wrote: >> Any recommendations for books on the subject? > > Perl Testing - A Developer’s notebook: Thanks, Liz--getting it! -Tom

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Elizabeth Mattijsen
> On 23 Mar 2015, at 14:11, Tom Browder wrote: > On Mon, Mar 23, 2015 at 7:04 AM, Tom Browder wrote: >> From your and Henk's comments, I think I need to learn a lot more about >> testing in general. > Any recommendations for books on the subject? Perl Testing - A Developer’s notebook: http://sh

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Tom Browder
On Mon, Mar 23, 2015 at 7:04 AM, Tom Browder wrote: > From your and Henk's comments, I think I need to learn a lot more about > testing in general. Any recommendations for books on the subject? -Tom

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Tom Browder
On Mar 23, 2015 3:19 AM, "Moritz Lenz" wrote: > That said, I wonder why tests need introspection at all. I mean, you test by > doing example calls and comparing to expected example return values. No argument from me. I am at the point of trying to replicate, in Perl 6, somene else's test suite (

Re: Object Introspection for Existence of Methods: How?

2015-03-23 Thread Moritz Lenz
Hi, On 03/23/2015 01:48 AM, Henk van Oers wrote: On Sun, 22 Mar 2015, Tom Browder wrote: On Sun, Mar 22, 2015 at 7:13 PM, Henk van Oers wrote: On Sun, 22 Mar 2015, Tom Browder wrote: I'm trying to write a test. To test what? Your own typo's? The tests are for a public Perl 6 module trans

Re: Object Introspection for Existence of Methods: How?

2015-03-22 Thread Tom Browder
On Sun, Mar 22, 2015 at 7:48 PM, Henk van Oers wrote: > On Sun, 22 Mar 2015, Tom Browder wrote: >> Do Perl 6 modules not need tests? > Yes they need tests. >> If so, which ones do they need? > The public interface. >> and which can be left off? > The private stuff. > You can not test for 'random_

Re: Object Introspection for Existence of Methods: How?

2015-03-22 Thread Henk van Oers
On Sun, 22 Mar 2015, Tom Browder wrote: On Sun, Mar 22, 2015 at 7:13 PM, Henk van Oers wrote: On Sun, 22 Mar 2015, Tom Browder wrote: I'm trying to write a test. To test what? Your own typo's? The tests are for a public Perl 6 module translated from an existing Perl 5 module. Do Perl 6 mo

Re: Object Introspection for Existence of Methods: How?

2015-03-22 Thread Tom Browder
On Sun, Mar 22, 2015 at 7:13 PM, Henk van Oers wrote: > On Sun, 22 Mar 2015, Tom Browder wrote: >> I'm trying to write a test. > To test what? Your own typo's? The tests are for a public Perl 6 module translated from an existing Perl 5 module. Do Perl 6 modules not need tests? If so, which ones

Re: Object Introspection for Existence of Methods: How?

2015-03-22 Thread Henk van Oers
On Sun, 22 Mar 2015, Tom Browder wrote: On Sun, Mar 22, 2015 at 6:22 PM, Henk van Oers wrote: On Sun, 22 Mar 2015, Tom Browder wrote: On Fri, Mar 20, 2015 at 2:02 PM, Tom Browder wrote: On Mar 20, 2015 1:51 PM, "Tobias Leich" wrote: if $obj.^can($method_name) {... That doesn't seem to wo

Re: Object Introspection for Existence of Methods: How?

2015-03-22 Thread Tom Browder
On Sun, Mar 22, 2015 at 6:22 PM, Henk van Oers wrote: > On Sun, 22 Mar 2015, Tom Browder wrote: >> On Fri, Mar 20, 2015 at 2:02 PM, Tom Browder >> wrote: >>> On Mar 20, 2015 1:51 PM, "Tobias Leich" wrote: if $obj.^can($method_name) {... >> That doesn't seem to work with private methods. An

Re: Object Introspection for Existence of Methods: How?

2015-03-22 Thread Henk van Oers
On Sun, 22 Mar 2015, Tom Browder wrote: On Fri, Mar 20, 2015 at 2:02 PM, Tom Browder wrote: On Mar 20, 2015 1:51 PM, "Tobias Leich" wrote: if $obj.^can($method_name) {... That doesn't seem to work with private methods. Any trick to accomplish that? What part of 'private' did you mis? I

Re: Object Introspection for Existence of Methods: How?

2015-03-22 Thread Tom Browder
On Fri, Mar 20, 2015 at 2:02 PM, Tom Browder wrote: > On Mar 20, 2015 1:51 PM, "Tobias Leich" wrote: >> if $obj.^can($method_name) {... That doesn't seem to work with private methods. Any trick to accomplish that? -Tom

Re: Object Introspection for Existence of Methods: How?

2015-03-20 Thread Tom Browder
On Mar 20, 2015 2:07 PM, "Will Coleda" wrote: > > > use Test; > > class bar { method foo () {}} > > ok bar.can("foo"), "stuff"; > ok 1 - stuff Oops (I say as I slap my forehead)! Thanks, Will. -Tom

Re: Object Introspection for Existence of Methods: How?

2015-03-20 Thread Will Coleda
> use Test; > class bar { method foo () {}} > ok bar.can("foo"), "stuff"; ok 1 - stuff On Fri, Mar 20, 2015 at 3:00 PM, Tom Browder wrote: > On Mar 20, 2015 1:50 PM, "Will Coleda" wrote: >> class bar { method foo () {}} >> my bar $a = bar.new(); >> say so $a.can("foo"); > > Great! > >> I'm not s

Re: Object Introspection for Existence of Methods: How?

2015-03-20 Thread Tom Browder
On Mar 20, 2015 1:51 PM, "Tobias Leich" wrote: > if $obj.^can($method_name) {... Thanks, Tobias. Cheers! -Tom

Re: Object Introspection for Existence of Methods: How?

2015-03-20 Thread Tom Browder
On Mar 20, 2015 1:50 PM, "Will Coleda" wrote: > class bar { method foo () {}} > my bar $a = bar.new(); > say so $a.can("foo"); Great! > I'm not sure this warrants a new _ok method. How would you do it with an existing test? Thanks, Will. Cheers! -Tom

Re: Object Introspection for Existence of Methods: How?

2015-03-20 Thread Tobias Leich
if $obj.^can($method_name) {... Am 20.03.2015 um 19:38 schrieb Tom Browder: > I am trying to create a testing subroutine to detect if a class object > has a certain method. > > I want it to look something like this: > > my $obj = Foo.new(); > can_ok($obj, 'method1'); > > sub can_ok($obj, Str

Re: Object Introspection for Existence of Methods: How?

2015-03-20 Thread Will Coleda
class bar { method foo () {}} my bar $a = bar.new(); say so $a.can("foo"); True my Int $b; say so $b.can("foo"); False I'm not sure this warrants a new _ok method. On Fri, Mar 20, 2015 at 2:38 PM, Tom Browder wrote: > I am trying to create a testing subroutine to detect if a class object > ha

Object Introspection for Existence of Methods: How?

2015-03-20 Thread Tom Browder
I am trying to create a testing subroutine to detect if a class object has a certain method. I want it to look something like this: my $obj = Foo.new(); can_ok($obj, 'method1'); sub can_ok($obj, Str $method_name) { if $obj.{$method_name}:exists { say "ok"; return True;