Skip Menu |
Report information
Id: 70894
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Cannot do .keys on enum type stash in Rakudo
Date: Sat, 28 Nov 2009 00:12:01 +0100
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 1.1k
<masak> TimToady: how do I get all the names the elements of an enum, in order? <masak> TimToady: simplest one I've found so far is SomeEnum.pick(*).sort <masak> hardly very idiomatic. <TimToady> masak: you might try SomeEnum::.keys since Type:: is supposed to be the stash of the type; no guarantees about rakudo though <masak> TimToady: oki, thanks. <TimToady> doesn't guarantee order either <TimToady> though of course, enums are only conventionally in a particular order <TimToady> they're just a convenient way to write a lot of constants <masak> rakudo: enum SomeEnum <a b c>; say SomeEnum::.keys <masak> locally, I get "invoke() not implemented in class 'Perl6Role'" <p6eval> rakudo 7347ec: ( no output ) <masak> is that worth a rakudobug submission? <masak> std: enum SomeEnum <a b c>; say SomeEnum::.keys <p6eval> std 29203: ok 00:01 106m␤ * jnthn looks confused at what the intent was there <jnthn> Oh <jnthn> Treating it as a namespace...hm <masak> yah. a stash, said TimToady. * jnthn is vaguely surprised Rakudo even parses that. <masak> heh. <jnthn> I guess if it ends with :: we're meant to treat it as a stash...I guess I can go with that. <jnthn> File rakudobug if you like. * masak likes
Added test for this in t/spec/S02-builtin_data_types/enum.t .
Subject: [perl #70894] tests available
Date: Sun, 27 Jun 2010 03:35:04 -0500
To: perl6-bugs-followup [...] perl.org
From: kyleha [...] gmail.com
Download (untitled) / with headers
text/plain 1.4k
This is an automatically generated mail to inform you that tests are now available in t/spec/S02-builtin_data_types/enum.t commit ec3fecca07d477e483f061520a4765587652383d Author: radus <radus@c213334d-75ef-0310-aa23-eaa082d1ae64> Date: Sun Jun 27 08:30:51 2010 +0000 [t/spec] Added test for RT70894: Cannot do .keys on enum type stash in Rakudo. git-svn-id: http://svn.pugscode.org/pugs@31474 c213334d-75ef-0310-aa23-eaa082d1ae64 diff --git a/t/spec/S02-builtin_data_types/enum.t b/t/spec/S02-builtin_data_types/enum.t index 6c573b2..0eddf9f 100644 --- a/t/spec/S02-builtin_data_types/enum.t +++ b/t/spec/S02-builtin_data_types/enum.t @@ -83,7 +83,8 @@ is %hash.values.sort, <A B C D E>, '...and the right values are assigned'; %hash = (); -lives_ok { %hash = enum <<:Alpha<A> Bravo Charlie Delta Echo>>; }, 'specifying a string up front works (Texas quotes)', :todo<feature>; +#?rakudo todo 'feature' +lives_ok { %hash = enum <<:Alpha<A> Bravo Charlie Delta Echo>>; }, 'specifying a string up front works (Texas quotes)'; #?pugs todo 'feature' is %hash.keys.sort, <Alpha Bravo Charlie Delta Echo>, '...and the right keys are assigned'; @@ -133,6 +134,15 @@ is %hash.values, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'), ' dies_ok { RT66648.c }, 'die attempting to access enum item as method'; } +# RT #70894 + +{ + enum SomeEnum <a b c>; + #?rakudo skip "RT #70894" + lives_ok {SomeEnum::.keys}, 'keys on enum stash works'; + +} + done_testing; # vim: ft=perl6
Download (untitled) / with headers
text/plain 120b
NOM: does not die, however output looks wrong bbkr:nom bbkr$ ./perl6 -e 'enum SomeEnum <a b c>; say SomeEnum::.keys' 0
Download (untitled) / with headers
text/plain 458b
On Sun Sep 11 13:33:55 2011, bbkr wrote: Show quoted text
> NOM: does not die, however output looks wrong > > > bbkr:nom bbkr$ ./perl6 -e 'enum SomeEnum <a b c>; say SomeEnum::.keys' > 0
The output is right, in fact. The spec has changed, and the enum keys can be found with SomeEnum.enums.keys, which works fine. without the .enums, .keys falls back to Any.keys, which is 0 for a scalar. I'll unfudge the test in t/spec/S02-types/enum.t and consider this ticket closed.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org