Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 117 lines (94 sloc) 3.298 kB
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
1 use v6;
2
db4bde7 [t/spec] add 'use MONKEY_TYPING' where appropriate
lwall authored
3 use MONKEY_TYPING;
4
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
5 use Test;
6
7
8 =begin description
9
b8d99dd [t/spec] fix more smartlinks
moritz authored
10 Enum tests from L<S12/Enumerations>
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
11
12 =end description
13
14 #?pugs 999 skip
b7c9e84 [t/spec] delete some outdated tests in S12-enums/thorough.t and fix s…
moritz authored
15 # L<S12/Enumerations/keys are specified as a parenthesized list>
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
16 enum day <Sun Mon Tue Wed Thu Fri Sat>;
17
931b743 @moritz clean up enum tests a big, refudge for rakudo
moritz authored
18 is day.gist, 'day()', 'enum itself stringififes';
19 ok day.WHAT === day, 'enum.WHAT returned a value';
a8b77bc [spec] test .WHAT and .perl on actual enums, masak++
moritz authored
20 ok day.perl, 'enum.perl returned a value';
21
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
22 sub test_stuff($x) {
f852369 @colomon Comment out obsolete tests, fudge for niecza.
colomon authored
23 #?niecza skip 'No candidates for dispatch to infix:<does>'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
24 ok $x.does(day::Tue), "basic enum mixing worked ($x-2)";
25 is $x.day, 2, "automatically created accessor worked ($x)";
26 is day::Tue, 2, "enum provided a correct mapping ($x)";
27 ok $x ~~ day, "smartmatch worked correctly ($x-1)";
28 ok $x ~~ Tue, "smartmatch worked correctly ($x-2)";
29 ok $x ~~ day::Tue, "smartmatch worked correctly ($x-3)";
30 ok $x !~~ Wed, "smartmatch worked correctly ($x-4)";
f852369 @colomon Comment out obsolete tests, fudge for niecza.
colomon authored
31 #?niecza skip 'No candidates for dispatch to infix:<does>'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
32 ok $x.does(Tue), ".does worked correctly ($x-1)";
f852369 @colomon Comment out obsolete tests, fudge for niecza.
colomon authored
33 #?niecza skip 'No candidates for dispatch to infix:<does>'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
34 ok $x.does(day), ".does worked correctly ($x-2)";
35 ok $x.Tue, ".Tue() worked correctly ($x)";
931b743 @moritz clean up enum tests a big, refudge for rakudo
moritz authored
36 ok $x.Tue.WHAT === day, '$obj.Tue.WHAT returns the proper type object';
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
37 ok $x.Tue.perl, '$obj.Tue.perl returns a true valuee';
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
38 }
39
931b743 @moritz clean up enum tests a big, refudge for rakudo
moritz authored
40 #?rakudo skip 'NYI'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
41 {
42 my $x = 1;
43 is $x, 1, "basic sanity (1)";
b7c9e84 [t/spec] delete some outdated tests in S12-enums/thorough.t and fix s…
moritz authored
44 # L<S12/Enumerations/on the right side of a but or does.>
f852369 @colomon Comment out obsolete tests, fudge for niecza.
colomon authored
45 #?niecza skip 'No candidates for dispatch to infix:<does>'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
46 ok $x does day(Tue), "basic enum mixing worked (1-1)";
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
47 test_stuff($x);
48 }
49
50
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
51 #?rakudo skip 'does day::Tue'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
52 {
53 my $x = 3;
54 is $x, 3, "basic sanity (3)";
55 ok $x does day::Tue, "basic enum mixing worked (3-1)";
56 test_stuff($x);
57 }
58
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
59 #?DOES 16
60 #?rakudo skip 'does &day::("Tue")'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
61 {
62 my $x = 4;
63 is $x, 4, "basic sanity (4)";
b7c9e84 [t/spec] delete some outdated tests in S12-enums/thorough.t and fix s…
moritz authored
64 # L<S12/Enumerations/Mixing in the full enumeration type produces a
65 # read-write attribute>
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
66 ok $x does day, "basic enum mixing worked (4-0)";
67 ok $x.day = &day::("Tue"), "basic enum mixing worked (4-1)";
68 test_stuff($x);
69 }
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
70
71 # used to be Rakudo regression, RT #64098
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same wit…
moritz authored
72 #?DOES 2
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
73 {
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
74 augment class Mu {
75 method f { 'inMu' };
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
76 }
77
4b71fc9 [t/spec] fix an "is also" that is giving STD fits
lwall authored
78 augment class Bool {
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
79 method f { 'inBool' };
80 }
81 is True.f, 'inBool', 'method on short name pick up the one from the enum';
82 is Bool::True.f, 'inBool', 'method on long name pick up the one from the enum';
83 }
84
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same wit…
moritz authored
85 ok True.perl ~~/^ 'Bool::True'/, 'True.perl';
86 ok Bool::True.perl ~~/^ 'Bool::True'/, 'Bool::True.perl';
87
931b743 @moritz clean up enum tests a big, refudge for rakudo
moritz authored
88 #?rakudo skip 'enum name as type constraint'
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
89 {
90 enum Negation << :isnt<isnt> :arent<arent> :amnot<amnot> :aint<aint> >>;
91 my Negation $foo;
92 lives_ok { $foo = Negation::isnt }, 'simple assignment from enum';
fcf1024 [t/spec] More revisions of past tests
kyle authored
93 is $foo, Negation::isnt, 'assignment from enum works';
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
94 }
95
9feb346 [t/spec] Test for RT #66886
kyle authored
96 # RT #66886
97 {
98 enum RT66886 <b>;
8bf9bb9 fix RT #66886 test, thanks to TimToady++
kyle authored
99 eval_dies_ok 'RT66886::c', 'accessing non-value of enum dies proper-like';
9feb346 [t/spec] Test for RT #66886
kyle authored
100 }
101
1223acd [t/spec] Test for RT 65658
kyle authored
102 # RT #65658
103 {
104 enum RT65658 <Todo Bug Feature Ticket>;
105 is RT65658(2), RT65658::Feature, 'can index enum by number';
106 is RT65658((Todo + 3.2).Int), RT65658::Ticket, 'enum and math and index';
107 }
108
ed30b2e @diakopter test for RT #71196. resolves ticket.
diakopter authored
109 # RT #71196
110 {
111 eval_lives_ok 'enum X <A B C> is export', 'marking enum export does not die';
112 }
113
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
114 done;
1223acd [t/spec] Test for RT 65658
kyle authored
115
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
116 # vim: ft=perl6
Something went wrong with that request. Please try again.