Re: testing with a "warn"

2016-04-29 Thread rnhainsworth
Hi. Sorry to ask again, but there are two independent questions here. 1) What 
is the purpose or best use of 'warn'. 2) How to test code that contains a 
'warn' used as it should be.
1) I thought that a 'warn' would be used where sometimes the user would want a 
fail but not always. I have a module that in normal use I want to continue even 
if there is a bad condition which has a default action, but that I can get to 
fail if I set an external flag. Maybe I'm wrong. But this is not the question I 
originally asked.
2) whatever may be the purpose of a warn, and I assume there is a good one 
since its in core perl6, surely the code that contains it should be tested, 
which means triggering the condition and picking up the warning. I can't work 
out how to do this. Can't get Test::Output to pick up the message sent to 
stderr from warn.
Regards


 Original message From: Larry Wall  Date: 
30/04/2016  06:45  (GMT+08:00) To: Brandon Allbery  Cc: 
Timo Paulssen , perl6-users  Subject: 
Re: testing with a "warn" 
On Fri, Apr 29, 2016 at 03:50:21PM -0400, Brandon Allbery wrote:
: On Fri, Apr 29, 2016 at 3:47 PM, Brandon Allbery 
: wrote:
: > Oh, they are resumable exceptions? Useful but rather high cost I'd think.
: > (Granting that perl6 isn't one of those languages that think exceptions
: > should be normal control flow. But anyone who decides it should be is
: > probably in for a very slow slog.)

Warnings are implemented like return or next; control exceptions are
more efficient than error exceptions.  (This is one of the reasons you
have to catch them with a CONTROL block rather than a CATCH block.)

: ...also I now know that I should not use warn in many cases where I would
: have otherwise.

If you need to produce actual warnings in hot code, something's wrong
with your design.  (If you just want to print to STDERR, you can use
'note' instead.)

Larry


Re: Helping Perl 6: a complete dev environment

2016-04-29 Thread Jovan Trujillo
I see Padre has hooks for running Perl 6 and even parrot code. Don't know if 
Git is built into it yet. Probably easier to get started than using Emacs or 
spacemacs

Sent from my iPhone

> On Apr 28, 2016, at 3:26 PM, Tom Browder  wrote:
> 
> Is there a pointer somewhere on how to set up a complete development 
> environment for Perl 6?  I know how to clone individual pieces but I don't 
> know how to use the various cloned directories for a complete dev environment 
> using them.  I assume I can install each piece individually but maybe there 
> is some magic way to use rakudobrew to do it more easily.
> 
> I would like to be able to easily test and create pull requests for rakudo 
> and also the Task::Star modules but haven't yet figured out how to get it all 
> working in the most effective manner.
> 
> Thanks.
> 
> Best regards,
> 
> -Tom


testing with a "warn"

2016-04-29 Thread Richard Hainsworth

I have a condition that uses warn

something like (its just an illustration)

