Testing Was: Appropriate last words

2018-10-21 Thread Richard Hainsworth
I'm writing a module and want to exit without a backtrace if conditions are not met. So I can write: exit note '$path directory does not exist' unless $path.IO ~~ :d; Fine. But how do I test this? I thought dies-ok, but dies-ok wants an exception. test.t:     sub testnote {exit note 'this

Re: Testing Was: Appropriate last words

2018-10-21 Thread Timo Paulssen
https://docs.perl6.org/language/variables#index-entry-%24%2AEXIT this should help you get to where you want to be. Someone™ can feel free to open up a ticket on the doc repository that the routine page for exit doesn't have a link to or explanation of &*EXIT. HTH   - Timo

Re: Testing Was: Appropriate last words

2018-10-21 Thread Richard Hainsworth
How does this answer the question about testing? Ok so there is code, but where do I go to find what that code is? Where in the Rakudo repo would I start looking, eg.? On 21/10/18 16:23, Timo Paulssen wrote: https://docs.perl6.org/language/variables#index-entry-%24%2AEXIT this should help y

Re: Appropriate last words

2018-10-21 Thread Richard Hainsworth
This sounds great. So I am writing a class verifies conditions, and dies when conditions are not met. How do I attach a default CATCH to all methods in the class. Or do I need to define my own Exception. On 04/09/18 04:48, Curt Tilmes wrote: On Mon, Sep 3, 2018 at 4:28 PM Parrot Raiser <

Re: Testing Was: Appropriate last words

2018-10-21 Thread Timo Paulssen
I think you would just have something like this in your test program's mainline:     my &*EXIT = -> | { die "exit was called" } and then you can use dies-ok. Bonus points for creating your own exception class so that you can check that it was actually &*EXIT that got you there, and not some rando

Re: Appropriate last words

2018-10-21 Thread Elizabeth Mattijsen
I’m not sure what you mean by: "How do I attach a default CATCH to all methods in the class.”. What are you trying to achieve? > On 21 Oct 2018, at 10:35, Richard Hainsworth wrote: > > This sounds great. > > So I am writing a class verifies conditions, and dies when conditions are not > met.

Re: I need unprintable regex help

2018-10-21 Thread ToddAndMargo via perl6-users
On 10/20/18 10:49 PM, ToddAndMargo via perl6-users wrote: I'm not sure what you thought I was showing you on IRC last night Oh ya, and a string is not an array of characters. That comes from my Modula2 days.

Re: Appropriate last words

2018-10-21 Thread Richard Hainsworth
I am trying to find a way to send a message via STDERR to a user, and to exit, but to eliminate the backtrace printing. so .. either I use your suggestion of 'exit note $message' which I find elegant, but so far difficult to test. (I tried timo's suggestion of &*EXIT = -> | { die 'exited' }

"put" vs "say"

2018-10-21 Thread Parrot Raiser
"put" and "say" seem to be redundant, but I'm sure there's a good reason for having 2 output commands. Would anyone care to comment on how they differ and why, or point to an explanation?

Re: "put" vs "say"

2018-10-21 Thread Timo Paulssen
put is meant for machines, while say is meant for humans. this is implemented by having say call the .gist method and put calling the .Str method. Try using say and put on a list of a thousand elements or more and you'll see what I mean. HTH   - Timo On 21/10/2018 18:29, Parrot Raiser wrote: >

Re: "put" vs "say"

2018-10-21 Thread Parrot Raiser
Thanks for the suggestions. I ran a couple of tests: my $data_list = 1..1001; say $data_list; produces 1..1000 real0m0.357s user0m0.435s sys 0m0.048s my $data_list = 1..1001; put $data_list; produces the list of integers from 1 to 1001 (obviously a single string). real0m0.470