raku / roast Goto Github PK
View Code? Open in Web Editor NEW🦋 Raku test suite
Home Page: https://raku.org/
License: Artistic License 2.0
🦋 Raku test suite
Home Page: https://raku.org/
License: Artistic License 2.0
If you want to know what from-loop is, see http://doc.perl6.org/routine/from-loop
We have indir() sub, but it appears to be both untested and undocumented.
There's a bunch of tests in S03-operators/context-forcers.t that currently result in Failure, but due to the @
coercer, that failure gets wrapped into a 1-item list that when coerced with ?
, returns True, causing the test to incorrectly pass.
There was a conversation and seems the $*
twigil should be just a $
. But, when I changed that to that, they still fail.
So I'm unsure what the fix is.
Code:
say $*IN.path
Result:
IO::Special.new(what => "<STDIN>")
Looking at this snippet, it seems like $.path attribute is not tested. Also, there are no tests for IO::Special.
See: http://unicode.org/reports/tr51/#Data_Files for how they are determined (These are Boolean)
Values stored here: http://unicode.org/Public/emoji/latest/emoji-data.txt
If you hadn't seen this before, really great resource to check which symbols have a property:
http://unicode.org/cldr/utility/properties.html
These are not official Unicode properties and should not have tests written for them. They are listed here for completeness.
The problem is with this piece of code (from https://github.com/rakudo/rakudo/blob/nom/src/core/List.pm#L426):
unless nqp::istype($topic, Iterable) {
return self unless self.elems;
return self if nqp::istype(self[0], Match);
return False;
}
For example:
say 4 ~~ () # ()
↑ That is a bit unexpected.
Some tests would help to clarify what should actually happen in these cases.
Also see http://irclog.perlgeek.de/perl6/2016-04-24#i_12386065 (discussion afterwards).
I've also opened this ticket: https://rt.perl.org/Ticket/Display.html?id=127980
Looking at S32-io/file-tests.t, I see many file tests offered by Rakudo are not tested for. These include .rw
, .rwx
, .z
and possibly others.
Unicode superscript exponentiation (ⁿ) tests were added to S32-num/power.t but related tests did not seem to be added to S03-operators/precedence.t which also has tests for the ** operator. Some tests like ++$i ** 2
(now ++$i²
) would not behave the same way because the superscript operator is not associative, but other tests should be quite similar. Fixing this might add about a half dozen tests.
This file was added in 2013, isn't in t/spectest.data, and fails to compile.
Need to review this file and run it or delete it.
class C {
multi method f(::?CLASS:U:){say "class method"}
multi method f(::?CLASS:D:){say "object method"}
}
C.f; # says class method
C.new.f; # says object method
I see some other invocant related tests but not for this use case that appears in S12, mentioned in docs, and seems well enough known.
moritz++ mentioned: a proposed addition that would let you write method f(:U:) { } for a class-only method...
A comment about the proposed addition might go in with the tests.
See also IRC discussion.
They are documented and they seem to work, but there are no tests for them.
See the comments on f9950fa
For example the majority of the tests in S03-metaops/cross.t use is
which is less than ideal.
It may take some manual searching to find the rest of the cases which should be changed.
I can find the tie-breaking rule between where-blocked multi routines in roast.
https://github.com/perl6/roast/blob/master/S06-multi/subsignature.t#L431-L441
However, it seems that there is another tie-breaking rule that where-blocked multi has higher priority than non-where-blocked multi.
The following example shows the above mentioned rule.
$ perl6 -e 'multi foo(Int $a){ say "1st" }; multi foo(Int $a where *.so){ say "2nd" }; foo(-1)'
2nd
$ perl6 -e 'multi foo(Int $a where *.so){ say "1st" }; multi foo(Int $a){ say "2nd" }; foo(-1)'
1st
Reading through s02 section Exponentials, I found a number representation which I tried in perl6.
Result is
> :10<1*2**-64>
===SORRY!=== Error while compiling <unknown file>
Malformed radix number
at <unknown file>:1
------> :10<1*2**⏏-64>
expecting any of:
number in radix notation
It seems not to accept the minus sign. It will accept positive numbers.
This is not tested in 'S02-literals/radix.t lines 183–192'.
Version of perl;
This is perl6 version 2015.01-77-gd320f00 built on MoarVM version 2015.01-21-g4ee4925
Today I was running the stresstest on a starved box and when it was done, I noticed there was still a running process running this test.
So it looks like some conditions exist, under which doesn't-hang()
does not successfully kill the process after the timeout.
EDIT: indeed there's a bug where .kill doesn't always kill: https://rt.perl.org/Ticket/Display.html?id=131479
Pulled from https://rt.perl.org/rt3/Ticket/Display.html?id=58922
Subject: .perl for self-referent structures
Date: Tue, 16 Sep 2008 17:17:27 +0200
To: [email protected]
From: "Carl M�sak" <[email protected]>
Download (untitled) [text/plain 631b]
Calling .perl on a self-referent structure makes Rakudo r31152 hang.
$ ./perl6 -e 'my @a = (1); @a[0] := @a; @a.perl'
<masak> pmichaud: what about @a[0] := @a ?
<pmichaud> masak: I don't know about that one. :-)
[...]
<masak> :)
[...]
<pmichaud> part of me thinks that ends up with a self-referential structure
<masak> I hope so
<masak> that seems to be what's happening in at least one case in
Rakudo right now
<masak> question is, should .perl be able to handle that, and if so, how?
<moritz_> masak: it should
<moritz_> perhaps it should emit something like 'do { my @x = (...);
@x[0] := @x; @x }'
* masak submits rakudobug
# Fri Nov 07 15:01:43 2008 pmichaud - Correspondence added [Reply] [Comment]
RT-Send-CC: [email protected]
Download (untitled) [text/plain 193b]
I'm going to mark this ticket as stalled until we have a good idea of
how self-referent structures should be handled in the output, either
through the spec itself or the spectests.
Thanks!
Pm
See http://irclog.perlgeek.de/perl6-dev/2016-09-27#i_13295357
There's a passing mention in S03-metaops/hyper.t
to test them for nodalness, but the functionality itself isn't tested.
The behaviour can be found from sourcecode here and here. the docs here and here, or you can join our IRC channels and ask for clarifications #perl6 or #perl6-dev.
Create new test files: S32-list/duckmap.t
(might already exist) and S32-list/deepmap.t
. Copy over one of the existing files in that directory to use as a starting template. Use any of the available testing routines to thoroughly test all of the behaviour and then submit the PR.
Once done and the PR is merged, if you did create new files, you can also submit another PR to add them to Rakudo's test list; just add your file where it fits alphabetically.
I'm not sure if that's the right place to report that (why there are no “is not tested” issues here?).
It looks like there are no tests for UInt.
Given that we have StrDistance available to any user, it should be tested.
This is related to doc issue Raku/doc#691
Installing rakudo perl6 with moar
make test
...
t/04-nativecall/15-rw-args.t ......... ok
t/04-nativecall/16-rt125408.t ........ Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
t/04-nativecall/16-rt125729.t ........ ok
...
More verbose (prove6 is an alias)
prove6 -v t/04-nativecall/16-rt125408.t
t/04-nativecall/16-rt125408.t .. Unhandled exception: Missing or wrong version of dependency 'gen/moar/stage2/QRegex.nqp' (from 'src/gen/m-main.nqp')
at <unknown>:1 (/home/marcel/Software/lib/perl6/share/perl6/runtime/perl6.moarvm:<dependencies+deserialize>:73)
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run
Test Summary Report
-------------------
t/04-nativecall/16-rt125408.t (Wstat: 256 Tests: 0 Failed: 0)
Non-zero exit status: 1
Parse errors: No plan found in TAP output
Files=1, Tests=0, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.02 cusr 0.00 csys = 0.05 CPU)
Result: FAIL
Version is
./perl6-m -v
This is perl6 version 2015.07.1-182-g5ba44fc built on MoarVM version 2015.07-108-g7e9f29e
OS is
uname -a
Linux h03-fedora 4.1.5-100.fc21.x86_64 #1 SMP Tue Aug 11 00:24:23 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
This really simple thing seems to be not covered by roast: https://irclog.perlgeek.de/perl6/2016-12-10#i_13717049
Besides other RT #124909 issues, FETCH can get called more than once.
I am sorry but I don't know how to open the issue for just that test file.
use v6;
#`{{
The problem is that with an $.attr type of Int FETCH is called twice
for one access to $.attr.
If you take away the type of Int $f_count returns 1 and bug goes away
According to timotimo "rakudo doesn't guarantee how often FETCH is called"
http://irclog.perlgeek.de/perl6/2015-09-25#i_11276252
}}
use Test;
plan 1;
our $f_count = 0;
class C {
has Int $.attr is rw;
method attr returns Int is rw {
return Proxy.new(
FETCH => -> $self {$f_count++; 42 },
STORE => -> $self, Int $new {},
);
}
}
my C $c .= new;
my $a = $c.attr;
is($f_count, 1, 'fetch called more than once can be unexpected');
When trying some older camelia queries I found this:
Code:
sub plop { loop (my int $i = 0; $i < 10; ++$i) { say $i }; }; plop();
Result (2015.12):
No lexical found with name '$i'
in block <unit> at /tmp/sNWgnSu4JV line 1
Result (HEAD):
0
1
2
3
4
5
6
7
8
9
Bisectable says that it was fixed in rakudo/rakudo@37e742f
I wonder if there's any test for this. If not, then we should probably add one.
Code:
say ‘abc’.trans(‘a’ => ‘X’, ‘a’ => ‘Z’, ‘c’ => ‘C’)
Result (2015.12):
XbC
Result (2016.02,HEAD):
ZbC
Discussion with TimToady here: http://irclog.perlgeek.de/perl6/2013-06-30
Based on grep of the repo, we have a rather scanty collection of S///
rests. We need more, especially tests with adverbs.
cpan@perlbuild2~/CPANPRC/rakudo/t/spec (master)$ grep -FR 'S/' .
./S03-operators/andthen.rakudo.moar:todo('RT 127822'); is (S/a/A/ andthen S/b/B/ given "ab"), "AB", 'andthen with two S///';
./S03-operators/andthen.t:is (S/a/A/ andthen S/b/B/ given "ab"), "AB", 'andthen with two S///';
./S05-substitution/subst.rakudo.moar: is S/a/A/, "foo", "non-mutating single substitution works ($/)";
./S05-substitution/subst.rakudo.moar: is S/o/O/, "fOo", "non-mutating single substitution works ($/)";
./S05-substitution/subst.rakudo.moar: is S/(o)/{$0.uc}/, "fOo", "non-mutating single substitution works ($0)";
./S05-substitution/subst.rakudo.moar: is_run 'await ^30 .map: { start { S/.+/{$/.chars.print}/ given "abc"; } }', {
./S05-substitution/subst.t: is S/a/A/, "foo", "non-mutating single substitution works ($/)";
./S05-substitution/subst.t: is S/o/O/, "fOo", "non-mutating single substitution works ($/)";
./S05-substitution/subst.t: is S/(o)/{$0.uc}/, "fOo", "non-mutating single substitution works ($0)";
./S05-substitution/subst.t: is_run 'await ^30 .map: { start { S/.+/{$/.chars.print}/ given "abc"; } }', {
It wasn't meant to be spectested even when it existed, so it needs to go from spectests.
Reminder for myself to fix this:
Test::Util::is-deeply-junction tests guts, but doesn't actually check the types of junctions match as well.
Correct me if I am wrong but this https://github.com/perl6/roast/blob/master/S11-modules/re-export.t looks like never being executed and not skipped. Also plan is bigger than number of tests.
The C programming language allows enumeration constants like this one:
enum { foo, bar = foo };
In Perl 6, that would correspond to:
enum ("foo", bar => foo);
Currently, such code dies like this:
===SORRY!=== Error while compiling -e
Undeclared routine:
foo used at line 1
I did not see it tested anywhere in S12-enum/, which means either that I failed to find it, that Perl 6 is not meant to behave as C in that regard, or that it was involuntary omitted.
The second case would be LTA imho. I stumbled upon such kind of enum while looking at a header file for the Vulkan 3D graphics API. I don't look at C header files very often so the fact that I've seen this construction suggests that they are not very rare. I believe Perl 6's enumeration constants should behave similarly as their C counterparts, since that would help the translation of C header files for NativeCall bindings.
nl-in
seem to be in S16-io/lines.t, but I don't see anything that would test its default value.nl-out
is in S29-any/deg-trans.t, arguably it tests the default value.:enc
is used everywhere, but I don't see anything that would test its default behavior.There is a high chance that something actually tests it somewhere (probably implicitly), but I think we should have a couple of clear simple tests exactly for the purpose of testing the default values.
In some sense this ticket is a continuation of Raku/doc#1111.
Originally opened as https://rt.perl.org/rt3/Ticket/Display.html?id=58290
Subject: <prior> not implemented in rules in Rakudo
Date: Sat, 23 Aug 2008 11:26:49 +0200
To: [email protected]
From: "Carl M?sak" <[email protected]>
To match whatever the prior successful regex matched, use:
/ <prior> /
r30466:
$ ./perl6 -e 'my $s = "hello"; say $s ~~ /ll/; say $s ~~ /ll/' # works
ll
ll
$ ./perl6 -e 'my $s = "hello"; say $s ~~ /ll/; say $s ~~ / <prior> /'
# not implemented
ll
Unable to find regex 'prior'
Null PMC access in invoke()
[...]
This feature request is perhaps more accurately classified as
pertaining to PGE. Please re-tag as needed.
Subject: Re: [perl #58290] <prior> not implemented in rules in Rakudo
Date: Sat, 23 Aug 2008 08:16:43 -0500
To: [email protected]
From: "Patrick R. Michaud" <[email protected]>
On Sat, Aug 23, 2008 at 02:27:10AM -0700, Carl M?sak wrote:
> To match whatever the prior successful regex matched, use:
>
> / <prior> /
>
> r30466:
> $ ./perl6 -e 'my $s = "hello"; say $s ~~ /ll/; say $s ~~ /ll/' # works
> ll
> ll
> $ ./perl6 -e 'my $s = "hello"; say $s ~~ /ll/; say $s ~~ / <prior> /'
> # not implemented
> ll
> Unable to find regex 'prior'
> Null PMC access in invoke()
> [...]
>
> This feature request is perhaps more accurately classified as
> pertaining to PGE. Please re-tag as needed.
...correct -- C<< <prior> >> is not yet implemented. I'm not
certain if it belongs in PGE or in Rakudo... I'm guessing that
<prior> needs to refer to the "prior successful regex" in a
statement-level context, as opposed to a regex context. For
example, if we interpret S05 literally then in the regex
/ <foo> <prior> /
it's pretty clear that C<< <foo> >> is the prior successful regex
matched, and I think that's not what is intended by C<< <prior> >>.
(If it is what is intended, then C<< <prior> >> becomes much
simpler. :-)
Pm
RT-Send-CC: [email protected]
I've changed this ticket to indicate that it's waiting on spec
clarification as to the exact meaning of <prior> in regexes.
Pm
Alias to infix: defined in src/core/List.pm. Likely just an oversight, still at least a test for existence is required.
One that is notably missing is .sort on native arrays. Others may be missing as well.
Filing this for records. Some of these are likely due to poorly constructed tests. Will try to look at them...
On today's HEAD, I get the following stresstest failures when run on Windows 10. I've not yet checked if any of these are simply floppers that pass when run on their own....
RT will follow soon
https://docs.perl6.org/language/operators#infix_cmp says:
if $a eqv $b, then $a cmp $b always returns Order::Same.
That makes sense and leads me to expect this should work, but it doesn't:
use Test;
class Point3D { has Int $.x; has Int $.y; has Int $.z; }
my $p1 = Point3D.new(:1x, :2y, :3z);
my $p2 = Point3D.new(:1x, :2y, :3z);
my $p3 = Point3D.new(:1x, :2y, :300z);
ok $p1 eqv $p2;
ok $p1 !eqv $p3;
is $p1 cmp $p2, Order::Same; # fail: actually returns Less
is $p1 cmp $p3, Order::Less;
is $p3 cmp $p1, Order::More;
I can get the third test to behave by adding:
multi infix:<cmp>($a, $b where $b eqv $a) { Order::Same }
sub named-def(:$def = 5 ){
say $def
}
my $key = 'def'
named-def( $key => 15 )
Too many positionals passed; expected 0 arguments but got 1
perl6 -v
This is perl6 version 2015.07.1 built on MoarVM version 2015.07
S04-blocks-and-statements/temp.t does have tests for @A[1] and %h<b> but seems not for whole array and hash. (temp @A) and (temp %h) work as expected AFAIK for current Rakudo and conforms to temp description as replacement for local. If no objection to issue may try to add tests in a few days.
There are a couple of mentions of .pairup
method, but none do thorough testing of the functionality.
Maybe there are some already. But if not, consider adding something like this:
<AlexDaniel> m: say [+] (3..9).map: *³
<camelia> rakudo-moar ea67ce: OUTPUT«2016»
<AlexDaniel> bisect: say [+] (3..9).map: *³
<bisectable6> AlexDaniel, Bisecting by exit code (old=2015.12 new=ea67ce9). Old exit code: 1
<bisectable6> AlexDaniel, bisect log: https://gist.github.com/2118bb6a99db2b8486a7f3776da3ab9b
<bisectable6> AlexDaniel, (2016-12-16) https://github.com/rakudo/rakudo/commit/c35d562df19d1351c8ea38bfa7027c8ea2092b75
<AlexDaniel> commit: c35d562df1^,c35d562df1 say [+] (3..9).map: *³
<committable6> AlexDaniel, ¦«c35d562df1^»: Cannot resolve caller Numeric(Whatever: ); none of these signatures match: (Mu:U \v: *%_) in block <unit> at /tmp/YswXNqpQVd line 1 «exit code = 1»¦«c35d562»: 2016
Commit 0892f24 tests all the candidates of Array.splice, but never bothers to check the arguments received by Callable
params are correct. The offset
Callables receive the .elems
of the Array being spliced and size
Callables receive the size of the piece past offset (that is .elems - offset
)
[15:17] <quietfanatic> p6: say (reduce *+*, 1, 2).WHAT
[15:17] <+camelia> rakudo-moar af886d: OUTPUT«(Int)»
[15:17] <quietfanatic> p6: say (reduce *+*, 1).WHAT
[15:17] <+camelia> rakudo-moar af886d: OUTPUT«(List)»
[15:17] <quietfanatic> Hah. If that isn't a reportable bug, I don't know what is.
I expect reduce with one item to return that item, but it wraps it in a List instead.
This should test for that.
is-deeply(reduce(+, 72), 72, "reduce with one item returns that item")
For reserved pragmas, add a doesn't die
type of test, so they could be documented.
The docs on fudging, IMHO, need to be written using "rakudo" as an example instead of "humpty", even though the test suites I guess can be used for other implementations--less confusing for wannabee contributors to rakudo. A wee bit more cookbook approach would also be useful.
I'll be glad to take a stab it unless this issue is deemed unnecessary.
permutations.t priviledges a particular order. That prevents the use of a possibly more efficient algorithm returning its results in a different order.
I suggest sorting the output before comparing it.
is (1, 2, 3).permutations.list.sort(:by(*.join)).perl, ((1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)).perl, "permutations method";
is permutations(3).list.sort(:by(*.join)).perl, ((0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)).perl, "permutations function";
As mentioned this would allow other algorithm such as this one (notice the credits, the author gave me autorisation via email):
sub permutations(int $n) {
# Credits for the following code goes to Phillip Paul Fuchs,
# who authorized its use here in november 2015.
# See his website, L<http://www.quickperm.org/>,
# for more information.
Seq.new:
class :: does Iterator {
has int $!n;
has @!a;
has int $!i;
has @!p;
submethod BUILD(:$n) { $!n = $n; self }
method pull-one {
if !@!a { @!a = ^$!n; $!i = 1; @!p = 0 .. $n; @!a; }
elsif $!i < $!n {
@!p[$!i]--;
@!a[$!i !%% 2 ?? @!p[$!i] !! 0, $!i].=reverse;
$!i = 0;
@!p[$!i] = $!i while @!p[++$!i] == 0;
@!a;
}
else { IterationEnd }
}
method count-only { [*] 1..$!n }
}.new(:$n)
}
From my experiments, it seems to me that this algorithm is about twice as fast.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.