sub abc {
...
if $iterations > 150 {
$iterations = 150;
warn 'excess recursion, clamping at 150';
}


In my test suite I tried

throws-like { abc('excess') }, Exception, 'got the exception', message 
=> / excess recursion /;



However, this fails to pick up the exception and I get something like:

excess recursion, clamping at 150
not ok 1 - code dies

# Failed test 'code dies'
# at t/basic.t line 56
ok 2 - # SKIP Code did not die, can not check exception
ok 3 - # SKIP Code did not die, can not check exception
# Looks like you failed 1 test of 3


lives-ok { abc('excess') }, 'got the exception';

passes the test, but does not verify that the correct warning message 
was passed, and in any case, this test would pass even if the exception 
condition wasn't fulfilled.


Have I missed something?

I could use the module Test:::Output, to test std-err, but this seems 
inappropriate for what is a core sub like warn.





Re: testing with a "warn"

2016-04-29 Thread Brandon Allbery
On Fri, Apr 29, 2016 at 1:25 AM, Richard Hainsworth 
wrote:

> throws-like { abc('excess') }, Exception, 'got the exception', message =>
> / excess recursion /;


I'm confused as to why you would expect this to work. The point of warn is
it is *not* an exception; an exception by definition aborts code execution,
while warn continues. As such, there is no exception and nothing you can
catch --- since if you could catch it, it would mean the original code
stopped executing and threw it instead.

I could imagine a design where the block where you used `warn` attached
some kind of extra value to whatever it eventually returns, but (a) it's a
horrid lot of extra complexity and slowdowns to handle such a thing, and
(b) you'd usually like to see the warning even if the block *doesn't*
return. If you want a side system of some kind that lets you treat *that*
case like an exception, then you're throwing fake exceptions to a whole
separate thread that sits there waiting for them and does something or
other --- again. lots of complexity for extremely dubious gain, and if you
then decide that since you got your warnings-are-exceptions you should now
get the full suite of things you could do with an exception... you now have
that warnings must stop until the side thread tells them what to do, or
else make warnings into full exceptions with some kind of resume capability
that is turned on by default. But this isn't an actual warning and now
people will ask why we don't have warnings, just resumable exceptions

In short: exceptions are not warnings, not practically and not
conceptually; they are a completely different thing entirely. No amount of
scaffolding will turn an apple into a horse. Use Test::Output.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: testing with a "warn"

2016-04-29 Thread Timo Paulssen
I didn't actually read the other mail in this thread yet, but you can
catch a control exception (like warn uses) with a CONTROL block. Don't
forget to .resume the exception unless you want it to break out of your
code, too.

Hope to help!
  - Timo


Re: testing with a "warn"

2016-04-29 Thread Brandon Allbery
On Fri, Apr 29, 2016 at 3:47 PM, Brandon Allbery 
wrote:

> Oh, they are resumable exceptions? Useful but rather high cost I'd think.
> (Granting that perl6 isn't one of those languages that think exceptions
> should be normal control flow. But anyone who decides it should be is
> probably in for a very slow slog.)


...also I now know that I should not use warn in many cases where I would
have otherwise.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Helping Perl 6: a complete dev environment

2016-04-29 Thread Timo Paulssen
I just have a ~/perl6 where i have a clone of MoarVM/MoarVM, perl6/nqp,
and rakudo/rakudo. You just have to provide each Configure.pl with the
same --prefiix - in my case that's ~/perl6/install - then everything
will find each other.

There's some extra paths in my $PATH:

/home/timo/perl6/install/share/perl6/site/bin
/home/timo/perl6/install/bin

If you're interested in an editor that plays well with perl6, there's
some plugins for Atom, like the "perl6-fe" module or something. These
include things like "run my code" or "check syntax" or "render the
included Pod into html and show it" and such.

Hope to help
  - Timo


Re: Difficulty Installing Module on Latest Rakudo Star

2016-04-29 Thread Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC at Cisco)
Hmmm, No that gets a similar error.


$ perl6 -MDigest -e1

===SORRY!===

Could not find Digest at line 1 in:

/Users/jpolanik/.perl6

/Applications/Rakudo/share/perl6/site

/Applications/Rakudo/share/perl6/vendor

/Applications/Rakudo/share/perl6

CompUnit::Repository::AbsolutePath<4435167512>

CompUnit::Repository::NQP<4435164760>

CompUnit::Repository::Perl5<4435162168>

Joe


From: Tadeusz Sośnierz 
>
Date: Friday, April 29, 2016 at 5:28 PM
To: "perl6-users@perl.org" 
>
Subject: Re: Difficulty Installing Module on Latest Rakudo Star

Alright. You mention Digest itself being installed, so just to be sure: 'perl6 
-MDigest -e1' works fine?

On 29/04/16 23:21, Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC at Cisco) 
wrote:
Tadeusz,

I tried using -force because I initially thought I would be reinstalling 
Bailador.

Eliminating --force and --prefix had no effect. Here is the entire output.


$ sudo panda install Digest::HMAC

==> Fetching Digest::HMAC

==> Building Digest::HMAC

==> Testing Digest::HMAC

===SORRY!===

Could not find Digest at line 6 in:

/Users/jpolanik/Documents/myPerl6/Bailador/life/.panda-work/1461964706_1/lib

/Users/jpolanik/.perl6

/Applications/Rakudo/share/perl6/site

/Applications/Rakudo/share/perl6/vendor

/Applications/Rakudo/share/perl6

CompUnit::Repository::AbsolutePath<140471828218032>

CompUnit::Repository::NQP<140471823022992>

CompUnit::Repository::Perl5<140471823023032>

t/01-basic.t ..

Dubious, test returned 1 (wstat 256, 0x100)

No subtests run


Test Summary Report

---

t/01-basic.t (Wstat: 256 Tests: 0 Failed: 0)

  Non-zero exit status: 1

  Parse errors: No plan found in TAP output

Files=1, Tests=0,  1 wallclock secs ( 0.02 usr  0.01 sys +  1.60 cusr  0.10 
csys =  1.73 CPU)

Result: FAIL

test stage failed for Digest::HMAC: Tests failed

  in method install at 
/Applications/Rakudo/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A
 (Panda) line 157

  in method resolve at 
