🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
guifa_ tbrowder you could always write a wrapper 01:32
m: use Test; &is.wrap: anon sub is ($expected, $got) { nextwith $got, $expected }; is 'expected', 'got';
camelia not ok 1 -
# Failed test at SETTING::src/core.c/control.pm6 line 146
# expected: 'expected'
# got: 'got'
01:33
tonyo rf: any way to just route _all_ errors in hummingbird through one handler rather than specifying the type or would i use advice and inspect the request for something? 03:07
tbrowder__ guifa: thanks, but i'm too lazy fo that... 09:56
lizmat tbrowder_: FWIW, you *don't* have to use Test in your tests 10:01
as long as your test files produce TAP, you should be fine 10:02
guifa_ lizmat: what do you mean by "produce TAP" ? 10:11
lizmat TAP output
ok 1 - foo
guifa_ ah. I was figuring it was the exit code that was used based on the END block 10:14
tbrowder__ hm, a good idea when all else fails! 10:29
lizmat e.g. many of the files in t/01-sanity do not use Test 10:30
tbrowder__ but, basically, at the moment my failures are being caused by testing hash/list structures with is-deeply, so i need Test 10:31
specifically the test that fails at the moment is from module Font::AFM where there is a structure hash .BBox keyed by character names, with values a 4-item list of numbers. 10:34
the "got" part is taking that has and multiplying each number by the same constant value (scale factor) to produce a new, replacement list 10:36
sorry, that is the "expected" entry 10:38
the "got" part is the equivalent .BBox from my module 10:39
i used a short cut from [Coke] and moritz to update the lists in one go by $newlist = $oldlist >>*>> $scalefactor 10:41
tbrowder__ the values work fine, but in one case i have a list and the other it's an array, and that causes is-deeply to fail 10:42
i haven't yet been able to zero in on a fix
(the failure msg is long due to the size of the hash) 10:43
tbrowder__ i can pass the test by completely unpacking the structure and rebuilding, but using >>*>> would be so much better 10:44
i't 10:45
lizmat maybe coerce the expected or gotten to .List ?
before giving it to is-deeply ? 10:46
tbrowder__ i tried that once with no success when applying it to the "got" part. ibut i may try again--that's where the confusion comes with Test got vs expected 10:48
give me a few... 10:49
i'm going back to my side of the test and see why it's an array. i used the >>*>> on that side, too. thnx for being a good sounding board 11:12
lizmat yw :-) 11:15
tbrowder__ ah, my side is using $newhash = $oldhash>>.map({$_ * $factor}) 11:18
that somehow produces an array. i'll fiddle with that... 11:19
lizmat that'd be multiplying a Pair ? 11:20
which feels.... suboptimal?
tbrowder__ ?
lizmat m: my %h = :42a, :666b; say %h>>.map(&dd) # TIL that >>. on a hash produces values 11:22
camelia 42
{a => (Nil), b => (Nil)}
666
lizmat or maybe re-learned :-) 11:23
tbrowder__ m: my $h = 'a' => (1,2); say %h>>.map({$_ * 2}) 11:26
camelia ===SORRY!=== Error while compiling <tmp>
Variable '%h' is not declared. Did you mean '$h'?
at <tmp>:1
------> my $h = 'a' => (1,2); say ⏏%h>>.map({$_ * 2})
Nemokosch I used that semi-regularly 11:27
tbrowder__ m: $h = a => 1,2; say $h>>.map({$_ * 2 }) 11:28
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$h' is not declared. Perhaps you forgot a 'sub' if this was
intended to be part of a signature?
at <tmp>:1
------> <BOL>⏏$h = a => 1,2; say $h>>.map({$_ * 2 })
Nemokosch for a long time I wondered, why something like deepmap exists in the first place, and there you go: it doesn't make a lot of sense for arrays but it makes great sense for deeply nested maps/hashes
where it's not only common but pretty good design to put the actual values in the nodes
tbrowder__ m: my $h = a => 1,2; say $h>>.map({$_ * 2}) 11:29
camelia WARNINGS for <tmp>:
Useless use of constant integer 2 in sink context (lines 1, 1)
Cannot resolve caller new(Pair:D: ); none of these signatures matches:
(Pair: Str:D $key, Mu \value, *%_)
(Pair: Mu \key, Mu \value, *%_)
(Pair: M…
tbrowder__ think i need parens 11:33
m: $h=a=>(1,2); say $h>>.map({$_*2}) 11:34
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$h' is not declared. Perhaps you forgot a 'sub' if this was
intended to be part of a signature?
at <tmp>:1
------> <BOL>⏏$h=a=>(1,2); say $h>>.map({$_*2})
tbrowder__ jeepers! 11:35
Nemokosch anyway, no, not parens
brackets around the RHS, or even better: %() around the RHS 11:36
tbrowder__ m: my $h=a=>(1,2); say $h>>.map({$_*2})
camelia Cannot resolve caller new(Pair:D: ); none of these signatures matches:
(Pair: Str:D $key, Mu \value, *%_)
(Pair: Mu \key, Mu \value, *%_)
(Pair: Mu :$key!, Mu :$value!, *%_)
in block <unit> at <tmp> line 1
tbrowder__ m: my $h=a=(1,2); say "{$h>>.map({$_*2})}" 11:40
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
a used at line 1
Nemokosch m: my $h = { a => (1, 2) }; say $h>>.map({$_ * 2}) 11:41
Raku eval {a => (2 4)}
tbrowder__ forgot > this time,
thnx, but why Raku eval? 11:42
gotta try my way... 11:43
Nemokosch because there is no camelia on discord 12:03
tbrowder__ m: my $h 12:57
camelia ( no output )
tbrowder__ ah, got it 12:59
okey dokey, [Coke]'s advice was correct, i just confirmed old rule that copy/pasta may not be the answer. he said, regarding map, that the ({$_ * X}) was the most flexible, and i used it in this work. 13:37
*however*, i failed to change that part to accurately model the actual structure. when i did, i get good results. 13:38
for a hash of %h<key> = 1,2,3,4 i needed %h>>.map({$_ >>*>>}) 13:41
duh: >>*>> $f}) 13:42
leont What's the right syntax to alias a type from another module to my own module? 14:22
leont «my ::Foo = Other::Foo;» doesn't seem to DWIM 14:23
rf tonyo: You can use a stash + middleware 14:25
Requests and Responses have stashes
[Coke] leont: I don't have a place to test this, but: bind, instead? 14:26
:= ?
leont Nope, but apparently getting rid of the my did the trick.
Or apparently it didn't, it just compiled 14:27
leont I'm entirely stuck on this? :-( 14:45
tbrowder__ my $t = $Foo::bar.foo 15:02
vrurg Why a type capture would be needed if there is `my \Foo = Other::Foo;` ? 15:04
tonyo rf: hummingbird seems to not parse query string correctly, whether i give it `?email=test@test.com` or `?email=test%40test.com`, in the .query('email') i get back `test` 17:43
also kills the server by running siege with the default configuration against it 17:49
rf tonyo: Query params have been a real pain, would you mind filing an issue. I thought I fixed this. 19:14
What's also odd is that it died with Siege, I've hit it with siege before and it seems to do okay 19:15
Ahh @tonyo I see the bug, I'll fix it up right away! 19:18
rf tonyo: github.com/rawleyfowler/Humming-Bird/pull/55 Just waiting on CI and it'll be released as 2.1.4 19:42
rf I must have been drunk when I wrote the query param decoding originally :X 19:56
tonyo hahaha 20:12
blesss
rf: i've narrowed the error down to the `error(` function + using siege 20:13
rf++ query is coming in nicely now 20:16
ugexe github.com/rawleyfowler/Humming-Bi...kumod#L588 20:17
dunno if that function needs to be thread safe, but it isnt
a wild guess is the reads and writes to that hash should be protected 20:19
tbrowder__ tonyo: is hummingbird usable with yr pdf https guide with all its bells and whistles? 20:31
rf tonyo: Great! Let me know if you find other issues 20:32
Humming bird is single threaded
tonyo tbrowder__: let me double check 20:33
rf To my knowledge lol, although i'm not entirely sure how raku does async stuff under the hood
tonyo tbrowder__: it is, the Cro parts would change slightly and i'd probably use this for templating: raku.land/zef:tony-o/Ryml 20:34
rf I use Ryml in production right now tonyo :)
Internal stuff but still it's excellent! 20:35
rf Also ugexe that call should typically only be called when setting up the server, thought there may be a case for calling it if you wish to dynamically handle new exception types at run time 20:39
ugexe delegate-route isn’t thread safe either 22:47
I do get that normally that shouldn’t be a problem though
easy enough to fix too 22:58
ugexe there are modules like Concurrent::Trie, but I usually just writer a getter/setter function for each hash, a global lock for each getter/setter pair, and then using $!the-lock.protect: { use-the-hash-here } 23:00