Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 126 lines (104 sloc) 3.539 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
1223acd [t/spec] Test for RT 65658
kyle authored
7 plan *;
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
8
9 =begin description
10
11 Enum tests from L<S12/Enums>
12
13 =end description
14
15 #?pugs 999 skip
16 # L<S12/Enums/values are specified as a list>
17 enum day <Sun Mon Tue Wed Thu Fri Sat>;
18
d2c9e73 [t/spec] Add test for RT#63878.
jnthn authored
19 ok day ne "", 'enum itself stringififes';
3cfd6a2 [t/spec] Fudge a test that is failing in Rakudo.
jnthn authored
20 #?rakudo skip 'regression'
a8b77bc [spec] test .WHAT and .perl on actual enums, masak++
moritz authored
21 ok day.WHAT, 'enum.WHAT returned a value';
22 ok day.perl, 'enum.perl returned a value';
23
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
24 sub test_stuff($x) {
43b5fc8 [t/spec] .does(Enum::Value) is on shakey ground, since the values are…
jnthn authored
25 #?rakudo 1 skip '.does for enum value - XXX is this really valid test? asked TimToady...'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
26 ok $x.does(day::Tue), "basic enum mixing worked ($x-2)";
27 is $x.day, 2, "automatically created accessor worked ($x)";
28 is day::Tue, 2, "enum provided a correct mapping ($x)";
29 ok $x ~~ day, "smartmatch worked correctly ($x-1)";
30 ok $x ~~ Tue, "smartmatch worked correctly ($x-2)";
31 ok $x ~~ day::Tue, "smartmatch worked correctly ($x-3)";
32 ok $x !~~ Wed, "smartmatch worked correctly ($x-4)";
43b5fc8 [t/spec] .does(Enum::Value) is on shakey ground, since the values are…
jnthn authored
33 #?rakudo 1 skip '.does for enum value - XXX is this really valid test? asked TimToady...'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
34 ok $x.does(Tue), ".does worked correctly ($x-1)";
35 ok $x.does(day), ".does worked correctly ($x-2)";
36 #?rakudo skip 'EnumValue($x)'
37 ok Tue($x), "Tue() worked correctly ($x)";
38 ok $x.Tue, ".Tue() worked correctly ($x)";
39 #?rakudo skip 'unknown bug'
40 ok $x.Tue.WHAT, '$obj.Tue.WHAT returns a true valuee';
41 ok $x.Tue.perl, '$obj.Tue.perl returns a true valuee';
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
42 }
43
44 {
45 my $x = 1;
46 is $x, 1, "basic sanity (1)";
47 # L<S12/Enums/has the right semantics mixed in:>
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
48 ok $x does day(Tue), "basic enum mixing worked (1-1)";
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
49 test_stuff($x);
50 }
51
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
52 #?DOES 15
53 #?rakudo skip 'does day<tue> - but is this even valid?'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
54 {
55 my $x = 2;
56 is $x, 2, "basic sanity (2)";
57 # L<S12/Enums/or pseudo-hash form:>
58 ok $x does day<Tue>, "basic enum mixing worked (2-1)";
59 test_stuff($x);
60 }
61
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
62 #?rakudo skip 'does day::Tue'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
63 {
64 my $x = 3;
65 is $x, 3, "basic sanity (3)";
66 # L<S12/Enums/is the same as>
67 ok $x does day::Tue, "basic enum mixing worked (3-1)";
68 test_stuff($x);
69 }
70
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
71 #?DOES 16
72 #?rakudo skip 'does &day::("Tue")'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
73 {
74 my $x = 4;
75 is $x, 4, "basic sanity (4)";
76 # L<S12/Enums/which is short for something like:>
77 ok $x does day, "basic enum mixing worked (4-0)";
78 ok $x.day = &day::("Tue"), "basic enum mixing worked (4-1)";
79 test_stuff($x);
80 }
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
81
82 # used to be Rakudo regression, RT #64098
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same wit…
moritz authored
83 #?rakudo skip 'augment'
84 #?DOES 2
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
85 {
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
86 augment class Mu {
87 method f { 'inMu' };
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
88 }
89
4b71fc9 [t/spec] fix an "is also" that is giving STD fits
lwall authored
90 augment class Bool {
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
91 method f { 'inBool' };
92 }
93 is True.f, 'inBool', 'method on short name pick up the one from the enum';
94 is Bool::True.f, 'inBool', 'method on long name pick up the one from the enum';
95 }
96
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same wit…
moritz authored
97 ok True.perl ~~/^ 'Bool::True'/, 'True.perl';
98 ok Bool::True.perl ~~/^ 'Bool::True'/, 'Bool::True.perl';
99
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
100 {
101 enum Negation << :isnt<isnt> :arent<arent> :amnot<amnot> :aint<aint> >>;
102 my Negation $foo;
103 #?rakudo todo 'Null PMC Access in invoke()'
104 lives_ok { $foo = Negation::isnt }, 'simple assignment from enum';
fcf1024 [t/spec] More revisions of past tests
kyle authored
105 #?rakudo skip 'Null PMC Access in invoke()'
106 is $foo, Negation::isnt, 'assignment from enum works';
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
107 }
108
9feb346 [t/spec] Test for RT #66886
kyle authored
109 # RT #66886
110 {
111 enum RT66886 <b>;
8bf9bb9 fix RT #66886 test, thanks to TimToady++
kyle authored
112 eval_dies_ok 'RT66886::c', 'accessing non-value of enum dies proper-like';
9feb346 [t/spec] Test for RT #66886
kyle authored
113 }
114
1223acd [t/spec] Test for RT 65658
kyle authored
115 # RT #65658
116 {
117 enum RT65658 <Todo Bug Feature Ticket>;
118 #?rakudo 2 skip 'RT 65658'
119 is RT65658(2), RT65658::Feature, 'can index enum by number';
120 is RT65658((Todo + 3.2).Int), RT65658::Ticket, 'enum and math and index';
121 }
122
123 done_testing;
124
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
125 # vim: ft=perl6
Something went wrong with that request. Please try again.