/Applications/Rakudo/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A
 (Panda) line 234

  in sub MAIN at 
/Applications/Rakudo/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8
 line 18

  in block  at 
/Applications/Rakudo/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8
 line 152



Failure Summary



Digest::HMAC(

*test stage failed for Digest::HMAC: Tests failed)

Thanks,

Joe



From: Tadeusz Sośnierz 
>
Date: Friday, April 29, 2016 at 5:10 PM
To: 
"perl6-users@perl.org"
 >
Subject: Re: Difficulty Installing Module on Latest Rakudo Star

Hey Joe,
Can you post the entire panda output? Also, does the situation change when you 
don't use --prefix, and/or is there a particular reason why you use --force?

On 29/04/16 23:02, Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC at Cisco) 
wrote:
I'm trying to install Bailador on a Mac running OSX 10.11.4 with the Latest 
Rakudo Star (2016.04). The installation fails on a dependency.

Digest::HMAC can't be installed using

sudo panda --prefix=/Applications/Rakudo/share/perl6/site/bin/ --force install 
Digest::HMAC

The error message says


Could not find Digest at line 6 in:

/Applications/Rakudo/share/perl6/site

/Applications/Rakudo/share/perl6/vendor

/Applications/Rakudo/share/perl6

However, Digest itself is installed. It's visible in the file system browser 
and my .per.6/panda/state file lists it as having been successfully installed.

Any advice would be appreciated.

Thanks,

Joe





Re: testing with a "warn"

2016-04-29 Thread Brandon Allbery
On Fri, Apr 29, 2016 at 6:45 PM, Larry Wall  wrote:

> If you need to produce actual warnings in hot code, something's wrong
> with your design.  (If you just want to print to STDERR, you can use
> 'note' instead.)
>

The latter's more what I was getting at, yes.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Difficulty Installing Module on Latest Rakudo Star

2016-04-29 Thread Tadeusz Sośnierz
Right; looks like Digest isn't properly installed after all. Try 'panda 
--force install Digest'?


On 29/04/16 23:39, Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC at 
Cisco) wrote:

Hmmm, No that gets a similar error.

$ perl6 -MDigest -e1

===SORRY!===

Could not find Digest at line 1 in:

  /Users/jpolanik/.perl6

  /Applications/Rakudo/share/perl6/site

  /Applications/Rakudo/share/perl6/vendor

  /Applications/Rakudo/share/perl6

  CompUnit::Repository::AbsolutePath<4435167512>

  CompUnit::Repository::NQP<4435164760>

  CompUnit::Repository::Perl5<4435162168>


Joe


From: Tadeusz Sośnierz >

Date: Friday, April 29, 2016 at 5:28 PM
To: "perl6-users@perl.org " 
>

Subject: Re: Difficulty Installing Module on Latest Rakudo Star

Alright. You mention Digest itself being installed, so just to be 
sure: 'perl6 -MDigest -e1' works fine?


On 29/04/16 23:21, Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC 
at Cisco) wrote:

Tadeusz,

I tried using —force because I initially thought I would be 
reinstalling Bailador.


Eliminating -—force and -—prefix had no effect. Here is the entire 
output.


$ sudo panda install Digest::HMAC

==> Fetching Digest::HMAC

==> Building Digest::HMAC

==> Testing Digest::HMAC

===SORRY!===

Could not find Digest at line 6 in:

/Users/jpolanik/Documents/myPerl6/Bailador/life/.panda-work/1461964706_1/lib

/Users/jpolanik/.perl6

/Applications/Rakudo/share/perl6/site

/Applications/Rakudo/share/perl6/vendor

/Applications/Rakudo/share/perl6

CompUnit::Repository::AbsolutePath<140471828218032>

CompUnit::Repository::NQP<140471823022992>

CompUnit::Repository::Perl5<140471823023032>

t/01-basic.t ..

Dubious, test returned 1 (wstat 256, 0x100)

No subtests run


Test Summary Report

---

t/01-basic.t (Wstat: 256 Tests: 0 Failed: 0)

  Non-zero exit status: 1

  Parse errors: No plan found in TAP output

Files=1, Tests=0,  1 wallclock secs ( 0.02 usr  0.01 sys +  1.60 
cusr  0.10 csys =  1.73 CPU)


Result: FAIL

test stage failed for Digest::HMAC: Tests failed

  in method install at 
/Applications/Rakudo/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A 
(Panda) line 157


  in method resolve at 
/Applications/Rakudo/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A 
(Panda) line 234


  in sub MAIN at 
