This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
antononcube @briandouglas_71953 I might have a simple, short solution, but you have to use a "complicated" package. 00:00
@briandouglas_71953 Here is my solution: use Testo; my $tester = Testo::Tester.new(format => 'TAP'); my $res1 = $tester.is(1, 2, '1 is always 2'); say '$res1 => ', $res1.raku; my $res2 = $tester.is-eqv([1, 3], [1, 3], 'arr'); say '$res2 => ', $res2.raku; 00:34
Here is the output: not ok 1 - 1 is always 2 # Got: 1 # Does not smartmatch with: 2 $res1 => Testo::Test::Result.new(so => Bool::False, desc => "1 is always 2", fail => " Got: 1\nDoes not smartmatch with: 2") ok 2 - arr $res2 => Testo::Test::Result.new(so => Bool::True, desc => "arr", fail => Nil) 00:35
We can see in the results that objects $res1 and $res2 can be scanned to get success or not and the corresponding assertions if the tests failed. 00:37
Unfortunately, only the format "TAP" (Testo::Out::TAP) is implemeted. I was hoping "Testo" to have JSON. Maybe it is not that hard add a new output class. 00:38
03:48 ACfromTX joined
briandouglas_71953 Thanks @antononcube , specifically I was hoping to get the output from the build in assertions. I've had to just add my own output. When running a test I throw a custom exception if the assertion is not True. raku class FailedComparison is Exception { has $.desc; has $.given; has $.expected; method message { "custom output"; } } role Comparator { has $.given is rw; method 07:51
to-be($expected) {...}; method to-be-true {...}; method to-be-false {...}; method run(Bool $result, $expected, $desc) { FailedComparison .new(desc => $desc, given => $.given, expected => $expected) .throw unless $result; } }
This way I can capture the output of expect inside it and describe. raku describe("Basic test suite", -> { it("should know 1 is 1", -> { expect(1).to-be(1); }); it("should know True is true", -> { expect(True).to-be-true; }); it("should run multiple assertions", -> { expect(1).to-be(1); expect(True).to-be-true; expect(True).not.to-be-false; expect(False).to-be-false; 07:52
expect(False).not.to-be-true; }); });
08:26 dakkar joined
ab5tract Looks pretty sleek! 09:05
09:44 TmpCon joined 09:49 TmpCon left 09:54 Salizer joined, Salizer left 10:33 discord-raku-bot left, discord-raku-bot joined 10:57 lizmat_ joined 11:01 lizmat left, lizmat_ left, lizmat joined 16:35 dakkar left 16:39 abc123abc123 joined
abc123abc123 Unable to install the rakudo-star march and april release on netbsd-10 using the "./bin/rstar install" approach. The previous releases would install using a different method as documented. Linux installs successfully. 16:43
Feedback. The 2023.09 rakudo-star would build and install on netbsd-10. The install method for 2024.04 mentions in the log that it failed to load library 'dynext/libperl6_ops_moar.so'. Perhaps that shared object file is stale. 17:09
18:11 abc123abc123 left
librasteve abc123abc123: you are in an offbeat OS and raku is really only implemented in mainstream Nix such as ubuntu - I would start by suggesting you try rakubrew.org (likely in source build mode) - if that hits similar issues, then maybe a Docker image or glot.io would work for you? 19:21