/Applications/Rakudo/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 
line 18


  in block  at 
/Applications/Rakudo/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 
line 152




Failure Summary



Digest::HMAC(

*test stage failed for Digest::HMAC: Tests failed)


Thanks,

Joe



From: Tadeusz Sośnierz >

Date: Friday, April 29, 2016 at 5:10 PM
To: "perl6-users@perl.org" >

Subject: Re: Difficulty Installing Module on Latest Rakudo Star

Hey Joe,
Can you post the entire panda output? Also, does the situation change 
when you don't use --prefix, and/or is there a particular reason why 
you use --force?


On 29/04/16 23:02, Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC 
at Cisco) wrote:
I'm trying to install Bailador on a Mac running OSX 10.11.4 with the 
Latest Rakudo Star (2016.04). The installation fails on a dependency.


Digest::HMAC can't be installed using

sudo panda --prefix=/Applications/Rakudo/share/perl6/site/bin/ 
--force install Digest::HMAC


The error message says

Could not find Digest at line 6 in:

/Applications/Rakudo/share/perl6/site

/Applications/Rakudo/share/perl6/vendor

/Applications/Rakudo/share/perl6


However, Digest itself is installed. It's visible in the file system 
browser and my .per.6/panda/state file lists it as having been 
successfully installed.


Any advice would be appreciated.

Thanks,

Joe









Re: Difficulty Installing Module on Latest Rakudo Star

2016-04-29 Thread Tadeusz Sośnierz
Alright. You mention Digest itself being installed, so just to be sure: 
'perl6 -MDigest -e1' works fine?


On 29/04/16 23:21, Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC at 
Cisco) wrote:

Tadeusz,

I tried using —force because I initially thought I would be 
reinstalling Bailador.


Eliminating -—force and -—prefix had no effect. Here is the entire output.

$ sudo panda install Digest::HMAC

==> Fetching Digest::HMAC

==> Building Digest::HMAC

==> Testing Digest::HMAC

===SORRY!===

Could not find Digest at line 6 in:

/Users/jpolanik/Documents/myPerl6/Bailador/life/.panda-work/1461964706_1/lib

  /Users/jpolanik/.perl6

  /Applications/Rakudo/share/perl6/site

  /Applications/Rakudo/share/perl6/vendor

  /Applications/Rakudo/share/perl6

CompUnit::Repository::AbsolutePath<140471828218032>

  CompUnit::Repository::NQP<140471823022992>

  CompUnit::Repository::Perl5<140471823023032>

t/01-basic.t ..

Dubious, test returned 1 (wstat 256, 0x100)

No subtests run


Test Summary Report

---

t/01-basic.t (Wstat: 256 Tests: 0 Failed: 0)

Non-zero exit status: 1

Parse errors: No plan found in TAP output

Files=1, Tests=0,  1 wallclock secs ( 0.02 usr  0.01 sys +  1.60 cusr  
0.10 csys =  1.73 CPU)


Result: FAIL

test stage failed for Digest::HMAC: Tests failed

in method install at 
/Applications/Rakudo/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A 
(Panda) line 157


in method resolve at 
/Applications/Rakudo/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A 
(Panda) line 234


in sub MAIN at 
/Applications/Rakudo/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 
line 18


in block  at 
/Applications/Rakudo/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 
line 152




Failure Summary



Digest::HMAC(

*test stage failed for Digest::HMAC: Tests failed)


Thanks,

Joe



From: Tadeusz Sośnierz >

Date: Friday, April 29, 2016 at 5:10 PM
To: "perl6-users@perl.org " 
>

Subject: Re: Difficulty Installing Module on Latest Rakudo Star

Hey Joe,
Can you post the entire panda output? Also, does the situation change 
when you don't use --prefix, and/or is there a particular reason why 
you use --force?


On 29/04/16 23:02, Joe Polanik -X (jpolanik - RESOLVIT RESOURCES LLC 
at Cisco) wrote:
I'm trying to install Bailador on a Mac running OSX 10.11.4 with the 
Latest Rakudo Star (2016.04). The installation fails on a dependency.


Digest::HMAC can't be installed using

sudo panda --prefix=/Applications/Rakudo/share/perl6/site/bin/ 
--force install Digest::HMAC


The error message says

Could not find Digest at line 6 in:

/Applications/Rakudo/share/perl6/site

/Applications/Rakudo/share/perl6/vendor

/Applications/Rakudo/share/perl6


However, Digest itself is installed. It's visible in the file system 
browser and my .per.6/panda/state file lists it as having been 
successfully installed.


Any advice would be appreciated.

Thanks,

Joe